News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

Setting up 3rd party libraries

Started by KirkD, August 07, 2009, 07:53:40 PM

Previous topic - Next topic

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?
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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

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??
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.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

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.

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.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

KirkD

stahta01  -  Interesting.  I'm not sure of the full nature of the library - not my development - so I don't know for certain about the exports. 

I've gone through the VC++ solution file and found all the listed dependencies for the library that seems to be failing.  Even when included in the "proper" order, etc. I cannot get around the reference failure.

So, I have the choice to rebuild using Code::Blocks or start using VC++ Express.  Code::Blocks is certainly my preference, but it may be more efficacious right now to go the other route.

Thank you both for your input!!

-Kirk


stahta01

#6
Compile the Library with the same compiler as the project is the way to go. The Library looks to be C++ to me.

https://sourceforge.net/projects/openbabel/

EDIT: FYI, Code::Blocks is an IDE not an compiler.

Tim S.
C Programmer working to learn more about C++.
On Windows 10 64 bit and Windows 11 64 bit.
--
When in doubt, read the CB WiKi FAQ. [url="http://wiki.codeblocks.org"]http://wiki.codeblocks.org[/url]

KirkD

Yes, I realize that Code::Blocks is an IDE - I tend to use Code::Blocks interchangeably with GCC.  oops.  8^)


I'll give the rebuild with GCC a shot.


PaulS

If it is C rather than C++ code this link may help -- http://www.emmestech.com/moron_guides/moron1.html.  I was able to use a small Microsoft dll by following the advice.  Even if C++ it may give you a clue about some of the problems.

Can't seem to get that link to format correctly -- may need a moron's guide for that too  :D