简体   繁体   English

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

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

I am trying to install FFTW with cmake on my windows machine.我正在尝试在我的 windows 机器上安装带有 cmake 的 FFTW。 I downloaded the latest version of the source files and ran cmake with these options first:我下载了最新版本的源文件并首先使用以下选项运行 cmake:

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

That works just fine on both Visual Studio 2017 and 2019. However, when I tried to compile the code with OpenMP,这在 Visual Studio 2017 和 2019 上都可以正常工作。但是,当我尝试使用 OpenMP 编译代码时,

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

I get a whole bunch of linking errors:我收到一大堆链接错误:

[...]
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]
[...]

However, it looks like cmake was able to find OpenMP during the configuration phase, so I am not sure what is causing this issue.但是,看起来 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")
[...]

Note that this worked just fine on my linux machine with gcc 9.请注意,这在我的带有 gcc 9 的 linux 机器上工作得很好。

I'm able to build fftw-3.3.8 in different versions using configure in MSYS2 using MinGW-W64 (version from http://winlibs.com ) like this:我可以使用 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

If you don't want all these versions you can just stick to the lines relating to build_standard .如果您不想要所有这些版本,您可以坚持与build_standard相关的行。

There were no OpenMP issues building like this.没有像这样构建的 OpenMP 问题。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM