News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Help me with the linking of external library

Started by Justin, December 05, 2008, 08:35:16 AM

Previous topic - Next topic

Justin

I have download some external libraries with extended name .a/.lib,  I want to link those libraries to my own project. I have configured the linker and seach path. But there are always problems. I cannot see the API lists of those libraries, and I cannot call the functions enveloped in those libraries.
My OS is Vista, and I am using the lastest version of CB.
What's wrong? Help!

Ceniza

Enable full compiler logging and copy&paste the problem here.

From Morten's signature: Logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"

Justin


-------------- Build: Debug in testC ---------------

mingw32-g++.exe -Llib  -o bin\Debug\testC.exe obj\Debug\main.o    lib\libcluto.a
obj\Debug\main.o: In function `main':
D:/CppProjects/testC/main.c:73: undefined reference to `_CLUTO_VP_ClusterRB
'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings

Justin

the document of those libraries said the libraries were compiled with gcc,  so did I use the wrong compiler, that is to say not mingw32-g++.exe,  but mingw32-gcc.exe?

Jenna

Quote from: Justin on December 05, 2008, 09:57:57 AM
the document of those libraries said the libraries were compiled with gcc,  so did I use the wrong compiler, that is to say not mingw32-g++.exe,  but mingw32-gcc.exe?

I don't think so.
gcc is either the gnu-compiler-collection or the c-compiler included in gcc, in both cases it should not be causing your problem.

But if the lib really was compiled with mingw32-gcc it's a c-library and you have to declare the functions inside the header as extern "c" to make them usable with c++.

google for extern "c", to see how you can do this.

Ceniza

I've never tried to link a library like that myself, but you may try adding as library only "cluto" (without quotes, of course). That should change the command line in that to -lcluto.

If you are the one who has to write the API declarations, do as jens said.

Jenna

Try what Ceniza said, if that does not work, try to link with libcluto.lib.
According to the manual you have to use libcluto.a on unix-based systems and libcluto.lib on win32 systems.