0
votes

I was trying to get my problem solved for hours, but I did not find any usefull hints. Hopefully you guys can help me out:

Some usefull data:
OS: Windows 8 Basic 64bit
Library: Intel OpenCL SDK
Compiler: MinGW(-gcc) (latest version)
IDE: Code::Blocks (latest version)

Minimal not working Code:

#include <stdlib.h>
#include <CL/cl.h>

int main(void)
{
  cl_uint available;
  cl_platform_id* platforms = (cl_platform_id*)malloc(sizeof(cl_platform_id));
  cl_int result = clGetPlatformIDs(1, platforms, &available);
  free(platforms);
  if(result == CL_SUCCESS)      
    return 0;      
  return -1;
}

Code::Blocks Global Compiler Settings:
Linker Settings: Added path to Intel's OpenCL.lib ([...]\Intel\OpenCL SDK\3.0\lib\x64\OpenCL.lib) (tried -lOpenCL as Other Options as well)
Search-Directories for Compiler: Path to Intels OpenCL-SDK include directory ([...]\Intel\OpenCL SDK\3.0\include)
Search-Directories for Linker: Path to Intels OpenCL-Lib directory ([...]\Intel\OpenCL SDK\3.0\lib\x64)

Build-Log:

mingw32-g++.exe -L"[...]\Intel\OpenCL SDK\3.0\lib\x64"  -o bin\Release\openCLTest.exe     obj\Release\main.o   -s "[...]\Intel\OpenCL SDK\3.0\lib\x64\OpenCL.lib" 
obj\Release\main.o:main.c:(.text.startup+0x39): undefined reference to `clGetPlatformIDs@12'
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings (0 minutes, 0 seconds)

I do not know why he does not link properly. The [...] in the text is modified by me to shorten the path, normally it would be "C:\Program Files (x86)...".

Hopefully you guys can help me! It is really frustrating! :(
Do you need more information?

EDIT:
Okay... one additional hour and I solved my own problem.
Hope this hint can help some other ppl:
I had to link additionally against the x86-library (seems that some functions are not implemented in X64).
Good to know -.-'''

2
Please add your solution as an answer to the question. You can later accept it, which marks the questions as solved. Putting solved in the title does not work on Stack Overflow. - talonmies
Worth noting that the actual reason it didn't work is because you were using 32-bit MinGW, and so the 64-bit library was unreadable. All functions are implemented in x64, you just need a 64-bit compiler to use them ;) - Thomas

2 Answers

0
votes

I got the same problem and I tried hard to figure out the solution and finally I did :)

First of all my hardware are Intel Processor Intel(R) Core(TM) i5-2500 CPU @ 3.30GHz and Intel(R) HD Graphics then I installed Intel OpenCL SDK 1.2 after updating the drivers. After that I configure the code::blocks to the new paths for include folder and lib folder as mentioned on the following link: http://www.obellianne.fr/alexandre/tutorials/OpenCL/tuto_opencl_codeblocks.php

Then I tried to compile the examples and I got linking problem as follows:

opencl.o(.text+0x6f):opencl.c: undefined reference to `clGetPlatformIDs@12'
opencl.o(.text+0xa7):opencl.c: undefined reference to `clGetDeviceIDs@24'
opencl.o(.text+0x142):opencl.c: undefined reference to `clGetDeviceInfo@20'
opencl.o(.text+0x263):opencl.c: undefined reference to `clGetDeviceInfo@20'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
4 errors, 0 warnings (0 minutes, 0 seconds)

I tried to use command line and I got the same error then I tried to uninstall Intel sdk and replace it with AMD sdk 2.8 which is support X86 CPU with SSE (Streaming SIMD Extension which is designed by Intel ) 2.x orlater

http://developer.amd.com/tools-and-sdks/heterogeneous-computing/amd-accelerated-parallel-processing-app-sdk/system-requirements-driver-compatibility/

Finally it works :)

I hope you find this comment useful.

0
votes

According to an external source i stumbled upon along my own path of enlightenment to this problem i found out something is actually wrong with the mingw-w64 linker. mingw-w64's ld.exe does not want to link with the standard libopencl.a.. whether this is intel SDK specific or not im not sure but here is the link to the solution.

http://sourceforge.net/p/mingw-w64/support-requests/46/

you just have to link to the supplied libopencl.a instead of the default one.

still dont know exactly why the linker gives a problem but i have verified that the solution does (some how) solve the problem.