Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Linker issue with CUDA API libraries
Qt 6.11 is out! See what's new in the release blog

Linker issue with CUDA API libraries

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 2.4k 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.
  • Cobra91151C Offline
    Cobra91151C Offline
    Cobra91151
    wrote on last edited by Cobra91151
    #1

    Hi! I want to add Nvidia CUDA API to Qt (OS: Windows | Qt 5.7.1).

    I have included:

    .pro file
    
    INCLUDEPATH += "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0\\include"
    
    win32 {
        contains(QMAKE_TARGET.arch, x86_64) {
          LIBS += "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0\\lib\\x64\\cudadevrt.lib"
        } else {
          LIBS += "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0\\lib\\Win32\\cudadevrt.lib"
        }
    }
    
    test.h file
    #include <cuda_runtime.h>
    

    I get errors in test.cpp :

    Screenshot:

    alt text

    I have test it in Visual Studio 2015 as console project and it works, but not in Qt.

    How to fix it? Thanks in advance.

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by Chris Kawa
      #2

      That's not how you pass libraries to the linker. Change this:

      LIBS += "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0\\lib\\x64\\cudadevrt.lib"
      

      to

      LIBS += -L"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64" -lcudadevrt
      

      That's -L for the path and -l(lowercase L) for the library name without the extension.
      After that re-run qmake (menu Build->Run qmake).

      Cobra91151C 2 Replies Last reply
      3
      • Chris KawaC Chris Kawa

        That's not how you pass libraries to the linker. Change this:

        LIBS += "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0\\lib\\x64\\cudadevrt.lib"
        

        to

        LIBS += -L"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64" -lcudadevrt
        

        That's -L for the path and -l(lowercase L) for the library name without the extension.
        After that re-run qmake (menu Build->Run qmake).

        Cobra91151C Offline
        Cobra91151C Offline
        Cobra91151
        wrote on last edited by Cobra91151
        #3

        @Chris-Kawa

        I have changed to:

        INCLUDEPATH += "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0\\include"
        
        win32 {
            contains(QMAKE_TARGET.arch, x86_64) {
              LIBS += -L"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64" -lcudadevrt
            } else {
              LIBS += -L"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/Win32" -lcudadevrt
            }
        }
        

        Run clean/run qmake/build but the errors still exists.

        1 Reply Last reply
        0
        • Chris KawaC Chris Kawa

          That's not how you pass libraries to the linker. Change this:

          LIBS += "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v8.0\\lib\\x64\\cudadevrt.lib"
          

          to

          LIBS += -L"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v8.0/lib/x64" -lcudadevrt
          

          That's -L for the path and -l(lowercase L) for the library name without the extension.
          After that re-run qmake (menu Build->Run qmake).

          Cobra91151C Offline
          Cobra91151C Offline
          Cobra91151
          wrote on last edited by
          #4

          @Chris-Kawa

          I have found the bug and fixed. Thanks.

          1 Reply Last reply
          0
          • V Offline
            V Offline
            vaibs1224
            wrote on last edited by
            #5

            @chris-kawa
            Please tell me how to solved this issue..I am troubling for solving this issue on windows platform

            aha_1980A 1 Reply Last reply
            0
            • V vaibs1224

              @chris-kawa
              Please tell me how to solved this issue..I am troubling for solving this issue on windows platform

              aha_1980A Offline
              aha_1980A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @vaibs1224

              Can you provide some more information?

              • Which compiler?
              • 32 or 64 bit?
              • Can you show your .pro file and the actual linker command from the Compile Output?

              Qt has to stay free or it will die.

              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