使用MinGW(Windows,GCC)如何编译由CMake生成的64位二进制文件?

huangapple go评论78阅读模式
英文:

How do I compile cmake generated binaries in 64bits using MinGW (Windows, GCC)?

问题

我一直在尝试使用cmake和MinGW编译模型加载库Assimp,但是我不知道如何为我正在使用的64位项目进行编译。我使用了命令"mingw32-make",但如果我理解正确,这是用于32位的,当我尝试使用得到的DLL运行我的项目时,它会无提示退出。我听说当你尝试将32位文件与64位项目链接时,可能会发生这种情况。我听说过"make.exe",但我不知道它是否是我需要的,而且无论如何我在我的MinGW文件夹中找不到它。我宁愿不使用Visual Studio,我使用VSCode。

英文:

I've been trying to compile the model loading library Assimp for my project using cmake and then MinGW. However, I don't know how to do that for 64bits which is what I'm using on my project. I used the command "mingw32-make" but if I understand correctly that is for 32bits and when I try to run my project with the obtained DLL it exits without explanation. I've heard this can happen when you try to link 32bit files with a 64bit projects. I heard about "make.exe" but I don't know if it's what I need and either way I can't find it in my MinGW folder. I'd rather not resort to Visual Studio, I use VSCode.

答案1

得分: 0

解决方案很简单:只需获取最新版本,为win64生成make文件,并自行构建:

cd <assimp-source>
cmake CMakeLists.txt -G 'MinGW Makefiles'
cmake --build .

如果你不知道你的mingw-toolchain cmake生成器的名称,你可以查看cmake的帮助文档:

cmake --help

只需查找MinGW相关内容,并将列出的名称添加到cmake -G选项中。

希望这能帮助你解决问题。

英文:

The solution is simple: just get the latest release, generate the make files for win64 and build it by yourself:

cd &lt;assimp-source&gt;
cmake CMakeLists.txt -G &#39;MinGW Makefiles&#39;
cmake --build .

If you don't know how your mingw-toolchain cmake generator is called you can check the cmake help for that:

cmake --help

Just check for the MinGW stuff and add the listed name for the cmake -G option.

Hope that helps you a little bit to get around your issues.

huangapple
  • 本文由 发表于 2023年8月9日 04:36:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76863055.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定