首先直接使用命令
sudo apt-get install mingw32
有可能会报错找不到mingw32
此时需要更新源,命令如下
sudo gedit /etc/apt/sources.list
//在sources.list末尾添加,保存
deb http://us.archive.ubuntu.com/ubuntu trusty main universe
sudo apt-get update
sudo apt-get install mingw32
安装完成后会多出一个路径
/usr/i586-mingw32msvc/
此时已经可以进行正常的交叉编译,但是在使用过程中竟然发现没有自带pthread库,那就只能自己配置一下了。
从下面的地址下载静态链接库:libpthreadGC2.a
ftp://sourceware.org/pub/pthreads-win32/dll-latest/lib/x86
从下面的地址下载头文件:pthread.h sched.h semaphore.h
ftp://sourceware.org/pub/pthreads-win32/dll-latest/include
如果没法直接打开网址的话可以使用工具filezilla
下载完成后
将头文件放置到/usr/i586-mingw32msvc/include路径下
将库文件放置到/usr/i586-mingw32msvc/lib路径下