c++ - 使用 OpenWRT 工具链为 OpenWRT Linux 环境交叉编译 POCO 库

标签 c++ linux ubuntu poco openwrt

我正在尝试使用 OpenWRT 工具链为 OpenWRT Linux 环境交叉编译 POCO 源包。我已经下载了 POCO 源码包并尝试交叉编译它,但是我得到如下错误日志

src/Error.cpp: In static member function 'static std::string
Poco::Error::getMessage(int)': src/Error.cpp:71:55: error: invalid
conversion from 'int' to 'const char*' [-fpermissive]
return std::string(strerror_r(errorCode, errmsg, 256));
                                                       ^
In file included from
/home/ubuntu/subhendu/options_cg/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_musl-1.1.10/mips-openwrt-linux-musl/include/c++/4.8.3/string:53:0,
                 from include/Poco/Bugcheck.h:24,
                 from include/Poco/Foundation.h:148,
                 from src/Error.cpp:17: /home/ubuntu/subhendu/options_cg/trunk/staging_dir/toolchain-mips_34kc_gcc-4.8-linaro_musl-1.1.10/mips-openwrt-linux-musl/include/c++/4.8.3/bits/basic_string.tcc:212:5:
error:   initializing argument 1 of 'std::basic_string<_CharT,
_Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]' [-fpermissive]
     basic_string<_CharT, _Traits, _Alloc>::
     ^
/home/ubuntu/subhendu/Poco/poco-1.6.0/build/rules/compile:53: recipe for target
'/home/ubuntu/subhendu/Poco/poco-1.6.0/Foundation/obj/Linux/x86_64/debug_shared/Error.o'
failed make[1]: ***
[/home/ubuntu/subhendu/Poco/poco-1.6.0/Foundation/obj/Linux/x86_64/debug_shared/Error.o]
Error 1 make[1]: Leaving directory
'/home/ubuntu/subhendu/Poco/poco-1.6.0/Foundation' Makefile:69: recipe
for target 'Foundation-libexec' failed make: *** [Foundation-libexec]
Error 2

如果有人遇到同样的问题或对如何解决它有任何想法,请提供您的解决方案...

最佳答案

查看the man page for strerror_r ,我明白了:

int strerror_r(int errnum, char *buf, size_t buflen);
            /* XSI-compliant */
char *strerror_r(int errnum, char *buf, size_t buflen);
            /* GNU-specific */

注意返回类型的不同。

查看您的错误消息:

error: invalid conversion from 'int' to 'const char*' [-fpermissive]
return std::string(strerror_r(errorCode, errmsg, 256));
                                                       ^

看来您正在编译的源代码期望 strerror_r 的 GNU 特定版本,但得到 XSI 兼容版本.您的目标没有提供 GNU 扩展,或者您的工具链设置不正确。

手册页继续:

Feature Test Macro Requirements for glibc (see feature_test_macros(7)): The XSI-compliant version of strerror_r() is provided if:

(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600) && ! _GNU_SOURCE

Otherwise, the GNU-specific version is provided.

所以您可能想朝那个方向进行调查。 (当您尝试编译时,_POSIX_C_SOURCE_XOPEN_SOURCE_GNU_SOURCE 是什么?)

关于c++ - 使用 OpenWRT 工具链为 OpenWRT Linux 环境交叉编译 POCO 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31578214/

相关文章:

c++ - C++11 中由 std::tuple_size 终止的递归可变参数模板

linux - 使用节点脚本代替 bash

c++ - Gnuplot 和 std::filesystem::remove

C++ boost线程在实例化两次时导致段错误

c++ - 是否可以从大括号类型的初始化中推断出元组的模板参数?

c - 当想要将某些内容写入文件时,在操作系统级别会发生什么?

linux - Perf 启动开销 : Why does a simple static executable which performs MOV + SYS_exit have so many stalled cycles (and instructions)?

python - 我怎样才能杀死一个 cron 程序?

php - 让 Nginx 将所有错误发送到一个页面并发布错误 ID?

C++。将 csv 文件加载到 2D vector