Author Topic: [solved] cannot find -lboost_regex-mgw34-mt-1_38.lib  (Read 10165 times)

Offline Seronis

  • Almost regular
  • **
  • Posts: 197
[solved] cannot find -lboost_regex-mgw34-mt-1_38.lib
« on: March 21, 2009, 09:28:21 pm »
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]
« Last Edit: March 22, 2009, 02:19:55 am by Seronis »

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: cannot find -lboost_regex-mgw34-mt-1_38.lib
« Reply #1 on: March 21, 2009, 09:48:02 pm »
Please post the appropriate part of the build log after changing "Settings -> Compiler and debugger... -> [your compiler] -> Other settings -> Compiler logging:" to "Full commandline".

Offline Seronis

  • Almost regular
  • **
  • Posts: 197
Re: cannot find -lboost_regex-mgw34-mt-1_38.lib
« Reply #2 on: March 21, 2009, 09:50:43 pm »
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
 

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]
« Last Edit: March 21, 2009, 09:55:03 pm by Seronis »

Offline Ceniza

  • Developer
  • Lives here!
  • *****
  • Posts: 1441
    • CenizaSOFT
Re: cannot find -lboost_regex-mgw34-mt-1_38.lib
« Reply #3 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).

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: cannot find -lboost_regex-mgw34-mt-1_38.lib
« Reply #4 on: March 21, 2009, 10:54:12 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).

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.

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.
« Last Edit: March 22, 2009, 01:04:31 am by jens »

Offline Seronis

  • Almost regular
  • **
  • Posts: 197
Re: cannot find -lboost_regex-mgw34-mt-1_38.lib
« Reply #5 on: March 21, 2009, 11:33:47 pm »
i had to put -llibboost_regex-mgw34-mt-1_38 in there, no suffix, and it worked for me.  the suffix still causes problems but at least i didnt have to rename any files.

edit:

btw thanks for such fast responses.  kinda makes me curious why i didnt have this issue on my system at home.  will have to reinstall from scratch to see if its just the version of gcc my friend has here.  either way problem solved before time for me to go back home so greatly appreciated.
« Last Edit: March 21, 2009, 11:47:14 pm by Seronis »

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: cannot find -lboost_regex-mgw34-mt-1_38.lib
« Reply #6 on: March 22, 2009, 01:00:40 am »
i had to put -llibboost_regex-mgw34-mt-1_38 in there, no suffix, and it worked for me.  the suffix still causes problems but at least i didnt have to rename any files.

You are right of course.

Just a typo of mine, but the quoted FAQ describes it correctly.

TimmermanV

  • Guest
Re: cannot find -lboost_regex-mgw34-mt-1_38.lib
« Reply #7 on: March 22, 2009, 02:02:35 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.
I was trying to do the same thing here, so I'm curious,  what is the best thing to do and why?

Offline Seronis

  • Almost regular
  • **
  • Posts: 197
Re: [solved] cannot find -lboost_regex-mgw34-mt-1_38.lib
« Reply #8 on: March 22, 2009, 07:17:20 pm »
My problem actually had nothing to do with MSVC since I use gcc.  As jens pointed out it ended up just being a naming convention issue that is more the fault of bjam building the boost libraries with unconventional names that gcc doesnt handle automatically.  Not really even C::Bs fault but greatful for the work-a-round jens linked to.

I think I read something about using msvc binaries being linked with gcc in one of the cross compiling forums in the past.  Might be worth a search.  Dont really know anything else about that stuff since i've always assumed you should only link binaries with others made from the same environment.

Offline nanyu

  • Almost regular
  • **
  • Posts: 188
  • nanyu
Re: [solved] cannot find -lboost_regex-mgw34-mt-1_38.lib
« Reply #9 on: March 25, 2009, 10:15:20 am »
my method is :

${#boost.lib}\lib\libboost_regex-mgw34-mt-1_38.lib

Offline Seronis

  • Almost regular
  • **
  • Posts: 197
Re: [solved] cannot find -lboost_regex-mgw34-mt-1_38.lib
« Reply #10 on: March 25, 2009, 10:24:48 pm »
isnt the  /lib part redundant if your  boost.lib points to it?  That aside using a fully qualified path name worked for me too but that defeats the purpose of having lib search paths.