【发布时间】:2019-06-25 00:26:13
【问题描述】:
我尝试构建 clFFT 库(用于使用 OpenCL 进行 FFT)并将示例包含在 clFFT git 中。
- 首先,进入
/opt/,我做到了:
git clone https://github.com/clMathLibraries/clFFT.git
-
之后,总是进入
/opt/目录,我做了:$ mkdir build && cd build/ -
从这里,我这样称呼
cmake:
cmake -DOpenCL_INCLUDE_DIR=/opt/AMDAPPSDK-3.0/include -DOpenCL_LIBRARY=/opt/AMDAPPSDK-3.0/lib/x86_64 ../clFFT/src/
确实,在/opt/ 目录中,我已经从AMD-APP-SDKInstaller-v3.0.130.136-GA-linux64.tar.bz2archive 安装了AMDAPPSDK-3.0。
- 一切似乎都对 clFFT 的编译有效,但它失败了:
4.1) 首先,在上面cmakecommand 的末尾,我得到:
cmake -DOpenCL_INCLUDE_DIR=/opt/AMDAPPSDK-3.0/include -DOpenCL_LIBRARY=/opt/AMDAPPSDK-3.0/lib/x86_64 ../clFFT/src/
-- The C compiler identification is GNU 8.3.0
-- The CXX compiler identification is GNU 8.3.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- UNICODE feature disabled on linux
-- 64bit build - FIND_LIBRARY_USE_LIB64_PATHS TRUE
-- Could NOT find Boost
CMake Warning at CMakeLists.txt:146 (message):
Try setting Boost_DEBUG and Boost_DETAILED_FAILURE_MSG for more information
-- Looking for CL_VERSION_2_2
-- Looking for CL_VERSION_2_2 - not found
-- Looking for CL_VERSION_2_1
-- Looking for CL_VERSION_2_1 - not found
-- Looking for CL_VERSION_2_0
-- Looking for CL_VERSION_2_0 - found
-- Found OpenCL: /opt/AMDAPPSDK-3.0/lib/x86_64 (found version "2.0")
-- Found FFTW: /usr/lib/x86_64-linux-gnu/libfftw3f.so;/usr/lib/x86_64-linux-gnu/libfftw3.so
-- Detected GNU fortran compiler.
-- CMAKE_CXX_COMPILER flags: -m64 -pthread
-- CMAKE_CXX_COMPILER debug flags: -g
-- CMAKE_CXX_COMPILER release flags: -O3 -DNDEBUG
-- CMAKE_CXX_COMPILER relwithdebinfo flags: -O2 -g -DNDEBUG
-- CMAKE_EXE_LINKER link flags:
FFT clients will NOT be built
GoogleTest unit tests will NOT be built
FFT callback client will NOT be built
-- Configuring done
WARNING: Target "clFFT" requests linking to directory "/opt/AMDAPPSDK-3.0/lib/x86_64". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "clFFT" requests linking to directory "/opt/AMDAPPSDK-3.0/lib/x86_64". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "StatTimer" requests linking to directory "/opt/AMDAPPSDK-3.0/lib/x86_64". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "StatTimer" requests linking to directory "/opt/AMDAPPSDK-3.0/lib/x86_64". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "example_examples_fft2d" requests linking to directory "/opt/AMDAPPSDK-3.0/lib/x86_64". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "example_examples_fft3d" requests linking to directory "/opt/AMDAPPSDK-3.0/lib/x86_64". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "example_examples_fft1d" requests linking to directory "/opt/AMDAPPSDK-3.0/lib/x86_64". Targets may link only to libraries. CMake is dropping the item.
-- Generating done
-- Build files have been written to: /opt/build
更准确地说,我说的是:
-- Configuring done
WARNING: Target "clFFT" requests linking to directory "/opt/AMDAPPSDK-3.0/lib/x86_64". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "clFFT" requests linking to directory "/opt/AMDAPPSDK-3.0/lib/x86_64". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "StatTimer" requests linking to directory "/opt/AMDAPPSDK-3.0/lib/x86_64". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "StatTimer" requests linking to directory "/opt/AMDAPPSDK-3.0/lib/x86_64". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "example_examples_fft2d" requests linking to directory "/opt/AMDAPPSDK-3.0/lib/x86_64". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "example_examples_fft3d" requests linking to directory "/opt/AMDAPPSDK-3.0/lib/x86_64". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "example_examples_fft1d" requests linking to directory "/opt/AMDAPPSDK-3.0/lib/x86_64". Targets may link only to libraries. CMake is dropping the item.
-- Generating done
-- Build files have been written to: /opt/build
4.2) 启动make进入/opt/build/ 目录后,我收到以下警告:
$ make
Scanning dependencies of target clFFT
[ 3%] Building CXX object library/CMakeFiles/clFFT.dir/transform.cpp.o
In file included from /opt/clFFT/src/library/repo.h:26,
from /opt/clFFT/src/library/transform.cpp:23:
/opt/clFFT/src/library/../statTimer/statisticalTimer.GPU.h:132:42: warning: ignoring attributes on template argument âcl_uintâ {aka âunsigned intâ} [-Wignored-attributes]
typedef std::pair< std::string, cl_uint > idPair;
^
[ 7%] Building CXX object library/CMakeFiles/clFFT.dir/accessors.cpp.o
In file included from /opt/clFFT/src/library/repo.h:26,
from /opt/clFFT/src/library/accessors.cpp:23:
/opt/clFFT/src/library/../statTimer/statisticalTimer.GPU.h:132:42: warning: ignoring attributes on template argument âcl_uintâ {aka âunsigned intâ} [-Wignored-attributes]
typedef std::pair< std::string, cl_uint > idPair;
^
[ 11%] Building CXX object library/CMakeFiles/clFFT.dir/plan.cpp.o
In file included from /opt/clFFT/src/library/repo.h:26,
from /opt/clFFT/src/library/plan.cpp:25:
/opt/clFFT/src/library/../statTimer/statisticalTimer.GPU.h:132:42: warning: ignoring attributes on template argument âcl_uintâ {aka âunsigned intâ} [-Wignored-attributes]
typedef std::pair< std::string, cl_uint > idPair;
^
[ 15%] Building CXX object library/CMakeFiles/clFFT.dir/repo.cpp.o
In file included from /opt/clFFT/src/library/repo.h:26,
from /opt/clFFT/src/library/repo.cpp:22:
...
最后,我得到以下结束错误:
[ 80%] Building C object examples/CMakeFiles/example_examples_fft2d.dir/fft2d.c.o
/opt/clFFT/src/examples/fft2d.c: In function âmainâ:
/opt/clFFT/src/examples/fft2d.c:63:5: warning: âclCreateCommandQueueâ is deprecated [-Wdeprecated-declarations]
queue = clCreateCommandQueue( ctx, device, 0, &err );
^~~~~
In file included from /opt/clFFT/src/include/clFFT.h:33,
from /opt/clFFT/src/examples/fft2d.c:21:
/opt/AMDAPPSDK-3.0/include/CL/cl.h:1359:1: note: declared here
clCreateCommandQueue(cl_context /* context */,
^~~~~~~~~~~~~~~~~~~~
[ 84%] Linking C executable examples/fft2d
/usr/bin/ld: CMakeFiles/example_examples_fft2d.dir/fft2d.c.o: in function `main':
fft2d.c:(.text.startup+0x76): undefined reference to `clGetPlatformIDs'
/usr/bin/ld: fft2d.c:(.text.startup+0x9d): undefined reference to `clGetPlatformInfo'
/usr/bin/ld: fft2d.c:(.text.startup+0xd1): undefined reference to `clGetDeviceIDs'
/usr/bin/ld: fft2d.c:(.text.startup+0xf6): undefined reference to `clGetDeviceInfo'
/usr/bin/ld: fft2d.c:(.text.startup+0x13c): undefined reference to `clCreateContext'
/usr/bin/ld: fft2d.c:(.text.startup+0x152): undefined reference to `clCreateCommandQueue'
/usr/bin/ld: fft2d.c:(.text.startup+0x215): undefined reference to `clCreateBuffer'
/usr/bin/ld: fft2d.c:(.text.startup+0x241): undefined reference to `clEnqueueWriteBuffer'
/usr/bin/ld: fft2d.c:(.text.startup+0x307): undefined reference to `clFinish'
/usr/bin/ld: fft2d.c:(.text.startup+0x334): undefined reference to `clEnqueueReadBuffer'
/usr/bin/ld: fft2d.c:(.text.startup+0x3a7): undefined reference to `clReleaseMemObject'
/usr/bin/ld: fft2d.c:(.text.startup+0x3cc): undefined reference to `clReleaseCommandQueue'
/usr/bin/ld: fft2d.c:(.text.startup+0x3d5): undefined reference to `clReleaseContext'
/usr/bin/ld: ../library/libclFFT.so.2.14.0: undefined reference to `clBuildProgram'
/usr/bin/ld: ../library/libclFFT.so.2.14.0: undefined reference to `clEnqueueNDRangeKernel'
/usr/bin/ld: ../library/libclFFT.so.2.14.0: undefined reference to `clSetKernelArg'
/usr/bin/ld: ../library/libclFFT.so.2.14.0: undefined reference to `clGetCommandQueueInfo'
/usr/bin/ld: ../library/libclFFT.so.2.14.0: undefined reference to `clReleaseEvent'
/usr/bin/ld: ../library/libclFFT.so.2.14.0: undefined reference to `clGetProgramBuildInfo'
/usr/bin/ld: ../library/libclFFT.so.2.14.0: undefined reference to `clGetContextInfo'
/usr/bin/ld: ../library/libclFFT.so.2.14.0: undefined reference to `clCreateProgramWithBinary'
/usr/bin/ld: ../library/libclFFT.so.2.14.0: undefined reference to `clRetainContext'
/usr/bin/ld: ../library/libclFFT.so.2.14.0: undefined reference to `clReleaseProgram'
/usr/bin/ld: ../library/libclFFT.so.2.14.0: undefined reference to `clGetProgramInfo'
/usr/bin/ld: ../library/libclFFT.so.2.14.0: undefined reference to `clCreateKernel'
/usr/bin/ld: ../library/libclFFT.so.2.14.0: undefined reference to `clCreateProgramWithSource'
/usr/bin/ld: ../library/libclFFT.so.2.14.0: undefined reference to `clReleaseKernel'
collect2: error: ld returned 1 exit status
make[2]: *** [examples/CMakeFiles/example_examples_fft2d.dir/build.make:85: examples/examples/fft2d] Error 1
make[1]: *** [CMakeFiles/Makefile2:223: examples/CMakeFiles/example_examples_fft2d.dir/all] Error 2
make: *** [Makefile:152: all] Error 2
我不明白这些错误可能来自哪里,似乎我构建的库 libclFFT.so.2.14.0 不包含对 OpenCL 基本函数的引用(如 clGetPlatformIDs 或 clCreateCommandQueue...)。
另外,我不知道为什么未定义引用的路径是上层的,即/usr/bin/ld: ../library/libclFFT.so.2.14.0,因为库是内置在/opt/build/library目录下的。
我希望能够很好地编译libclFFT.so,它考虑到路径OpenCL_INCLUDE_DIR 指示的OpenCL 标头和OpenCL_LIBRARY 指示的库。
我必须解决cmake 采用的路径问题,即:../library/libclFFT.so.2.14.0 并将来自AMDAPPSDK 的所有 OpenCL 函数包含到该库的构建中。
【问题讨论】:
-
你使用什么操作系统和编译器?
-
请致电
make VERBOSE=1- 您将获得编译和链接命令。之后您可能会看到如何自己解决问题...如果没有,请使用此新信息更新您的问题 -
@HEKTO。问题最终在 MacOS Catalina 上得到解决,但最后一个问题是:如何管理 MacOS 上用于 OpenCL 的 AMD APP SDK 的安装,是否默认安装?我没有看到很多关于此的文档?我意识到我有
/System/Library/Frameworks/OpenCL.framework和/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/OpenCL.frameworkdirectories 但我不确定是否必须安装另一个 AMD APP SDK 才能获得最后的 OpenCL 库?欢迎任何帮助。问候 -
我从来没有听说过在 MacOS 上使用 AMD APP SDK - 我相信这个(相当过时的)包是为 Windows 和 Linux 开发的。 MacOS 拥有(或拥有?)自己的 OpenCL 实现,应使用
-framework OpenCL选项访问它 -
@HEKTO 谢谢,这是我的想法,但不确定。最初,我在 Linux 上使用 AMD APP SDK OpenCL。
标签: cmake compiler-errors shared-libraries opencl