tags:

views:

325

answers:

3

I have created a XCode project and I have added "/opt/local/include/boost" to Header Search Path and "/opt/local/lib" to Library Search Path

But I still have this error:

boost::system::get_generic_category()", referenced from:
   __static_initialization_and_destruction_0(int, int)in main.o
   __static_initialization_and_destruction_0(int, int)in main.o
   __static_initialization_and_destruction_0(int, int)in main.o

And in my /opt/local/lib, I find this (I assume that is Boost.System library):

-rw-r--r--  2 root  admin     80600 Jul 23 16:31 libboost_system-mt.a
-rwxr-xr-x  2 root  admin     30988 Jul 23 16:30 libboost_system-mt.dylib*

Can you please tell me what am I missing?

A: 

You are missing:

-lboost_system-mt

Unfortunately, your question (and your questions on the boost-user mailing list) also suggests that you are missing basic knowledge of how C++ compilers operate. If this is because you are coming from Windows and "spoiled" by autolink, I recommend you google and read the material on the topic. If that is because you are new to C++ in general, I would not recommend you to make much use of the the Boost C++ Libraries until you gain understanding of the basics.

Vladimir Prus
I think you're assuming too much. Nearly all of Boost is header-only, so it's quite easy to forget when you need to link explicitly to another library. And being "spoiled" by a terrific feature idea is nothing to be chastised about.
Rob Kennedy
agreed with Rob. And even if you are "spoiled" by a feature offered on other platforms, "google it" is generally not a good answer on SO. People are supposed to come to SO to find answers, not a redirect to Google.
jalf
jalf, the correct answer to the question is given in the first paragraph. However, I still believe that knowledge of what -I, -L and -l option do is essential for C++ developer. and this question, and the questions that OP asked on the Boost mailing list suggest some problems with all of those 3. I think it's important thing to learn now, to avoid problems later.
Vladimir Prus
I agree that the response was harsh. You might as well have written rtfm!
jkp
+2  A: 

Adding the library path isn't sufficient. That just ensures that whenever you tell it to link to a library, it will search for that library in the specified path as well as all the default paths.

So you also need to actually tell the compiler to link to the library, with the flag

-lboost_system-mt

On Windows, Boost supports autolinking by default -- that is, if you just include the correct headers, it will attempt to link to the actual libraries as well (through use of a MSVC #pragma). On other platforms, you have to manually link to the library.

jalf
+1  A: 

To link to Libraries in XCode, right click the "Target" that uses Boost and choose Get Info. In the lower list "Linked Libraries" add the boost dylib files by clicking the +

Hope this helped.

Wgaffa