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
Forum Updated to NodeBB v4.3 + New Features

Linker issue with CUDA API libraries

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 4 Posters 1.6k 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.
  • C Offline
    C Offline
    Cobra91151
    wrote on 13 May 2017, 18:13 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
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 13 May 2017, 18:32 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).

      C 2 Replies Last reply 13 May 2017, 18:46
      3
      • C Chris Kawa
        13 May 2017, 18:32

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

        C Offline
        C Offline
        Cobra91151
        wrote on 13 May 2017, 18:46 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
        • C Chris Kawa
          13 May 2017, 18:32

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

          C Offline
          C Offline
          Cobra91151
          wrote on 13 May 2017, 19:12 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 16 Sept 2019, 08:13 last edited by
            #5

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

            A 1 Reply Last reply 16 Sept 2019, 08:46
            0
            • V vaibs1224
              16 Sept 2019, 08:13

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

              A Offline
              A Offline
              aha_1980
              Lifetime Qt Champion
              wrote on 16 Sept 2019, 08:46 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