mingw - 使用 gcc 标志 -m32 构建后出现错误 0xc000007b
问题描述
我已经安装了 mingw-w64,因为我需要 C++11/C11 多线程功能来执行犰狳库(http://arma.sourceforge.net/),但我也需要使用 32 位 dll 编译程序。当我使用标志 -m32 编译这个 32 位程序时,运行它时没有问题,但是当我使用带有此标志的犰狳库运行程序时,会出现错误 0xc000007b。为了使用犰狳库构建程序,我需要为 32 位架构链接英特尔数学内核库( https://software.intel.com/en-us/mkl )。
我已经尝试过使用依赖walker,但结果并没有澄清任何事情。
这是我使用的命令行:
g++ --std=c++11 -o PruebaArmadillo PruebaArmadillo.cpp -IC:\armadillo-9.800.4\include -LC:\mkl_32\redist\ia32_win\mkl -lmkl_rt -m32
我使用 g++(x86_64-posix-sjlj-rev0,由 MinGW-W64 项目构建)8.1.0 在 Windows 10 上工作
代码
#include <iostream>
#include <armadillo>
#include <vector>
using namespace std;
using namespace arma;
int main()
{
vec p = { 1, 1, 3 };
cout << p << endl;
}
结果
编辑
为了澄清某些方面,我在这里展示了使用 mingw 和 mingw-w64 编译的相同代码的结果。
使用 mingw:
C:\MicoCode\prueba1>g++ --version
g++ (MinGW.org GCC-8.2.0-5) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
C:\MicoCode\prueba1>g++ --std=c++11 -o PruebaArmadillo PruebaArmadillo.cpp -IC:\armadillo-9.800.4\include -LC:\mkl_32\redist\ia32_win\mkl -lmkl_rt
In file included from C:\armadillo-9.800.4\include/armadillo:171,
from PruebaArmadillo.cpp:4:
C:\armadillo-9.800.4\include/armadillo_bits/SpMat_bones.hpp:675:29: error: 'mutex' in namespace 'std' does not name a type
arma_aligned mutable std::mutex cache_mutex;
这会导致互斥错误,这就是我需要使用 mingw-w64 的原因,但这给了我一开始指出的错误。但是,如果我将 mkl 库用于 64 位,它就可以正常工作:
C:\MicoCode\prueba1>g++ --version
g++ (x86_64-posix-sjlj-rev0, Built by MinGW-W64 project) 8.1.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
C:\MicoCode\prueba1>g++ --std=c++11 -o PruebaArmadillo PruebaArmadillo.cpp -IC:\armadillo-9.800.4\include -LC:\mkl_2\redist\intel64_win\mkl -lmkl_rt
C:\MicoCode\prueba1>PruebaArmadillo.exe
1.0000
1.0000
3.0000
解决方案
最后,我找到了解决方案,出现错误是因为系统找不到 32 位库,因为程序是在 64 位架构上编译的。为了解决这个问题,将这些库包含为路径环境变量就足够了。它位于以下位置的 32 位库:
C:\---\mingw64\x86_64-w64-mingw32\lib32
推荐阅读
- go - Golang:如何使用base64字符串作为附件内容发送带有图像的html正文电子邮件
- shell - 如何找到我的 AWS Lambda 的 UUID 和批量大小
- html - Thymeleaf 路径变量不起作用。我究竟做错了什么?
- asp.net-core - Asp.net MVC Core 提供空复选框数据,而不是 HTTPPost 上的所有选定复选框
- android - Android Kotlin 单元测试因 io.mockk.MockKException 失败:找不到答案
- prolog - 在查询中使用冗余目标
- cmake - 从通过 target_link_libraries 指定的依赖项生成 find_dependency
- github - 尽管在代理中添加了身份,但无法使用 SourceTree 推送到 github:权限被拒绝(公钥)
- angular - 我如何延迟加载组件 html 直到获得所有图像?
- vue.js - Vue axios 发布请求被 CORS 策略阻止