|
-
June 29th, 2005, 05:56 AM
#1
Trouble linking with boost libs
Hi all
Im having some headaches using the boost filesystem lib and hope someone can offer advice as im pickled!
My recipie for disaster is two projects, one a static lib that uses boost::filesystem. The second is a client executable that uses my static lib.
Where is the linker getting the boost lib from? Usually to utilise a static library I would include the headers in my code and specify the library in the project's link options. In this case I did not specify the lib in the link tab, and when compiling i got a "cannot find libboost_filesystem-vc6-mt-gd-1_32.lib" error instead of an unresolved external error that I was expecting.
Anyway my library linked ok once i dropped libboost_filesystem-vc6-mt-gd-1_32.lib into the project dir.
Next i came to build my executable project, now the header from my library must include the boost/filesystem/path.hpp file because a class in my library has a BFS: ath as a member. When linking I got a simmilar error to when building the library: "cannot find libboost_filesystem-vc6-sgd-1_32.lib". Both projects are configured as Debug Single Threaded runtime but the library project wanted the mt boost lib and the exe project wanted the st version!
I dont want my exe linking directly against boost and i dont see why it should wan't to either as my static library links to the required boost functionality.
I hope this makes sense!
regards
chris
-
June 29th, 2005, 06:49 AM
#2
Re: Trouble linking with boost libs
Did you bjam when you installed boost?
Did you stage when you installed boost?
Did you add the stage folder to your library search paths in your IDE?
Read the boost installation docs, follow the procedure, it takes about 30 mins for the libs to build then collate the libs into 1 folder with a bjam stage or something like that. Add the staged folder to your paths and you should be good to go.
Hungarian notation is the bane of self documenting code.
Forget all fancy tricks with operator precedence. Code should be easily readable.
May the BOOST be with you.
Good free E-Books thanks to Bruce Eckel.
-
June 29th, 2005, 03:28 PM
#3
Re: Trouble linking with boost libs
As for the problem with the executable project linking against the filesystem library, that is because you include the path.hpp header. That header includes filesystem/config.hpp and that in turn autolinks against the appropriate library. You can probably prevent that (as long as you don't call any of the functions in the libs) by defining BOOST_FILESYSTEM_NO_LIB before you include the other headers in your executable project.
As to why your two projects seem link against different threading models, I have no idea. Are you sure they both use the same run-time?
Insert entertaining phrase here
-
June 30th, 2005, 02:15 AM
#4
Re: Trouble linking with boost libs
Thanks, I have not come across of the auto-linking feature of VC!
And yes both projects are using the same runtime, maybe it has something to do with the autolink mechanism.
Anyhow, I have found the easiest way to build the project it is with dynamic linking, using the BOOST_ALL_DYN_LINK definition.
As a side note if i use the library in the exe project and build with the reqired lib, I get a load of multiple symbol definition errors. Why doent the same thing happen with the standard C/C++ libraries that are used by both my lib and my exe?
many thanks
chris
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|