Code::Blocks Forums

User forums => Help => Topic started by: orefa on September 17, 2005, 03:28:30 am

Title: Static library "lib" prefix.
Post by: orefa on September 17, 2005, 03:28:30 am
Not sure if this is normal or not, but when I compile a static library named "foo" the resulting product is named "libfoo.a", that is a "lib" prefix is prepended to the name I gave it. I deleted the prefix from the target name in the project options but c::b insists on adding it. Maybe there's a reason for it that I'm not thinking of. Is this intentional or should I report it as a bug?
Title: Re: Static library "lib" prefix.
Post by: Ceniza on September 17, 2005, 04:07:22 am
That must be intentional. Libraries in GCC start with lib and have the extension .a.

When you try to link a library (specifying -lname_of_the_library) it'll try to find libname_of_the_library.a

So, don't worry, it isn't a bug.
Title: Re: Static library "lib" prefix.
Post by: rickg22 on September 17, 2005, 04:28:13 am
How curious, I reported this as a bug a week ago. Yiannis fixed it in CVS so that codeblocks isn't confused with library names anymore.
Title: Re: Static library "lib" prefix.
Post by: orefa on September 17, 2005, 04:45:33 am
Yiannis fixed it in CVS

So it won't add "lib" to the library name anymore? That would be better. I just tried to link that "foo.a" in another project but the linker was not actually looking for "libfoo.a" so I had to rename it. A minor problem, but it's better solved than not. :)
Title: Re: Static library "lib" prefix.
Post by: mandrav on September 17, 2005, 11:52:23 am
Yiannis fixed it in CVS

So it won't add "lib" to the library name anymore? That would be better. I just tried to link that "foo.a" in another project but the linker was not actually looking for "libfoo.a" so I had to rename it. A minor problem, but it's better solved than not. :)


Yes, it's fixed.
Title: Re: Static library "lib" prefix.
Post by: severach on September 23, 2005, 07:34:01 am
The reason you prepend lib and postpend .a onto the specified file is so all compilers can use the same lib names and the lib tool adapts to the proper names. I should be able to specify the following standard libs without having to change them for each compiler I use.

shell32 (shell32.lib libshell32.a)
user32
shlwapi
C:\Program Files\CodeBlocks\lib\foo.a

If you use the full path for the lib, C::B does not add anything. There should be a less drastic way to get C::B to drop prefixes and suffixes. I end up with .o/.obj problems too. It seems that C::B stores a default lib/obj extension for each compiler but I can't find where to change it.
Title: Re: Static library "lib" prefix.
Post by: zieQ on September 23, 2005, 08:05:53 am
I end up with .o/.obj problems too. It seems that C::B stores a default lib/obj extension for each compiler but I can't find where to change it.

There's none actually, the prefix and extension are hardcoded into the compiler plugin. This will be subject to changes in the compiler revamp after v1.0  :wink:
Title: Re: Static library "lib" prefix.
Post by: mandrav on September 23, 2005, 09:32:56 am
It 's in Settings->Compiler->Other->Advanced options.