fglrxドライバとamd app sdkをインストールした後にOpenCLをgccに関連付けることができないのはなぜですか?

fglrxドライバとamd app sdkをインストールした後にOpenCLをgccに関連付けることができないのはなぜですか?

このチュートリアルに従って、私のコンピュータにfglrxドライバをインストールしました。http://wiki.cchtml.com/index.php/Fedora_18_Installation_Guide、opencl-headersパッケージをインストールして実行したときに、最後にamd app sdkをインストールしました。

gcc -lOpenCL someprogram.c

エラーが発生しました。

/usr/bin/ld: cannot find -lOpenCL
collect2: error: ld returned 1 exit status

fglrxinfoから次の情報を取得します。

display: :0  screen: 0
OpenGL vendor string: Advanced Micro Devices, Inc.
OpenGL renderer string: AMD Radeon HD 6310 Graphics
OpenGL version string: 4.2.12422 Compatibility Profile Context 13.152

そして/usr/lib64/にはlibopencl.soはありません。

私はそれを実行して接続する方法を見つけました。

gcc -I/opt/AMDAPP/include -L/opt/AMDAPP/lib/x86_64 -lOpenCL hellocl.c -o hello

ベストアンサー1

ldリンクする実際のライブラリが必要です。ヘッダーはリンクではなくコンパイルにのみ必要です。libOpenCL.soライブラリパスで呼び出されたファイルを見つけます。ldマンページから:

   -l namespec
   --library=namespec
       Add the archive or object file specified by namespec to the list of
       files to link.  This option may be used any number of times.  If
       namespec is of the form :filename, ld will search the library path
       for a file called filename, otherwise it will search the library path 
       for a file called libnamespec.a.

       On systems which support shared libraries, ld may also search for 
       files other than libnamespec.a. Specifically, on ELF and SunOS
       systems, ld will search a directory for a library called 
       libnamespec.so before searching for one called libnamespec.a.  
       (By convention, a ".so" extension indicates a shared library.)  
       Note that this behavior does not apply to :filename, which always
       specifies a file called
       filename.

ビルドシステムが探している名前にライブラリをシンボリックリンクしてみてください。

ln -s /usr/lib64/libopencl.so /usr/lib64/libOpenCL.so

おすすめ記事