clFFT编译问题:对`clGetPlatformInfo'和其他OpenCL函数的未定义引用

时间:2019-06-25 00:26:13

标签: cmake compiler-errors shared-libraries opencl

我尝试构建clFFT库(用于使用OpenCL进行FFT)和包含在clFFT git中的示例。

1)首先,我进入/opt/

git clone https://github.com/clMathLibraries/clFFT.git

2)之后,我总是进入/opt/目录:$ mkdir build && cd build/

3)从这里,我这样叫cmake

cmake -DOpenCL_INCLUDE_DIR=/opt/AMDAPPSDK-3.0/include -DOpenCL_LIBRARY=/opt/AMDAPPSDK-3.0/lib/x86_64 ../clFFT/src/

实际上,我已经从/opt/归档文件中安装了AMDAPPSDK-3.0AMD-APP-SDKInstaller-v3.0.130.136-GA-linux64.tar.bz2目录中。

4)一切似乎对于clFFT的编译都是有效的,但失败了:

4.1)首先,在上述cmake命令的末尾,我得到:

 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或{{1} } ...)。

此外,我不知道为什么未定义引用的路径是上一级,即clCreateCommandQueue,因为该库内置在/usr/bin/ld: ../library/libclFFT.so.2.14.0目录中

考虑到路径/opt/build/library指示的OpenCL标头和libclFFT.so指示的库,我希望能够对OpenCL_INCLUDE_DIR进行精细的编译。

我必须解决OpenCL_LIBRARY所采取的路径问题,即cmake,并将../library/libclFFT.so.2.14.0 SDK中的所有OpenCL函数包含到该库的构建中。

欢迎您的帮助,

1 个答案:

答案 0 :(得分:1)

您计算机上的mypalette=rep("Green",length(Days)) mypalette[Days <= 25] = "Pink" mypalette[Days <= 15] = "Orange" mypalette[Days <= 5] = "Blue" mypalette[is.na(Days)] = "Red" 安装程序应具有一个OpenCL查找程序,当 window.onload= function (){ var paper = new Raphael( 0, 0, 800, 600); var backGround = paper.rect(0,0,800,600); backGround.attr({ fill: "blue"}); /* Comment - Add your code here*/ var ball = paper.circle(0,0,30); ball.attr({ fill: "black"}); function position1() { ball.animate({cy: 150 , cx: 250 }, 500, 'ease-in', position2); } function position2() { ball.animate({cy: 105 , cx: 309}, 500, 'ease-in', position3); } function position3() { ball.animate({cy: 100 , cx: 400}, 500, 'ease-in', position4); } function position4() { ball.animate({cy: 120 , cx: 490}, 500, 'ease-in', position5); } function position5() { ball.animate({cy: 520 , cx: 190}, 500, 'ease-in', position6); } function position6() { ball.animate({cy: 300 , cx: 540}, 500, 'ease-in', position7); } function position7() { ball.animate({cy: 410 , cx: 450}, 500, 'ease-in', position8); } function position8() { ball.animate({cy: 400 , cx: 300}, 500, 'ease-in', position9); } function position9() { ball.animate({cy: 305 , cx: 250}, 500, 'ease-in', position10); } function position10() { ball.animate({cy: 220 , cx: 230}, 500, 'ease-in', position1); } }; 从{{1}执行cmake文件时,该命令由find_package(OpenCL)命令调用}}分发(也可以在您自己的cmake文件中使用此命令)。该查找程序只是一个名为CMakeLists.txt的文件,该文件必须是clFFT配置的一部分。确保您拥有此文件:

CMakeLists.txt

如果拥有此查找程序,则无需在FindOpenCL.cmake调用中设置变量cmakefind /usr -name FindOpenCL.cmake -查找程序将找到所有所需的OpenCL路径。如果您有这个查找程序,但是它不能正常工作-那么对于它的开发人员来说将是个问题。如果您没有拥有此查找器,那么在OpenCL_INCLUDE_DIR安装和/或设置中将是一个问题。 here描述了该发现者。

根据我们在评论中的对话,您试图在MacOS上使用AMD APP SDK v3.0软件包-这是行不通的,因为AMD仅支持Windows和Linux操作系统。这是可以理解的,因为Apple拥有自己的OpenCL支持悠久的历史-请参阅here