2013-06-04 77 views
0

我想編譯一個只有一個文件的小型c + +項目。 BoostRegex.cpp的5個第一行是:使找不到regex.hpp(boost)

#include <iostream> 
#include <string> 
#include <regex.hpp> 

int main() { .... 

我運行下面的./configure線(這是一個交叉編譯):

cmake -DCMAKE_TOOLCHAIN_FILE=/home/vitor/bin/raspi/cmaketoolchain/toolchain.cmake ../src/ 

這條線的工作原理與以下輸出:

[[email protected] bin]$ cmake -DCMAKE_TOOLCHAIN_FILE=/home/vitor/bin/rasp/cmaketoolchain/toolchain.cmake ../src/ 
-- The C compiler identification is GNU 4.7.3 
-- The CXX compiler identification is GNU 4.7.3 
-- Check for working C compiler: /home/vitor/local/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc 
-- Check for working C compiler: /home/vitor/local/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc -- works 
-- Detecting C compiler ABI info 
-- Detecting C compiler ABI info - done 
-- Check for working CXX compiler: /home/vitor/local/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-g++ 
-- Check for working CXX compiler: /home/vitor/local/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-g++ -- works 
-- Detecting CXX compiler ABI info 
-- Detecting CXX compiler ABI info - done 
-- Boost version: 1.49.0 
-- Found the following Boost libraries: 
-- system 
-- regex 
-- unit_test_framework 
status ** Boost Root: /home/vitor/local/usr/lib ** 
status ** Boost Include: /home/vitor/local/usr/include ** 
status ** Boost Libraries Dirs: ** 
status ** Boost Librraries: /home/vitor/local/usr/lib ** 
-- Configuring done 
-- Generating done 
-- Build files have been written to: /home/vitor/tmp/boost-regex/bin 

但是當我運行make命令:

[[email protected] bin]$ make 
Scanning dependencies of target BoostRegex 
[100%] Building CXX object CMakeFiles/BoostRegex.dir/BoostRegex.cpp.o 
In file included from /home/vitor/local/usr/include/features.h:323:0, 
      from /home/vitor/local/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/4.7.3/../../../../arm-unknown-linux-gnueabi/include/c++/4.7.3/arm-unknown-linux-gnueabi/bits/os_defines.h:40, 
      from /home/vitor/local/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/4.7.3/../../../../arm-unknown-linux-gnueabi/include/c++/4.7.3/arm-unknown-linux-gnueabi/bits/c++config.h:414, 
      from /home/vitor/local/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/4.7.3/../../../../arm-unknown-linux-gnueabi/include/c++/4.7.3/iostream:39, 
      from /home/vitor/tmp/boost-regex/src/BoostRegex.cpp:1: 
/home/vitor/local/x-tools/arm-unknown-linux-gnueabi/arm-unknown-linux-gnueabi/sysroot/usr/include/bits/predefs.h:23:3: error: #error "Never use <bits/predefs.h> directly; include <stdc-predef.h> instead." 
/home/vitor/tmp/boost-regex/src/BoostRegex.cpp:3:21: fatal error: regex.hpp: No such file or directory 
compilation terminated. 
make[2]: *** [CMakeFiles/BoostRegex.dir/BoostRegex.cpp.o] Error 1 
make[1]: *** [CMakeFiles/BoostRegex.dir/all] Error 2 
make: *** [all] Error 2 

我必須再次指出boost lib的頭文件嗎?我該怎麼做?

回答

0

這看起來就像在你的CMakeLists.txt

你是否包括正確迪爾斯爲每FindBoost模塊的錯誤?

include_directories(${Boost_INCLUDE_DIRS}) 
+0

嗨!我對CMakeLists.txt做了一些修改,第7,8和18行(註釋)是在你的答案(https://gist.github.com/vitorcarvalhoml/5748911)之前寫的行。以下要點顯示cmake命令的輸出:https://gist.github.com/vitorcarvalhoml/5748943請看第17-19行。 make命令將在我的/ usr/lib中查找boost庫。但我想做一個交叉編譯。謝謝! –

+0

我已經分出了你的要點[這裏](https://gist.github.com/Fraser999/5753224) - 你可以放棄一下嗎? – Fraser

+0

我測試了你的CMakeLists.txt,它可以工作,但是這次我有另一個問題與另一個庫。我改變了做命令的方法。知道之前,這很好。感謝您的回答。 –