News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Linker can't find my lib file, what's wrong ?

Started by keyser, July 17, 2008, 02:14:16 PM

Previous topic - Next topic

keyser

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 ?

thomas

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

dje

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

MortenMacFly

Quote from: dje on July 17, 2008, 02:25:14 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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

keyser

Quote from: 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.

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

keyser

Quote from: 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

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.

keyser

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"