简体   繁体   English

使用x86_64-w64-mingw32-g ++进行OMP交叉编译

[英]OMP Cross compilation with x86_64-w64-mingw32-g++

I have some trouble with crosscompiling C++ program which takes advantage of openMP library. 使用openMP库的交叉编译C ++程序遇到一些麻烦。 I am using Linux Ubuntu 12.04 LTS. 我正在使用Linux Ubuntu 12.04 LTS。 I want to obtain executable file runnable on Windows. 我想获取Windows上可运行的可执行文件。

I have no problem with compiling my program with OMP with regular g++ command: 使用常规g ++命令使用OMP编译程序时,我没有任何问题:

  g++ a.cpp b.cpp -o OMPres -pg -O3 -I./CBLAS/include -L./ -lcblas

Also when I try crosscompilation without OMP, everything runs perfectly fine: 另外,当我尝试不使用OMP进行交叉编译时,一切运行正常:

 x86_64-w64-mingw32-g++ a.cpp b.cpp -O3 -I./CBLAS/include ./CBLAS/cblas_WIN64.a ./BLAS/blas_WIN64.a -o res.exe -l gfortran -static

But when I try to crosscompile it with OMP using following command: 但是,当我尝试使用以下命令与OMP交叉编译时:

x86_64-w64-mingw32-g++ a.cpp b.cpp -O3 -I./CBLAS/include ./CBLAS/cblas_WIN64.a ./BLAS/blas_WIN64.a -o OMPres.exe -l gfortran -static -fopenmp

I get this error: a.cpp:41:17: fatal error: omp.h: No such file or directory compilation terminated. 我收到此错误: a.cpp:41:17:致命错误:omp.h:没有此类文件或目录编译终止。

I found where omp.h file is located on my disk, and added the path to the command. 我找到了磁盘上的omp.h文件所在的位置,并在命令中添加了路径。 After executing it: 执行后:

x86_64-w64-mingw32-g++ a.cpp b.cpp -O3 -I./CBLAS/include -I/usr/lib/gcc/x86_64-linux-gnu/4.6/include ./CBLAS/cblas_WIN64.a ./BLAS/blas_WIN64.a -o OMPres.exe -l gfortran -static -fopenmp

I got another error: x86_64-w64-mingw32-g++: error: libgomp.spec: No such file or directory 我收到另一个错误: x86_64-w64-mingw32-g ++:错误:libgomp.spec:没有这样的文件或目录

As I also have this file on the disk I tried to copy it in various places and finaly it worked when I copied it directly into the directory where compilation takes place. 由于我还在磁盘上存储了该文件,因此我尝试在各个位置复制该文件,最后将其直接复制到进行编译的目录中时,该文件终于起作用了。 Then it produced another error: 然后产生了另一个错误:

/usr/bin/x86_64-w64-mingw32-ld: cannot find -lgomp /usr/bin/x86_64-w64-mingw32-ld: cannot find -lrt collect2: ld returned 1 exit status / usr / bin / x86_64-w64-mingw32-ld:找不到-lgomp / usr / bin / x86_64-w64-mingw32-ld:找不到-lrt collect2:ld返回1退出状态

I don't have a good understanding of how compilers exactly work. 我对编译器的工作方式不太了解。 I tried to update all mingw-w64 compilers that I could find with apt-cache search but nothing helped. 我试图更新所有可以通过apt-cache搜索找到的mingw-w64编译器,但没有任何帮助。 I have no idea what more I can do :(. 我不知道我还能做什么:(。

Your x86_64-w64-mingw32 toolchain appears to have been build without libgomp . 您的x86_64-w64-mingw32工具链似乎是在没有libgomp情况下libgomp

  • You could check your supplier/distribution if it there additional or variant packages that have libgomp . 您可以检查供应商/分销商是否包含libgomp其他软件包或变体软件包。
  • Or switch to a different supplier/distribution. 或切换到其他供应商/分销商。
  • Or you could rebuild (or build in the first place) a cross gcc with --enable-libgomp . 或者,您可以使用--enable-libgomp重建(或首先构建)交叉gcc This is kinda the hard way . 这有点困难

