Code::Blocks Forums

User forums => Help => Topic started by: keyser on July 17, 2008, 02:14:16 pm

Title: Linker can't find my lib file, what's wrong ?
Post by: keyser 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 ?
Title: Re: Linker can't find my lib file, what's wrong ?
Post by: thomas 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.
Title: Re: Linker can't find my lib file, what's wrong ?
Post by: dje 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
Title: Re: Linker can't find my lib file, what's wrong ?
Post by: MortenMacFly 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.
Title: Re: Linker can't find my lib file, what's wrong ?
Post by: keyser 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.
Title: Re: Linker can't find my lib file, what's wrong ?
Post by: keyser 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.
Title: Re: Linker can't find my lib file, what's wrong ?
Post by: keyser 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"