在 linux 上使用 mingw 与 clang 交叉编译

Nic*_*_93 5 linux windows mingw clang cross-compiling

我试图在 linux 下为 windows 编译。我已经为 linux 和 w64-mingw 安装了 binutils multilib。如果我使用 x86_64-w64-mingw-gcc 编译一切正常,但是如果我使用带有 -target x86_64-w64-mingw 或 x86_64-windows-gnu 编译器的 clang 会给我很多警告和 windows.h 的包含错误。

问题是什么?Clang 不支持 mingw binutils?

PS我也对freebsd的交叉编译感兴趣,我在哪里可以找到针对freebsd的binutils?

非常感谢您提前:)

Tho*_*mas 6

-target 还不够,您还需要指定包含目录,即:

clang -target i686-w64-mingw32 -nostdinc -fno-exceptions -isystem /opt/compiler/llvm-3.6/bin/../lib/clang/3.6.0/include -isystem /opt/compiler/mingw-w64/i686-w64-mingw32/include -isystem /opt/compiler/mingw-w64/i686-w64-mingw32/include/c++/4.9.2 -isystem /opt/compiler/mingw-w64/i686-w64-mingw32/include/c++/4.9.2/backward -isystem /opt/compiler/mingw-w64/i686-w64-mingw32/include/c++/4.9.2/i686-w64-mingw32
Run Code Online (Sandbox Code Playgroud)

您可能会发现我的项目很有用:https : //github.com/tpoechtrager/wclang - 该工具正在为您执行所有讨厌的包含目录搜索。