Author Topic: Help me with the linking of external library  (Read 5829 times)

Offline Justin

  • Single posting newcomer
  • *
  • Posts: 3
Help me with the linking of external library
« on: December 05, 2008, 08:35:16 am »
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!
 

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Help me with the linking of external library
« Reply #1 on: December 05, 2008, 08:44:00 am »
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"

Offline Justin

  • Single posting newcomer
  • *
  • Posts: 3
Re: Help me with the linking of external library
« Reply #2 on: December 05, 2008, 09:52:02 am »

-------------- 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
 

Offline Justin

  • Single posting newcomer
  • *
  • Posts: 3
Re: Help me with the linking of external library
« Reply #3 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?

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Help me with the linking of external library
« Reply #4 on: December 05, 2008, 10:39:44 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.

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: Help me with the linking of external library
« Reply #5 on: December 05, 2008, 11:37:12 am »
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.

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7252
Re: Help me with the linking of external library
« Reply #6 on: December 05, 2008, 11:52:23 am »
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.