PS: Adding paths that do not correspond with your platform, like -I/usr/lib/gcc/x86_64-linux-gnu/4.6/include , is a bad idea in general, and will most certainly fail... This kinda creates a Franken-compiler. PS:添加与您的平台不匹配的路径,例如-I/usr/lib/gcc/x86_64-linux-gnu/4.6/include ,通常是一个坏主意,并且肯定会失败...这种情况会创建弗兰肯编译器。

First, @nmaier is completely correct in that the Ubuntu x86_64-w64-mingw32 toolchain is crippled, and that you can rebuild the toolchain yourself. 首先,@ nmaier是完全正确的,因为Ubuntu x86_64-w64-mingw32工具链已损坏,您可以自己重建该工具链。

I, however, suggest that you use MXE , which saves you the time of manually compiling gcc and every dependency of it. 但是,我建议您使用MXE ,它可以节省您手动编译gcc及其所有依赖项的时间。 The steps below should be enough for your purpose: 以下步骤足以满足您的目的:

# Get MXE
git clone https://github.com/mxe/mxe.git && cd mxe

# Settings
cat <<EOF > settings.mk
MXE_TARGETS := x86_64-w64-mingw32.static
JOBS := 4
EOF

# Build gcc, libgomp, blas, and cblas. It will take a while
make -j2 libgomp cblas

# Add toolchain to PATH
# See http://htmlpreview.github.io/?https://github.com/mxe/mxe/blob/master/index.html#tutorial step 4
export PATH=`pwd`/usr/bin:$PATH

# You don't need -I./CBLAS/include ./CBLAS/cblas_WIN64.a ./BLAS/blas_WIN64.a
# because headers and libraries are installed to standard location and
# I already used `-lcblas -lblas`.
x86_64-w64-mingw32-g++ a.cpp b.cpp -fopenmp -O3 -o res.exe -lcblas -lblas -lgfortran -lquadmath

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 x86_64-w64-mingw32-g ++编译失败,g ++正常工作 - x86_64-w64-mingw32-g++ fails to compile, g++ works fine 带有 x86-64-w64-mingw32-g++ 未定义引用的 libcurl。 g++ 工作正常 - libcurl with x86-64-w64-mingw32-g++ undefined reference. g++ works fine CMake 和 vcpkg x86_64-w64-mingw32/bin/ld:交叉编译时找不到 -lOpenGL32 - CMake and vcpkg x86_64-w64-mingw32/bin/ld: cannot find -lOpenGL32 when cross compiling 严重错误:sys / socket.h:没有此类文件或目录,x86_64-w64-mingw32模式 - fatal error: sys/socket.h: No such file or directory, x86_64-w64-mingw32 mode 无法在 linux (i686-w64-mingw32-g++) 上交叉编译包含 sqlite 的 C++ 类(未定义的引用) - Can't cross compile c++ class with sqlite included (undefined reference) on linux (i686-w64-mingw32-g++) Eclipse 错误:在 PATH 中找不到“x86_64-w64-mingw32-gcc”。 如何消除这个错误? 我不需要这个供应商 - Eclipse error: "x86_64-w64-mingw32-gcc" not found in PATH. How to remove this error? i dont need this provider Haskell 32到64位交叉编译 - Haskell 32 to 64 bit cross compilation 在Linux上与mingw-w64交叉编译时的声明冲突 - Conflicting declaration when cross compiling with mingw-w64 on Linux 交叉编译gstreamer失败:x86-64 - &gt; ARMv6 32位 - cross compiling gstreamer fails: x86-64 -> ARMv6 32-bit 如何使用linux amd64,cmake和g ++交叉编译linux x86? - How to cross compile for linux x86 with linux amd64, cmake and g++?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM