C++ 在windows上使用cmake编译FFTW(OpenMP)

C++ 在windows上使用cmake编译FFTW(OpenMP),c++,visual-studio,cmake,openmp,fftw,C++,Visual Studio,Cmake,Openmp,Fftw,我正在尝试在我的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=Fals

我正在尝试在我的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机器上运行得很好。

我能够在MSYS2中使用MinGW-W64(版本自)在不同版本中构建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\u standard
相关的行


没有像这样构建OpenMP的问题。

问题可能是Microsoft编译器只支持OpenMP 2.0(现在已经17年了…),但我不清楚为什么这会导致在链接时丢失函数。您可以安装支持更现代OpenMP(GCC、LLVM等)的编译器