cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

morphet
Journeyman III

Undefined references while compiling with mingw

Good afternoon AMD aficionados !

I'm just begining developping with OpenCL and I'm running out with problems. At this point, my problem is that when I compile my test application I've got "undefined reference"(s) like this :

"undefined reference to `clCreateContext@24'"

Here is my build command :

gcc -o example -I"C:\Program Files (x86)\AMD APP\include" -L"C:\Program Files (x86)\AMD APP\lib\x86_64" main.cpp -lOpenCL

Most of the time, as I saw on forums, the error occurs when the programmer forget the "-OpenCL" option at the end, but I didn't !

If someone knows what happens to my compilation, I would be very happy, as I want to start coding my own stuff as soon as possible.

Thanks in advance 😉

undefined reference to `clCreateContext@24'

0 Likes
2 Replies
notyou
Adept III

Originally posted by: morphet Good afternoon AMD aficionados !

 

I'm just begining developping with OpenCL and I'm running out with problems. At this point, my problem is that when I compile my test application I've got "undefined reference"(s) like this :

 

"undefined reference to `clCreateContext@24'"

 

Here is my build command :

 

gcc -o example -I"C:\Program Files (x86)\AMD APP\include" -L"C:\Program Files (x86)\AMD APP\lib\x86_64" main.cpp -lOpenCL

 

Most of the time, as I saw on forums, the error occurs when the programmer forget the "-OpenCL" option at the end, but I didn't !

 

If someone knows what happens to my compilation, I would be very happy, as I want to start coding my own stuff as soon as possible.

 

Thanks in advance 😉

 

IIRC, that type of compilation problem results from linking the incorrect OpenCL.lib file. So, instead of linking ...\lib\x86_64, you need to link ...\lib\x86. I know it seems odd, but the version you need to link is based on your target machine and not your development machine (in VS 2010 it defaults to x86 even though my machine is x86_64 which is why I need to link the x86 library file).

0 Likes

Thanks a lot. Finally I found the good way with Code::Blocks. And like you said, I'm using x86 now, finally no need the x64 compatibility ^^

0 Likes