Mik*_*ike 6 linux boost mingw boost-thread boost-asio
通常情况下,我可以通过google方式找到解决方案,但这次不是.
我正在使用64位Linux Ubuntu 11.04来编译32位Windows应用程序.我正在使用i586-mingw32msvc-gcc来编译我的C++文件.
TEST.CPP:
#include <boost/asio.hpp>
Run Code Online (Sandbox Code Playgroud)
生成文件:
i586-mingw32msvc-gcc -c -m32 -mthreads -o test.o test.cpp
Run Code Online (Sandbox Code Playgroud)
错误:
boost/asio/detail/socket_types.hpp:
# include <sys/ioctl.h>
doesn't exist.
Run Code Online (Sandbox Code Playgroud)
添加到makefile:-DBOOST_WINDOWS
Error:
# warning Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately
Run Code Online (Sandbox Code Playgroud)
好的,添加到makefile:-D_WIN32_WINNT = 0x0501
Error:
# error "Compiler threading support is not turned on. Please set the correct command line options for threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)"
Run Code Online (Sandbox Code Playgroud)
但我确实指定了-mthreads.
事实证明,我有一组 #undef 和 #defines 来强制 GLIBC 版本允许我为 Linux(而不是交叉编译)RHEL5 进行编译,否则会给我带来各种其他错误。事实证明,当使用 mingw 对 Windows 进行交叉编译时,强制输入 GLIBC 版本会导致 boost 采取奇怪的路径,从而导致各个方面未定义,包括线程的行为或可用性。我用 #ifndef _WIN32 包围它,这使得问题消失了。