views:

25

answers:

1

I'm trying to use the Boost Libraries ... but to no avail. I attempted to follow the Getting Started tutorial on Boost's website (for Unix Variants), but having problems along the way.

I compiled the libraries into a directory in my Downloads folder:

/Users/myUsername/Downloads/boostCompiled

When I use the full path to the library ... The example program (given on the Boost Website) compiles and links fine.

g++ -o boostTesting boostTesting.cpp -I /Users/myUsername/Downloads/boostCompiled/include/ /Users/myUsername/Downloads/boostCompiled/lib/libboost_regex.a

However, when I attempt to link the using the -L and -l options ... it fails ...

g++ -o boostTesting boostTesting.cpp -I /Users/myUsername/Downloads/boostCompiled/include/ -L /Users/myUsername/Downloads/boostCompiled/lib/ -l boost_regex

ld: library not found for -lboost_regex
collect2: ld returned 1 exit status

g++ -o boostTesting boostTesting.cpp -I /Users/myUsername/Downloads/boostCompiled/include/ -L /Users/myUsername/Downloads/boostCompiled/lib/ -l libboost_regex

ld: library not found for -llibboost_regex
collect2: ld returned 1 exit status

g++ -o boostTesting boostTesting.cpp -I /Users/myUsername/Downloads/boostCompiled/include/ -L /Users/myUsername/Downloads/boostCompiled/lib/ -l regex

ld: library not found for -lregex
collect2: ld returned 1 exit status

My shell is bash ... and I've set my DYLD_LIBRARY_PATH to the following:

export DYLD_LIBRARY_PATH=/usr/local/cuda/lib:/Users/myUsername/Downloads/boostCompiled/lib

It appears I'm not using the correct name to link (with the -l) option. Can somebody please help! Thanks in advance!

A: 
  • There shouldn't be a space between -L and /Users/myUsername/Downloads/boostCompiled/lib/

  • Make sure that libboost_regex.a is compiled in /Users/myUsername/Downloads/boostCompiled/lib.

Then this should work:

g++ -o boostTesting boostTesting.cpp -I/Users/myUsername/Downloads/boostCompiled/include/ -L/Users/myUsername/Downloads/boostCompiled/lib/ -lboost_regex
Bertrand Marron
Yes! Thank you very much! That solved it. For some reason, the space between -L and the /Users/myUsername/Downloads/boostCompiled/lib/ was causing the issue. Additionally, I removed the space betweek -l and boost_regex. It works!