Author Topic: Linker can't find my lib file, what's wrong ?  (Read 8150 times)

Offline keyser

  • Single posting newcomer
  • *
  • Posts: 7
Linker can't find my lib file, what's wrong ?
« on: July 17, 2008, 02:14:16 pm »
My project is

F:\utility\utility.cbp

And I put one of my own lib file(container.a) to:

F:\utility\bin\lib\

So that the lib file is:

F:\utility\bin\lib\container.a

I have a build target named "Test", it's build a .exe which is linking to container.a

I add "F:\utility\bin\lib\" to "Search directories -> linker" in Build options

I add "container.a" to "Linker settings -> Link libraries" in Build options

But this doesn't work.

the error is :

ld.exe||cannot find -lcontainer.a|
||=== Build finished: 1 errors, 0 warnings ===|


why ?

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Linker can't find my lib file, what's wrong ?
« Reply #1 on: July 17, 2008, 02:22:45 pm »
Drop the .a extension ("container"), or provide a full, absolute path. MinGW wants one or the other, no thing in between.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline dje

  • Lives here!
  • ****
  • Posts: 683
Re: Linker can't find my lib file, what's wrong ?
« Reply #2 on: July 17, 2008, 02:25:14 pm »
I'm between and it works !
libwxmsw28u.a in the Link libraries
C:\wxWidgets-2.8.8\lib\gcc_dll in the linker search directories

EDIT: I use gcc version 3.4.5 (mingw-vista special) on XP SP2.

Did you specify your options to the right project /build target ?

Dje
« Last Edit: July 17, 2008, 02:29:23 pm by dje »

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: Linker can't find my lib file, what's wrong ?
« Reply #3 on: July 17, 2008, 04:36:43 pm »
I'm between and it works !
libwxmsw28u.a in the Link libraries
You are not. Notice the "lib" prefix? That's what's missing below. That's why it is not working and Thomas is right.
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 keyser

  • Single posting newcomer
  • *
  • Posts: 7
Re: Linker can't find my lib file, what's wrong ?
« Reply #4 on: July 18, 2008, 08:39:55 am »
Drop the .a extension ("container"), or provide a full, absolute path. MinGW wants one or the other, no thing in between.

I drop the ".a" extension, but it still doesn't work.

Offline keyser

  • Single posting newcomer
  • *
  • Posts: 7
Re: Linker can't find my lib file, what's wrong ?
« Reply #5 on: July 18, 2008, 08:52:37 am »
I'm between and it works !
libwxmsw28u.a in the Link libraries
C:\wxWidgets-2.8.8\lib\gcc_dll in the linker search directories

EDIT: I use gcc version 3.4.5 (mingw-vista special) on XP SP2.

Did you specify your options to the right project /build target ?

Dje

I meet that problem several times. I found that if i provide a full path of the ".a" file in the "Link Libraries" such as "F:\utility\bin\lib\container.a" it works well.

but if i change it to "container.a", and specific the path in "Search Directories" such as "F:\utility\bin\lib\", it doesn't work at all.

I think C::B should connect "Search Directories" and "Link Libraries", but it doesn't,  i don't know why.

Offline keyser

  • Single posting newcomer
  • *
  • Posts: 7
Re: Linker can't find my lib file, what's wrong ?
« Reply #6 on: July 18, 2008, 09:01:41 am »
Finally i got it worked.


I change my lib file name from "container.a" to "libcontainer.a", and then add "container"(without prefix or extension) in my "Link Libraries", and it works well.

And i also find that in Compiler and debugger settings you can set the libraries "prefix" and "extension", which in default is "lib" and "a"