Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
The Intel sign-in experience has changed to support enhanced security controls. If you sign in, click here for more information.
7782 Discussions

QT and VIsual Studio using OpenCL x86 undefined reference to symbol


Hardware specs :
Core: Intel Core i7 2600
GPU: Nvidia Geforce Gtx-580

Software environment:
IDE 1: QT 4.8
IDE 2: Visual Studio 2013 
OS: Windows 7 
Compiler for QT: mingw32-g+.exe
Compiler for VS: cl.exe
SDK: Intel OpenCL Code builder 2015, v


Goal: Have a 32bit build application in QT4.8 using OpenCL and mingw32-g++ compiler. 

Building a simple hello world program that reference any opencl methods, I get an undefined reference.

In QT 
undefined reference to  clGetPlatformIDs@12

 undefined reference to  _clCreateBuffer@24 referenced in function _main 

What I have done:
- reference compiler to includes of intel includes =>C:\Intel\INDE\code_builder_5.0.0.43\include 
- reference linker to intel librarie OpenCL.lib=> C:\Intel\INDE\code_builder_5.0.0.43\lib\x86   


In visual studio I get to compile properly. but building (compile + link) I get the error. And this linking only works well if I build for a x64 platform, and reference the VS IDE to the x64 libraries.  C:\Intel\INDE\code_builder_5.0.0.43\lib\x64 instead

1. What am I doing wrong? How to get it to work?
2. Does the OpenCL libraries really support x86 platforms? I dumpbin the libraries for both platform, and  the symbols name were differnent. in x64 they had for example clGetPlatformIDs and in x86 library _clGetPlatformIDs@12. 
3. My platform is openCL 1.2, Should I be put the visual studio include path to a opencl 1.2 header files? instead of the ones came with the sdk? I assume they are for opencl 2.1 

0 Kudos
1 Reply
Black Belt

If you mix the obsolete stdcall API of 15 years ago (as shown in your undefined references) with the current cdecl you are bound to fail.

Mixing 32-bit and X64/intel64 builds won't work, regardless of stdcall settings. 

As you saw, Microsoft and Intel support were transitioned to cdecl when X64 was invented.

Mixing mingw and VS compatible compilation seems doubtful, as run-time library conflicts are likely.

I don't know about interoperability of opencl and c++, but it seems at best it would be restricted to current x64/Intel64 mode.  It's strange that it's so hard to find information on the 32 vs. 64-bitness of the OpenCL.