Compiling OpenCL programs on Mac OS X Snow Leopard
I installed Snow Leopard on my laptop yesterday. I was very curious about OpenCL and installed the drivers and the GPU Computing SDK from NVIDIA.
I searched my hard disk after installation and found the following directory: /Developer/GPU Computing/OpenCL. Looks promising.
In the subdirectory src/oclDeviceQuery I found a basic test and I tried to compile it.
$ cd src/oclDeviceQuery $ make ld: library not found for -loclUtil collect2: ld returned 1 exit status make: *** [../../..//OpenCL//bin//darwin/release/oclDeviceQuery] Error 1
I googled for “-loclUtils”? I found nothing. “liboclUtils”? Nothing. So i found a brand new problem that is not known to mankind. Hurray.
But i remembered a similiar situation when i used the CUDA-SDK. So i searched the other directories. The solution is to create the library manually.
$ pushd ../../common/ $ make ar: creating archive ../..//OpenCL//common//lib/liboclUtil.a q - obj/release/oclUtils.cpp.o $ popd
So -loclUtil should now be found. And i tried to compile again.
$ make ld: library not found for -lshrutil collect2: ld returned 1 exit status make: *** [../../..//OpenCL//bin//darwin/release/oclDeviceQuery] Error 1
Aha, there’s another library missing. I tried the one in /Developer/GPU Computing/shared.
$ cd ../../../shared/ $ make src/rendercheckGL.cpp: In member function ‘virtual bool CheckBackBuffer::readback(GLuint, GLuint, GLuint)’: src/rendercheckGL.cpp:523: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘GLuint’ src/rendercheckGL.cpp:527: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘GLuint’ src/rendercheckGL.cpp: In member function ‘virtual bool CheckFBO::readback(GLuint, GLuint, GLuint)’: src/rendercheckGL.cpp:1342: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘GLuint’ src/rendercheckGL.cpp:1346: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘GLuint’ a - obj/release/shrUtils.cpp.o a - obj/release/rendercheckGL.cpp.o a - obj/release/cmd_arg_reader.cpp.o
Back into the directory with the device query sources.
$ cd ../OpenCL/src/oclDeviceQuery/ $ make
The compilation succeeds, but where’s the executable? It is not in the current directory.
$ ls Makefile obj/ oclDeviceQuery.cpp
I searched the directories again and its in a bin subfolder of /Developer/GPU Computing/OpenCL
$ ../../bin/darwin/release/oclDeviceQuery oclDeviceQuery.exe Starting... OpenCL SW Info: CL_PLATFORM_NAME: Apple CL_PLATFORM_VERSION: OpenCL 1.0 (Jul 15 2009 23:07:32) OpenCL SDK Version: 1.2.0.16 ...
That’s it. OpenCL runs on my laptop. Yeah. ![]()
October 7th, 2009 at 19:17 pm
Hello
I installed Snow Leopard with Xcode too, but I don’t find “/Developer/Gpu Computing directory”. I only find Opencl.framework directory. Is it necessary to install anything else?
Thanks
Best Regard
October 13th, 2009 at 18:48 pm
Sorry, i forgot to mention the GPU Computing SDK from NVIDIA. I updated the article.