I had to make OpenCL computations with following configuration:

  • Windows 7 64bit
  • mingw32
  • NVidia GPU

The problem is that NVidia provides in their samples only Visual Studio (2008 and 2010) version of OpenCL libraries in their samples. So, the problem was getting a static .a or dynamic .dll 32bit library for mingw32 along with appropriate headers. Many ways I tried failed (most notable one was trying to use reimp tool as described here), so I solved the problem in a less clean manner. I simply copied all header files from NVidia’s samples and copied the dll file from one of NVidia’s folders on my PC. This made my code compile without problems and link with some warnings (presumably caused by the difference of function naming between VS and g++ compilers) similar to those:

Warning: resolving _clGetPlatformIDs@12 by linking to _clGetPlatformIDs
Warning: resolving _clGetPlatformInfo@20 by linking to _clGetPlatformInfo

It worked nevertheless thanks to automatic call correction. To supress those warnings, I used the suggested --enable-stdcall-fixup linker option (meaning -Xlinker --enable-stdcall-fixup for g++). I compiled everything with the following call:
g++ -o app -O3 -Ilib -Llib -Xlinker --enable-stdcall-fixup -lOpenCL app.cpp

where lib was the folder containing CL folder with headers and OpenCL.dll file.

Please note that I haven't really tested what kind of impact would this change have on OpenCL performance. I assume there should be no changes. Also, I only used few OpenCL 1.1 features in my project, so in some situations you might want to somehow check compatibility of header files and the dll file you used.

Here is a zip file containing the OpenCL.dll file with headers I used: OpenCL dll library with headers.