2 Replies Latest reply on Dec 11, 2011 2:28 PM by morphet

    Undefined references while compiling with mingw

    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 ;-)

      undefined reference to `clCreateContext@24'

        • Undefined references while compiling with mingw
          notyou

           

          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).