制造can';找不到regex.hpp(boost) 我试图用一个文件编译一个小型C++项目。BoostRegex.cpp的前5行是: #include <iostream> #include <string> #include <regex.hpp> int main() { ....

制造can';找不到regex.hpp(boost) 我试图用一个文件编译一个小型C++项目。BoostRegex.cpp的前5行是: #include <iostream> #include <string> #include <regex.hpp> int main() { ....,boost,makefile,cmake,boost-regex,cross-compiling,Boost,Makefile,Cmake,Boost Regex,Cross Compiling,该行使用以下输出: [vitor@archlinux 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: /

该行使用以下输出:

[vitor@archlinux 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命令时:

[vitor@archlinux 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
[vitor@archlinuxbin]$make
目标BoostRegex的扫描相关性
[100%]构建CXX对象CMakeFiles/BoostRegex.dir/BoostRegex.cpp.o
在/home/vitor/local/usr/include/features.h:323:0中包含的文件中,
来自/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,
来自/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,
来自/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“永远不要直接使用;改为包含。”
/home/vitor/tmp/boost regex/src/BoostRegex.cpp:3:21:致命错误:regex.hpp:没有这样的文件或目录
编译终止。
生成[2]:***[CMakeFiles/BoostRegex.dir/BoostRegex.cpp.o]错误1
生成[1]:***[CMakeFiles/BoostRegex.dir/all]错误2
make:**[全部]错误2

我必须再次指出boost lib的标题?我该怎么做?

这看起来像是您的CMakeLists.txt中的错误

您是否按照模块要求提供了正确的目录


你好我在CMakeLists.txt上做了一些更改,第7行、第8行和第18行、第19行(注释)是在您的答案()之前写的。下面的要点显示了cmake命令的输出:查看第17-19行。make命令将在my/usr/lib中查找boost lib。但我想做一个交叉编译。谢谢我已经说出了你的要点-你能试一试吗?我测试了你的CMakeLists.txt,它可以工作,但这次我在另一个libs上遇到了另一个问题。我改变了指挥的方式。在你知道之前一切都很好。谢谢你的回答。
[vitor@archlinux 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
include_directories(${Boost_INCLUDE_DIRS})