User forums > Using Code::Blocks
Setting up 3rd party libraries
KirkD:
I have a 3rd party library (OpenBabel - www.openbable.org) that was built using VC++ Express 2008 that I'm trying to use in Code::Blocks. I can link to this library and compile an application through VC++ Express 2008 or through Code::Blocks if I specify VC++ as the compiler of choice. But, when I switch go the GCC compiler and (to the best of my knowledge) have the libraries specified as well as the correct search paths, I always get "undefined reference to" errors referring to functions within the OpenBabel libraries.
Is it not possible to link to a library built with another compiler? I could rebuild with GCC, but I would prefer to use these prebuilt libraries.
I appreciate any assistance!
-Kirk
MortenMacFly:
--- Quote from: KirkD on August 07, 2009, 07:53:40 pm ---Is it not possible to link to a library built with another compiler?
--- End quote ---
It is possible. Notice that you just need to resolve the missing references - that's it. From my experience I can say that usually the import of VC projects into C::B works just fine. Just in a VC project you don't need to explicitly define all required libraries. Visual Studio seems to do some "voodoo" so that in the end the linker is happy. C::B doesn't do such (luckily) so you must make sure that you have setup the project correctly.
So far I had only one (!) VC library that I was not able to use with GCC. Every else worked just fine - even such things like Direct/X.
KirkD:
Morten,
Thanks for the reply. I suppose it is at least comforting to know that it is possible.
At this point I've added every library in that I have and pointed to all the appropriate search directories, as far as I know. Any suggestions on where to look for what I'm missing? Or is this part of the "voodoo" - finding the missing parts??
-Kirk
MortenMacFly:
--- Quote from: KirkD on August 07, 2009, 08:14:34 pm ---Any suggestions on where to look for what I'm missing? Or is this part of the "voodoo" - finding the missing parts??
--- End quote ---
Notice that also the order matters. SO if lib1 requires lib2 you cannot link against lib1 in the first place. Here is what I usually do:
- import VC project
- remove all libs from the project's linker options (only the libs)
- compile
- notice the first missing symbol
- ask google what library this is from -> MSDN helps nicely if it's a MS Windows dependency
- if it's "my" stuff I either know or use the symbol table plugin to find the library that exports the missing symbol.
- like this I add all libs needed step by step and automatically have the right order.
stahta01:
--- Quote from: KirkD on August 07, 2009, 07:53:40 pm ---Is it not possible to link to a library built with another compiler? I could rebuild with GCC, but I would prefer to use these prebuilt libraries.
--- End quote ---
If all the exported functions are "C" it is possible. If C++ functions then it is NOT normally possible to change Compilers between client code and library code.
Tim S.
Navigation
[0] Message Index
[#] Next page
Go to full version