2010-09-29 81 views
1

我试图使用Boost库...但无济于事。我试图按照Boost网站上的入门教程(对于Unix变体),但是一直存在问题。Boost库:无法链接MAC OS X上的正则表达式库

我编译库到一个目录在我的下载文件夹,:

/Users/myUsername/Downloads/boostCompiled 

当我使用的完整路径库...示例程序(在升压网站给出)编译和链接的罚款。

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

然而,当我尝试使用-L和-l选项链接...失败...

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 

我的shell是bash ......我已经设置我DYLD_LIBRARY_PATH以下几点:

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

看来我没有使用正确的名称链接(与-l)选项。有人可以帮助!提前致谢!

回答

1
  • 不应该有一个空间,确保libboost_regex.a/Users/myUsername/Downloads/boostCompiled/lib编译-L/Users/myUsername/Downloads/boostCompiled/lib/

  • 之间

那么这应该工作:

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

是的!非常感谢你!这解决了它。由于某种原因,-L和/ Users/myUsername/Downloads/boostCompiled/lib /之间的空间导致了问题。此外,我删除了-l和boost_regex之间的空间。有用! – user462020 2010-09-29 22:52:07