我安装了mingw-w64是因为我需要C ++ 11 / C11多线程功能来执行犰狳库(http://arma.sourceforge.net/),但我也需要使用32位dll编译程序。当我使用标志-m32编译此32位程序时,运行该程序没有问题,但是当我使用该标志运行带有armadillo库的程序时,出现错误0xc000007b。对于使用armadillo库构建程序,我需要链接Intel Math Kernel library(https://software.intel.com/en-us/mkl)以获得32位arquitecture。
我已经尝试使用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,但是这却给了我开始时指出的错误。但是,如果我将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