Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. Problem linking OpenCL
Forum Update on Monday, May 27th 2025

Problem linking OpenCL

Scheduled Pinned Locked Moved Installation and Deployment
5 Posts 3 Posters 4.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mirror3000
    wrote on 25 Jul 2013, 21:43 last edited by
    #1

    I work on a project and I must link the OpenCL library on Windows.
    When I use the QtCreator to add it (right click on project, in project tree/Add library), I get error “LNK2019: unresolved external symbol clGetPlatformID”
    The .pro file looks like this:

    @win32: LIBS += -L$$PWD/../../../../../Program Files/NVIDIA GPU Computing Toolkit/CUDA/v5.0/lib/Win32/ -lOpenCL

    INCLUDEPATH += $$PWD/../../../../../Program Files/NVIDIA GPU Computing Toolkit/CUDA/v5.0/lib/Win32
    DEPENDPATH += $$PWD/../../../../../Program Files/NVIDIA GPU Computing Toolkit/CUDA/v5.0/include

    win32: PRE_TARGETDEPS += $$PWD/../../../../../Program Files/NVIDIA GPU Computing --Toolkit/CUDA/v5.0/lib/Win32/OpenCL.lib@

    Also, I tried a different approach: I copied the OpenCL folder to C:\opencl because I thought that the white spaces in the file path may cause problems, but I still get the same errors.
    The .pro file for this approach looks like this:

    @win32:CONFIG(release, debug|release): LIBS += -Lc:/opencl/lib/Win32 -lOpenCL
    else:win32:CONFIG(debug, debug|release): LIBS += -Lc:/opencl/lib/Win32 -lOpenCL

    INCLUDEPATH += c:/opencl/include
    DEPENDPATH += c:/opencl/include@

    Another problem I get is when I try to include <CL/cl.h>.
    @C1083: Cannot open include file: 'CL/cl.h': No such file or directory.@

    I fixed this by copying the cl.h in the project, but this isn’t the best way.
    Any ideas of how to fix this?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on 26 Jul 2013, 06:42 last edited by
      #2

      welcome to devnet

      This looks like a compiler mismatch.
      Are you sure that the openCL lib is compiled with the same compiler and the same version as you are using in Qt creator as a tool chain?

      [quote author="mirror3000" date="1374788633"]
      @win32:CONFIG(release, debug|release): LIBS += -Lc:/opencl/lib/Win32 -lOpenCL
      else:win32:CONFIG(debug, debug|release): LIBS += -Lc:/opencl/lib/Win32 -lOpenCL

      INCLUDEPATH += c:/opencl/include
      DEPENDPATH += c:/opencl/include@
      [/quote]
      You are using the same LIBS statement for debug and release. If that is your intention, you can change to :
      @LIBS += -Lc:/opencl/lib/Win32 -lOpenCL
      @

      However, this may be also the basis of your problem. You may try to use a release lib with a debug compilation. You need to check.

      [quote author="mirror3000" date="1374788633"]
      Another problem I get is when I try to include <CL/cl.h>.
      @C1083: Cannot open include file: 'CL/cl.h': No such file or directory.@
      [/quote]

      Where is the include file located?
      Your current project.pro allows only includes from
      @
      INCLUDEPATH += c:/opencl/include
      @

      You need to add the location where the actual include is located.

      Based on this information
      [quote author="mirror3000" date="1374788633"]
      @win32: LIBS += -L$$PWD/../../../../../Program Files/NVIDIA GPU Computing Toolkit/CUDA/v5.0/lib/Win32/ -lOpenCL

      INCLUDEPATH += $$PWD/../../../../../Program Files/NVIDIA GPU Computing Toolkit/CUDA/v5.0/lib/Win32
      DEPENDPATH += $$PWD/../../../../../Program Files/NVIDIA GPU Computing Toolkit/CUDA/v5.0/include

      win32: PRE_TARGETDEPS += $$PWD/../../../../../Program Files/NVIDIA GPU Computing --Toolkit/CUDA/v5.0/lib/Win32/OpenCL.lib@
      [/quote]

      I guess it should be something like
      @
      INCLUDEPATH += c:/opencl/include
      INCLUDEPATH += c:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v5.0/lib/include
      @

      Vote the answer(s) that helped you to solve your issue(s)

      1 Reply Last reply
      0
      • S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 26 Jul 2013, 08:10 last edited by
        #3

        Hi,

        to add to what koahnig wrote, IIRC when installing cuda sets up some environment variables containing the path to its installation folder, you can use them in your pro file

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mirror3000
          wrote on 26 Jul 2013, 14:12 last edited by
          #4

          @SGaist Yes, they do add environment variables. Thanks for the tip:)

          The compiler I use with QtCreator is MSVC 11 x64.
          I tried including both the X64 and Win32 libraries, but it didn't work with debug compilation. It works with release compilation.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 26 Jul 2013, 21:28 last edited by
            #5

            What doesn't work in debug mode ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0

            1/5

            25 Jul 2013, 21:43

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved