User forums > Help
[solved] cannot find -lboost_regex-mgw34-mt-1_38.lib
Seronis:
Setting up c::b and boost on a laptop for a friend (running winxp sp3) that has mingw 3.4.5 already installed and working. I know its working cause it finished compiling boost with no problems just a few min ago.
In c::b i created a global variable for boost and a project to compile the example boost::regex on the 'getting started' page. In the projects Build Options i have $(#boost.include) and $(#boost.lib) in their respective search paths. So im at a loss as to why im getting the linking error.
edit: oh yeah. in linker settings the only included library name is
libboost_regex-mgw34-mt-1_38.lib
which is the exact filename in question. omitting the 'lib' prefix and/or omitting the '.lib' suffix to allow c::b to auto generate an appropriate name does not help.
[attachment deleted by admin]
Jenna:
Please post the appropriate part of the build log after changing "Settings -> Compiler and debugger... -> [your compiler] -> Other settings -> Compiler logging:" to "Full commandline".
Seronis:
--- Quote ----------------- Clean: Debug in testing ---------------
Cleaned "testing - Debug"
-------------- Build: Debug in testing ---------------
mingw32-g++.exe -Wall -fexceptions -g -IC:\dev\Boost\include\boost-1_38 -IC:\dev\SDL\SDL-1.2.13\include -c C:\dev\Projects\testing\main.cpp -o obj\Debug\main.o
mingw32-g++.exe -LC:\dev\Boost\lib\ -o bin\Debug\testing.exe obj\Debug\main.o -lboost_regex-mgw34-mt-1_38.lib
c:\dev\mingw\bin\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot find -lboost_regex-mgw34-mt-1_38.lib
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
1 errors, 0 warnings
--- End quote ---
also if i delete the 'lib' prefix from the file itself and delete both the prefix AND suffix from the filename used in the linker settings it is able to find the file. Does this qualify as a bug since it cant locate a lib file that begins with the letters 'lib' ?
edit: screen attached. filename listed in options exactly matches actual filename. lib prefix is removed apparently in the full commandline. renaming file and adjusting the option in the screenshot will allow it to be found.
[attachment deleted by admin]
Ceniza:
So, you are trying to link a MSVC library with GCC. Although it works to some extent, it is not exactly the best thing to do.
Anyway, when you add a library to the linker options, the generated command will be -l<name of the library>, which in turn will try to find the file lib<name of the library>.a (I am not sure if .so are also candidates, but at least with MinGW that is what it looks for).
Jenna:
--- Quote from: Ceniza on March 21, 2009, 10:32:02 pm ---So, you are trying to link a MSVC library with GCC. Although it works to some extent, it is not exactly the best thing to do.
Anyway, when you add a library to the linker options, the generated command will be -l<name of the library>, which in turn will try to find the file lib<name of the library>.a (I am not sure if .so are also candidates, but at least with MinGW that is what it looks for).
--- End quote ---
As far as I know doe sboost name the libs created with MinGW *.lib also.
And that leads to the problem.
C::B removes the starting lib, but leaves the file-ending untouched, and so it leads to the error with MinGW.
Quote from MinGW FAQ:
--- Quote ---How do I specify the libraries to be searched by the linker?
* MinGW supports libraries named according to the `<name>.lib' and `<name>.dll' conventions, in addition to the normal `lib<name>.a' convention common on *nix systems. To include any libraries named according to any of these conventions, simply add the `-l<name>' switch to the compiler command, ensuring it is placed _after_ the name of the module in which the reference appears.
* Note that, if the library is not found in any of the default library search paths, you may also need to insert a `-L<dir>' switch _before_ the `-l<name>' switch, to specify its location.
* Also note that the library names `lib<name>.a' and `lib<name>.lib' _are not_ equivalent; if you have a library named according to the aberrant `lib<name>.lib' convention, it will not be found by specifying the `-l<name>' switch -- you must use the form `-llib<name>' instead.
--- End quote ---
I think it's not correct, that C::B removes the prefix from a library with the suffix lib.
As a workaround it should work to put -llibboost_regex-mgw34-mt-1_38.lib into the Other linker options:-tab.
(edit: fixed a typo, the suffix should not be included, thanks Seronis)
You might also want to file a bug-report at berlios, so that the issue will not get lost in the deep of the forum.
Navigation
[0] Message Index
[#] Next page
Go to full version