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. How do you add a library in QT

How do you add a library in QT

Scheduled Pinned Locked Moved Installation and Deployment
5 Posts 2 Posters 1.8k Views 1 Watching
  • 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.
  • D Offline
    D Offline
    dolphonebubleine
    wrote on last edited by
    #1

    All I am trying to do is add OpenCL to a QT project. My OpenCL files are in

    @
    c:/opencl

    c:/opencl/include/CL/cl.h
    c:/opencl/lib/x86/OpenCL.lib@

    According to what I read "here":http://qt-project.org/forums/viewthread/6960 if you have a .lib and a .dll you should link dynamically and I do have a .dll.

    @c:/opencl/bin/x86/OpenCL.dll@

    I setup my .pro file:

    @LIBS += -lOpenCL
    LIBS += -LC:/opencl/lib/x86
    INCLUDEPATH += C:/opencl/include@

    I include the header file:

    @#include <CL/cl.h>@

    QT intellisense incorporates the header file

    !http://i.troll.ws/83b43d1e.png()!

    The application builds and runs fine. However, as soon as I try to call any of the functions in the library I get linker errors:

    @LNK2019: unresolved external symbol clGetPlatformIDs referenced in function main
    LNK1120: 1 unresolved externals@

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      2 potential solutions I see here:

      • linkers are sequential - they include the libraries in the order you specify. In your case, you are including the libfile (small 'L') before you specify the folder that contains it (big 'L'). Swap those 2 lines and it could work
      • on Windows, you can actually specify the path to your .lib file without any '-l' or '-L': LIBS += C:/opencl/lib/x86/OpenCL.lib

      (Z(:^

      1 Reply Last reply
      0
      • D Offline
        D Offline
        dolphonebubleine
        wrote on last edited by
        #3

        Good guess but it's a nogo. Neither attempt worked.

        @LIBS += "C:/opencl/lib/x86/OpenCL.lib"
        INCLUDEPATH += C:/opencl/include@

        @LIBS += -LC:/opencl/lib/x86
        LIBS += -lOpenCL
        INCLUDEPATH += C:/opencl/include@

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dolphonebubleine
          wrote on last edited by
          #4

          I finally figured this out (with some help).

          I installed QT 64-bit. Then I linked to OpenCL 64 bit (did not realize it but I was linked to 32 bit OpenCL before).

          1 Reply Last reply
          0
          • sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            Uh, very good find. 64/32 bit mismatches are sometimes hard to notice.

            (Z(:^

            1 Reply Last reply
            0

            • Login

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