Author Topic: build with libxxx library.  (Read 4242 times)

Offline readon

  • Single posting newcomer
  • *
  • Posts: 2
build with libxxx library.
« on: March 04, 2010, 09:18:52 am »
when i include libxml library in my project.
i find that, after typing libxml2 in "project build option-> link setting -> link libraries"
the ld.exe would report error cannot find -lxml2.  notice that lib was cutted automatically.
i tried many times, there are two ways to solve that.
1.rename the libxml2.lib file to xml2.lib.(path has already added to search directories)
2.type in full path of libxml2.lib.(this is not suitable for multi-developer case.)
above methods are not good enough.
how to solve this in a elegant way? is it a bug?

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: build with libxxx library.
« Reply #1 on: March 04, 2010, 09:39:49 am »
how to solve this in a elegant way?
Besides providing the name of the library you'll also need to provide the path to the library in the project options -> search directories -> linker.

is it a bug?
No.

A suggestion: First try to compile your file on the command line to understand how am compiler/linker works, then use an IDE.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline readon

  • Single posting newcomer
  • *
  • Posts: 2
Re: build with libxxx library.
« Reply #2 on: March 04, 2010, 11:00:19 am »
I have added the path in search directories-> linker
i think you can try it yourself with cb 8.02 /win32 using libxml2.lib.

i have using gcc & make system in linux.
in linux, prefix lib- and .so would be added automatically.

Offline Seronis

  • Almost regular
  • **
  • Posts: 197
Re: build with libxxx library.
« Reply #3 on: March 05, 2010, 04:49:23 am »
I think this is related to the fact that libraries are expected to be named  lib<name>.a  or   <name>.lib and  NOT   lib<name>.lib.   I had issues with this myself before and there was some small discussion on it being caused by CB doing some automatic name 'correcting' of what you enter and what it actually sends as the option to the linker.   I think a workaround was entering    liblib<name>.lib   in the cb box to compensate for improper name correcting.   I'll see if i can find the old thread...

-edit-

http://forums.codeblocks.org/index.php/topic,11123.0.html