【发布时间】:2017-10-29 10:21:44
【问题描述】:
我想在 arm 平台上交叉编译 tiny-dnn(一个 c++14 项目,https://github.com/tiny-dnn/tiny-dnn)。 所以我安装了g++-arm-Linux-gnueabi和gcc-arm-Linux-gnueabi,版本是GCC5.4。 然后我修改了 CMakeList 以添加一些标志。
option(ARM "Crosscompile with arm" ON)
if(ARM)
SET(CMAKE_SYSTEM_NAME Linux)
SET(CMAKE_C_COMPILER arm-linux-gnueabi-gcc)
SET(CMAKE_CXX_COMPILER arm-linux-gnueabi-g++)
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
endif()
然后我添加了一些标志:
-march=armv7-a -mtune=cortex-a9 -mfpu=neon
最后,所有的标志(一些标志显示两次)是:
-O3 -DNDEBUG -O3 -march=armv7-a -mtune=cortex-a9 -mfpu=neon -static-libstdc++ -static-libgcc -static -pthread -Wall -Wpedantic -Wno-narrowing -Wno-deprecated -Wall -Wpedanitc -Wno-narrowing -Wno-deprecated
最后我得到了这些错误:
[ 6%] 构建 CXX 对象 示例/CMakeFiles/example_mnist_train.dir/mnist/train.cpp.o [ 12%] 链接 CXX 可执行文件 example_mnist_train CMakeFiles/example_mnist_train.dir/mnist/train.cpp.o:在函数中 std::__future_base::_State_baseV2::_M_set_result(std::function ()>, bool) [克隆 .constprop.5599]': train.cpp:(.text+0x584): 未定义参考 tostd::__atomic_futex_unsigned_base::_M_futex_notify_all(unsigned int*)' CMakeFiles/example_mnist_train.dir/mnist/train.cpp.o:在 功能 std::__future_base::_State_baseV2::_M_set_result(std::function ()>, bool) [克隆 .constprop.5600]': train.cpp:(.text+0x67c): 未定义参考 tostd::__atomic_futex_unsigned_base::_M_futex_notify_all(unsigned int*)' CMakeFiles/example_mnist_train.dir/mnist/train.cpp.o:在 函数`std::__future_base::_Result::~_Result()':
...等
它似乎不能引用标准库。我错过了什么吗?
顺便说一句,我可以在 Nvidia TX1 和 Raspbian Pi 上编译该项目,所以该项目应该与 ARM 兼容。
【问题讨论】:
-
当你输入
/path/to/your/gcc/lib/libstdc++.a | grep _M_futex_notify_all时你看到了什么? -
我输入了
sudo cat ./libstdc++.a | grep _M_futex_notify_all,没有找到匹配项。在普通 gcc 上尝试了代码,得到了二进制匹配。所以我应该尝试其他一些跨工具链还是自己编译一个。 -
抱歉打错了,我的错。你需要
nm -C /path/to/your/gcc/lib/libstdc++.a | grep _M_futex_notify_all(以及为什么需要sudo?!) -
尝试了新代码,没有返回任何内容。在普通的 GCC 上尝试了代码,返回:
00000000000000 T std::__atomic_futex_unsigned_base::_M_futex_notify_all(unsigned int*) U std::__atomic_futex_unsigned_base::_M_futex_notify_all(unsigned int*) -
你能在 arm 库中找到任何其他函数吗,例如
nm ... | grep basic_string?
标签: c++ linux arm c++14 cross-compiling