使用 gcc 标志 -m32 构建后出现错误 0xc000007b
Error 0xc000007b after building with gcc flag -m32
我已经安装了 mingw-w64,因为我需要 C++11/C11 多线程功能来执行 armadillo 库 (http://arma.sourceforge.net/) but I need to compile program with 32bit dll too. When I compile this 32bit program with the flag -m32 there are no problem when I run it but when I run a program with armadillo library with this flag the error 0xc000007b appears. For builds a program with armadillo library I need to link Intel Math Kernel Library (https://software.intel.com/en-us/mkl) 用于 32 位架构。
我已经尝试使用 dependency 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++ 开发 windows 10(x86_64-posix-sjlj-rev0,由 MinGW-W64 项目构建)8.1.0
代码
#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 的原因,但这给了我一开始指出的错误。但是如果我使用 64 位的 mkl 库,它工作正常:
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
终于找到解决办法了,出现这个错误是因为程序是在64位架构上编译的,系统找不到32位的库。要解决它,将这些库作为路径环境变量包含在内就足够了。它所在的 32 位库:
C:\---\mingw64\x86_64-w64-mingw32\lib32
我已经安装了 mingw-w64,因为我需要 C++11/C11 多线程功能来执行 armadillo 库 (http://arma.sourceforge.net/) but I need to compile program with 32bit dll too. When I compile this 32bit program with the flag -m32 there are no problem when I run it but when I run a program with armadillo library with this flag the error 0xc000007b appears. For builds a program with armadillo library I need to link Intel Math Kernel Library (https://software.intel.com/en-us/mkl) 用于 32 位架构。
我已经尝试使用 dependency 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++ 开发 windows 10(x86_64-posix-sjlj-rev0,由 MinGW-W64 项目构建)8.1.0
代码
#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 的原因,但这给了我一开始指出的错误。但是如果我使用 64 位的 mkl 库,它工作正常:
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
终于找到解决办法了,出现这个错误是因为程序是在64位架构上编译的,系统找不到32位的库。要解决它,将这些库作为路径环境变量包含在内就足够了。它所在的 32 位库:
C:\---\mingw64\x86_64-w64-mingw32\lib32