Linker issue with YOLO CUDA 8.0 API libraries in c files




  • Qt Champions 2017

    Hi and welcome to the forums

    Does link come with question ?

    if using C++, you might need to wrap the includes in
    extern "C" {
    #include "xxx.h"
    }

    But else you must tell a bit more about what issue is , what you tried, the
    error messages you get etc. The compiler you use.

    else the link shows how to link to the libs.



  • the problem is with functions that defined in cu file and used in c file.
    sorry my question isn't clear enough


  • Lifetime Qt Champion

    Hi,

    Then please show the exact error you are getting.



  • 0_1528320488198_Capture1.JPG


  • Lifetime Qt Champion

    What does your .pro file look like ?



  • QT += core gui

    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

    DEFINES += OPENCV
    DEFINES +=_TIMESPEC_DEFINED
    DEFINES +=_CRT_SECURE_NO_WARNINGS
    DEFINES += GPU
    DEFINES += CUDNN
    CONFIG += c++11

    INCLUDEPATH += F:\WORK\install\include
    INCLUDEPATH += F:\my_work\yolo-qt-master\src
    INCLUDEPATH += F:\my_work\yolo-qt-object-detection-master\3rdparty\include
    #INCLUDEPATH += F:\my_work\yolo-qt-object-detection-master\cudainclude

    DESTDIR = release
    OBJECTS_DIR = release/obj
    CUDA_OBJECTS_DIR = release/cuda
    CONFIG += console
    CONFIG -= app_bundle
    CONFIG += force_debug_info

    TEMPLATE = app

    #Enter your gencode here!
    GENCODE = arch=compute_52,code=sm_52

    #We must define this as we get some confilcs in minwindef.h and helper_math.h
    DEFINES += NOMINMAX

    CUDA_SOURCES += /*.cu
    #\

    F:/my_work/yolo-qt-master/src/*.c

    SOURCES += /.cu
    SOURCES -= /
    .cu

    CUDA with Windows

    #CUDA_DIR = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5"
    CUDA_DIR = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0"
    SYSTEM_NAME = x64         # Depending on your system either 'Win32', 'x64', or 'Win64'
    SYSTEM_TYPE = 64            # '32' or '64', depending on your system
    CUDA_ARCH = sm_30           # Type of CUDA architecture, for example 'compute_10', 'compute_11', 'sm_10'
    NVCC_OPTIONS = --use_fast_math # default setting
    
    #include paths
    #INCLUDEPATH += $$CUDA_DIR\include
    #INCLUDEPATH += "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\include"
    INCLUDEPATH += "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include"
    
    #library directories
    #QMAKE_LIBDIR += $$join(CUDA_DIR,'" -I"','-I"','"')\lib\$$SYSTEM_NAME
    #QMAKE_LIBDIR += "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v7.5\lib\x64"
    QMAKE_LIBDIR += "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\lib\x64"
    
    CUDA_LIBS = -lcuda -lcudart -lcufft -lcublas
    
    CUDA_INC += $$join(INCLUDEPATH,'" -I"','-I"','"')
    
    LIBS += $$CUDA_LIBS
    
    # MSVCRT link option (static or dynamic, it must be the same with your Qt SDK link option)
    MSVCRT_LINK_FLAG_DEBUG = "/MDd"
    MSVCRT_LINK_FLAG_RELEASE = "/MD"
    
    CONFIG(debug, debug|release){
        cuda_d.input    = CUDA_SOURCES
        cuda_d.output   = ${QMAKE_FILE_BASE}_cuda.obj
        cuda_d.commands = $$CUDA_DIR/bin/nvcc.exe -D_DEBUG $$NVCC_OPTIONS $$CUDA_INC $$LIBS \
                        --machine $$SYSTEM_TYPE -arch=$$CUDA_ARCH \
                        --compile -cudart static -g -DWIN32 -D_MBCS \
                        -Xcompiler "/wd4819,/EHsc,/W3,/nologo,/Od,/Zi,/RTC1" \
                        -Xcompiler $$MSVCRT_LINK_FLAG_DEBUG \
                        -c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}
        cuda_d.dependency_type = TYPE_C
        QMAKE_EXTRA_COMPILERS += cuda_d
    }
    else {
        # Release settings
        cuda.input    = CUDA_SOURCES
        cuda.output   = ${QMAKE_FILE_BASE}_cuda.obj
        cuda.commands = $$CUDA_DIR/bin/nvcc.exe $$NVCC_OPTIONS $$CUDA_INC $$LIBS \
                        --machine $$SYSTEM_TYPE -arch=$$CUDA_ARCH \
                        --compile -cudart static -DWIN32 -D_MBCS \
                        -Xcompiler "/wd4819,/EHsc,/W3,/nologo,/O2,/Zi" \
                        -Xcompiler $$MSVCRT_LINK_FLAG_RELEASE \
                        -c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}
        cuda.dependency_type = TYPE_C
        QMAKE_EXTRA_COMPILERS += cuda
    }
    

    TARGET = qt5_opencv3_darknet

    LIBS += F:\my_work\yolo-qt-object-detection-master\3rdparty\lib\x64\pthreadVC2.lib
    LIBS += F:\WORK\install\x64\vc14\lib\opencv_core320.lib
    LIBS += F:\WORK\install\x64\vc14\lib\opencv_highgui320.lib
    LIBS += F:\WORK\install\x64\vc14\lib\opencv_imgcodecs320.lib
    LIBS += F:\WORK\install\x64\vc14\lib\opencv_imgproc320.lib
    LIBS += F:\WORK\install\x64\vc14\lib\opencv_objdetect320.lib
    LIBS += F:\WORK\install\x64\vc14\lib\opencv_video320.lib
    LIBS += F:\WORK\install\x64\vc14\lib\opencv_videoio320.lib

    SOURCES += darknet.cpp
    main.cpp
    mainwindow.cpp
    player.cpp
    ../yolo-qt-master/src/art.c
    ../yolo-qt-master/src/yolo.c
    ../yolo-qt-master/src/convolutional_layer.c
    ../yolo-qt-master/src/writing.c
    ../yolo-qt-master/src/voxel.c
    ../yolo-qt-master/src/tag.c
    ../yolo-qt-master/src/swag.c
    ../yolo-qt-master/src/super.c
    ../yolo-qt-master/src/rnn_vid.c
    ../yolo-qt-master/src/rnn.c
    ../yolo-qt-master/src/nightmare.c
    ../yolo-qt-master/src/image.c
    ../yolo-qt-master/src/go.c
    ../yolo-qt-master/src/detector.c
    ../yolo-qt-master/src/darknet.c
    ../yolo-qt-master/src/coco.c
    ../yolo-qt-master/src/classifier.c
    ../yolo-qt-master/src/cifar.c
    ../yolo-qt-master/src/demo.c
    ../yolo-qt-master/src/activation_layer.c
    ../yolo-qt-master/src/activations.c
    ../yolo-qt-master/src/avgpool_layer.c
    ../yolo-qt-master/src/batchnorm_layer.c
    ../yolo-qt-master/src/blas.c
    ../yolo-qt-master/src/box.c
    ../yolo-qt-master/src/captcha.c
    ../yolo-qt-master/src/col2im.c
    ../yolo-qt-master/src/compare.c
    ../yolo-qt-master/src/connected_layer.c
    ../yolo-qt-master/src/cost_layer.c
    ../yolo-qt-master/src/cpu_gemm.c
    ../yolo-qt-master/src/crnn_layer.c
    ../yolo-qt-master/src/crop_layer.c
    ../yolo-qt-master/src/cuda.c
    ../yolo-qt-master/src/data.c
    ../yolo-qt-master/src/deconvolutional_layer.c
    ../yolo-qt-master/src/detection_layer.c
    ../yolo-qt-master/src/dice.c
    ../yolo-qt-master/src/dropout_layer.c
    ../yolo-qt-master/src/gemm.c
    ../yolo-qt-master/src/getopt.c
    ../yolo-qt-master/src/gettimeofday.c
    ../yolo-qt-master/src/gru_layer.c
    ../yolo-qt-master/src/im2col.c
    ../yolo-qt-master/src/layer.c
    ../yolo-qt-master/src/list.c
    ../yolo-qt-master/src/local_layer.c
    ../yolo-qt-master/src/matrix.c
    ../yolo-qt-master/src/maxpool_layer.c
    ../yolo-qt-master/src/network.c
    ../yolo-qt-master/src/normalization_layer.c
    ../yolo-qt-master/src/option_list.c
    ../yolo-qt-master/src/parser.c
    ../yolo-qt-master/src/region_layer.c
    ../yolo-qt-master/src/reorg_layer.c
    ../yolo-qt-master/src/rnn_layer.c
    ../yolo-qt-master/src/route_layer.c
    ../yolo-qt-master/src/shortcut_layer.c
    ../yolo-qt-master/src/softmax_layer.c
    ../yolo-qt-master/src/tree.c
    ../yolo-qt-master/src/utils.c

    FORMS +=
    mainwindow.ui

    HEADERS +=
    mainwindow.h
    player.h
    ../yolo-qt-master/src/activation_layer.h
    ../yolo-qt-master/src/activations.h
    ../yolo-qt-master/src/avgpool_layer.h
    ../yolo-qt-master/src/batchnorm_layer.h
    ../yolo-qt-master/src/blas.h
    ../yolo-qt-master/src/box.h
    ../yolo-qt-master/src/bugfixes.h
    ../yolo-qt-master/src/classifier.h
    ../yolo-qt-master/src/col2im.h
    ../yolo-qt-master/src/connected_layer.h
    ../yolo-qt-master/src/convolutional_layer.h
    ../yolo-qt-master/src/cost_layer.h
    ../yolo-qt-master/src/crnn_layer.h
    ../yolo-qt-master/src/crop_layer.h
    ../yolo-qt-master/src/cuda.h
    ../yolo-qt-master/src/data.h
    ../yolo-qt-master/src/deconvolutional_layer.h
    ../yolo-qt-master/src/demo.h
    ../yolo-qt-master/src/detection_layer.h
    ../yolo-qt-master/src/dropout_layer.h
    ../yolo-qt-master/src/gemm.h
    ../yolo-qt-master/src/gru_layer.h
    ../yolo-qt-master/src/im2col.h
    ../yolo-qt-master/src/image.h
    ../yolo-qt-master/src/layer.h
    ../yolo-qt-master/src/list.h
    ../yolo-qt-master/src/local_layer.h
    ../yolo-qt-master/src/matrix.h
    ../yolo-qt-master/src/maxpool_layer.h
    ../yolo-qt-master/src/network.h
    ../yolo-qt-master/src/normalization_layer.h
    ../yolo-qt-master/src/option_list.h
    ../yolo-qt-master/src/parser.h
    ../yolo-qt-master/src/region_layer.h
    ../yolo-qt-master/src/reorg_layer.h
    ../yolo-qt-master/src/rnn_layer.h
    ../yolo-qt-master/src/route_layer.h
    ../yolo-qt-master/src/shortcut_layer.h
    ../yolo-qt-master/src/softmax_layer.h
    ../yolo-qt-master/src/stb_image.h
    ../yolo-qt-master/src/stb_image_write.h
    ../yolo-qt-master/src/tree.h
    ../yolo-qt-master/src/utils.h
    3rdparty/include/pthread.h
    3rdparty/include/sched.h
    3rdparty/include/semaphore.h



  • i have also this problem
    C:\Qt\Qt5.9.4\Tools\QtCreator\bin\jom.exe -f Makefile.Release
    C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0/bin/nvcc.exe --use_fast_math -I"F:\WORK\install\include" -I"F:\my_work\yolo-qt-master\src" -I"F:\my_work\yolo-qt-object-detection-master\3rdparty\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0/include" F:\my_work\yolo-qt-object-detection-master\3rdparty\lib\x64\pthreadVC2.lib F:\WORK\install\x64\vc14\lib\opencv_core320.lib F:\WORK\install\x64\vc14\lib\opencv_highgui320.lib F:\WORK\install\x64\vc14\lib\opencv_imgcodecs320.lib F:\WORK\install\x64\vc14\lib\opencv_imgproc320.lib F:\WORK\install\x64\vc14\lib\opencv_objdetect320.lib F:\WORK\install\x64\vc14\lib\opencv_video320.lib F:\WORK\install\x64\vc14\lib\opencv_videoio320.lib -lcuda -lcudart -lcufft -lcublas --machine 64 -arch=sm_30 --compile -cudart static -DWIN32 -D_MBCS -Xcompiler /wd4819,/EHsc,/W3,/nologo,/O2,/Zi -Xcompiler /MD -c -o activation_kernels.o ..\activation_kernels.cu
    nvcc fatal : A single input file is required for a non-link phase when an outputfile is specified


  • Lifetime Qt Champion

    Did you just take all the files of the project and put them in your project ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.