سؤال

I want to conditionally compile some c++ code that uses boost, and make it so it doesn't try to compile the boost dependent code if boost is not present.

Does boost have any global macro that will be defined, like __BOOST__, that I can check for?

EDIT: It's clear to me now that I have to achieve this on the makefile level. I am working on OSX lion. Using gnu make

هل كانت مفيدة؟

المحلول

The TYPICAL way that this is done is to use a "configuration script" or similar, that detects if the required/optional component(s) is/are present, and then selectively sets some -D options to the build system.

Obviously, if it's just your own project or a small distribution, you could do the same thing manually.

You probably also need a couple of ifdef type of choices in the Makefile if there are library files that you need.

One of the easier ways to determine if a part of boost that you need is installed is to try to compile it. If there are errors, the likely cause is that that part of boost isn't present (this obviously doesn't work if there are more important parts missing - for example, not having a compiler or standard library installed will ALSO cause a compile to fail. This is why nearly all configure type tools "start with the most basic features, and work their way up the tree of dependencies").

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top