簡體   English   中英

在 windows 上使用 cmake 編譯 FFTW (OpenMP)

[英]Compiling FFTW (OpenMP) with cmake on windows

我正在嘗試在我的 windows 機器上安裝帶有 cmake 的 FFTW。 我下載了最新版本的源文件並首先使用以下選項運行 cmake:

mkdir build && cd build
cmake --DBUILD_TESTS=False -DENABLE_FLOAT=On ..
cmake --build . --config Release

這在 Visual Studio 2017 和 2019 上都可以正常工作。但是,當我嘗試使用 OpenMP 編譯代碼時,

cmake --DBUILD_TESTS=False -DENABLE_FLOAT=On -DENABLE_OPENMP=On ..
cmake --build . --config Release

我收到一大堆鏈接錯誤:

[...]
ct.obj : error LNK2001: unresolved external symbol fftwf_ops_zero [C:\Users\jha1\Desktop\fftw-3.3.8.tar\fftw-3.3.8\build\fftw3f_omp.vcxproj]
dft-vrank-geq1.obj : error LNK2001: unresolved external symbol fftwf_ops_zero [C:\Users\jha1\Desktop\fftw-3.3.8.tar\fftw-3.3.8\build\fftw3f_omp.vcxproj]
hc2hc.obj : error LNK2001: unresolved external symbol fftwf_ops_zero [C:\Users\jha1\Desktop\fftw-3.3.8.tar\fftw-3.3.8\build\fftw3f_omp.vcxproj]
[...]

但是,看起來 cmake 在配置階段能夠找到 OpenMP,所以我不確定是什么導致了這個問題。

[...]
-- Found OpenMP_C: -openmp (found version "2.0")
-- Found OpenMP_CXX: -openmp (found version "2.0")
-- Found OpenMP: TRUE (found version "2.0")
[...]

請注意,這在我的帶有 gcc 9 的 linux 機器上工作得很好。

我可以使用 MinGW-W64(來自http://winlibs.com的版本)在 MSYS2 中使用configure構建不同版本的 fftw-3.3.8,如下所示:

INSTALLPREFIX=/usr/local
BUILDPLATFORM=i686-w64-mingw32
RUNPLATFORM=i686-w64-mingw32
BUILDPLATFORM=x86_64-w64-mingw32
RUNPLATFORM=x86_64-w64-mingw32
mkdir -p build_single build_longdouble build_quad build_standard &&
cd build_single &&
#../configure --prefix=$INSTALLPREFIX --build=$BUILDPLATFORM --host=$RUNPLATFORM --enable-shared --enable-static --with-our-malloc16 --enable-threads --with-combined-threads --enable-portable-binary --enable-sse2 LDFLAGS="-Wl,--enable-auto-import" &&
#../configure --prefix=$INSTALLPREFIX --build=$BUILDPLATFORM --host=$RUNPLATFORM --enable-shared --enable-static --disable-alloca --with-our-malloc16 --enable-threads --with-combined-threads --enable-single --enable-sse --enable-sse2 --enable-avx LDFLAGS="-Wl,--enable-auto-import" &&
../configure --cache-file=../config.cache --prefix=$INSTALLPREFIX --build=$BUILDPLATFORM --host=$RUNPLATFORM --enable-shared --enable-static --disable-alloca --with-our-malloc16 --enable-threads --with-combined-threads --enable-single --enable-sse --enable-sse2 --enable-avx LDFLAGS="-Wl,--enable-auto-import" &&
cd .. &&
cd build_longdouble &&
#../configure --prefix=$INSTALLPREFIX --build=$BUILDPLATFORM --host=$RUNPLATFORM --enable-shared --enable-static --disable-alloca --with-our-malloc16 --enable-threads --with-combined-threads --enable-long-double LDFLAGS="-Wl,--enable-auto-import" &&
../configure --cache-file=../config.cache --prefix=$INSTALLPREFIX --build=$BUILDPLATFORM --host=$RUNPLATFORM --enable-shared --enable-static --disable-alloca --with-our-malloc16 --enable-threads --with-combined-threads --enable-long-double LDFLAGS="-Wl,--enable-auto-import" &&
cd .. &&
#cd build_quad &&
##../configure --prefix=$INSTALLPREFIX --build=$BUILDPLATFORM --host=$RUNPLATFORM --enable-shared --enable-static --disable-alloca --with-our-malloc16 --enable-threads --with-combined-threads --enable-quad-precision LDFLAGS="-Wl,--enable-auto-import" &&
#../configure --cache-file=../config.cache --prefix=$INSTALLPREFIX --build=$BUILDPLATFORM --host=$RUNPLATFORM --enable-shared --enable-static --disable-alloca --with-our-malloc16 --enable-threads --with-combined-threads --enable-quad-precision LDFLAGS="-Wl,--enable-auto-import" &&
## fix building DLLs
#mv libtool libtool.bak &&
#sed -e "s/\(allow_undefined=\)yes/\1no/" libtool.bak > libtool &&
#cd .. &&
cd build_standard &&
#../configure --prefix=$INSTALLPREFIX --build=$BUILDPLATFORM --host=$RUNPLATFORM --enable-shared --enable-static --disable-alloca --with-our-malloc16 --enable-threads --with-combined-threads --enable-sse2 --enable-avx LDFLAGS="-Wl,--enable-auto-import" &&
../configure --cache-file=../config.cache --prefix=$INSTALLPREFIX --build=$BUILDPLATFORM --host=$RUNPLATFORM --enable-shared --enable-static --disable-alloca --with-our-malloc16 --enable-threads --with-combined-threads --enable-sse2 --enable-avx LDFLAGS="-Wl,--enable-auto-import" &&
cd .. &&
( make -Cbuild_single || make -Cbuild_single LIBS="-lpthread" ) &&
make -Cbuild_single install-strip &&
( make -Cbuild_longdouble || make -Cbuild_longdouble LIBS="-lpthread" ) &&
make -Cbuild_longdouble install-strip &&
#( make -Cbuild_quad || make -Cbuild_quad LIBS="-lpthread" ) &&
#make -Cbuild_quad install-strip &&
( make -Cbuild_standard || make -Cbuild_standard LIBS="-lpthread" ) &&
make -Cbuild_standard install-strip &&
# fix absolute link in .cmake file(s)
sed -i -e "s?$(echo $INSTALLPREFIX|sed -e "s?^/\([a-zA-Z]\)/?\1:/?")?\${CMAKE_CURRENT_LIST_FILE}/../../../..?g" $INSTALLPREFIX/lib/cmake/fftw3/*Config.cmake &&
echo Done

如果您不想要所有這些版本,您可以堅持與build_standard相關的行。

沒有像這樣構建的 OpenMP 問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM