[英]OMP Cross compilation with x86_64-w64-mingw32-g++
使用openMP庫的交叉編譯C ++程序遇到一些麻煩。 我正在使用Linux Ubuntu 12.04 LTS。 我想獲取Windows上可運行的可執行文件。
使用常規g ++命令使用OMP編譯程序時,我沒有任何問題:
g++ a.cpp b.cpp -o OMPres -pg -O3 -I./CBLAS/include -L./ -lcblas
另外,當我嘗試不使用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
但是,當我嘗試使用以下命令與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
我收到此錯誤: a.cpp:41:17:致命錯誤:omp.h:沒有此類文件或目錄編譯終止。
我找到了磁盤上的omp.h文件所在的位置,並在命令中添加了路徑。 執行后:
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
我收到另一個錯誤: x86_64-w64-mingw32-g ++:錯誤:libgomp.spec:沒有這樣的文件或目錄
由於我還在磁盤上存儲了該文件,因此我嘗試在各個位置復制該文件,最后將其直接復制到進行編譯的目錄中時,該文件終於起作用了。 然后產生了另一個錯誤:
/ usr / bin / x86_64-w64-mingw32-ld:找不到-lgomp / usr / bin / x86_64-w64-mingw32-ld:找不到-lrt collect2:ld返回1退出狀態
我對編譯器的工作方式不太了解。 我試圖更新所有可以通過apt-cache搜索找到的mingw-w64編譯器,但沒有任何幫助。 我不知道我還能做什么:(。
您的x86_64-w64-mingw32
工具鏈似乎是在沒有libgomp
情況下libgomp
。
libgomp
其他軟件包或變體軟件包。 --enable-libgomp
重建(或首先構建)交叉gcc
。 這有點困難 。 PS:添加與您的平台不匹配的路徑,例如-I/usr/lib/gcc/x86_64-linux-gnu/4.6/include
,通常是一個壞主意,並且肯定會失敗...這種情況會創建弗蘭肯編譯器。
首先,@ nmaier是完全正確的,因為Ubuntu x86_64-w64-mingw32工具鏈已損壞,您可以自己重建該工具鏈。
但是,我建議您使用MXE ,它可以節省您手動編譯gcc及其所有依賴項的時間。 以下步驟足以滿足您的目的:
# 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.