Qt and OpenCV CUDA library integration -
i try use compiled cuda library on qt project. have project library generator , gui project on y first computer. both work fine.
when try compile same project on other computer crashs:
[thread debugging using libthread_db enabled] using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". program received signal sigsegv, segmentation fault. 0x00007fffef4e6b8c in ?? () /usr/lib/x86_64-linux-gnu/libqttest.so.4
here program:
template = lib config += console config -= qt config += no_plugin_name_prefix sources += \ config += link_pkgconfig pkgconfig += opencv includepath += /usr/local/include includepath += /usr/local/include/opencv libs += -l/usr/local/lib libs += -l/usr/lib/x86_64-linux-gnu libs += -l/usr/local/share/opencv/3rdparty/lib libs += -lm libs += -lopencv_core libs += -lopencv_imgproc libs += -lopencv_highgui libs += -lopencv_objdetect libs += -lopencv_calib3d libs += -lgl -lglu -lx11 -lglut -lglew -lpthread # cuda settings <-- may change depending on system cuda_sources += ./cuda/resizer.cu cuda_sdk = /usr/lib/nvidia-cuda-toolkit #/usr/include/ # path cuda sdk install cuda_dir = /usr/lib/nvidia-cuda-toolkit # path cuda toolkit install # not edit beyond unless know doing.... system_name = unix # depending on system either 'win32', 'x64', or 'win64' system_type = 64 # '32' or '64', depending on system cuda_arch = sm_52 # type of cuda architecture, example 'compute_10', 'compute_11', 'sm_10' nvcc_options = #--use_fast_math # include paths includepath += $$cuda_dir/include includepath += $$cuda_dir/ # library directories qmake_libdir += /usr/lib/x86_64-linux-gnu#/usr/lib/nvidia-cuda-toolkit/lib #/usr/lib/i386-linux-gnu #$cuda_dir/lib/ cuda_objects_dir = ./ # add necessary libraries cuda_libs = -lcuda -lcudart -lnppi -lnpps # following makes sure path names (which include spaces) put between quotation marks cuda_inc = $$join(includepath,'" -i"','-i"','"') libs += -l /usr/lib/x86_64-linux-gnu -lcuda -lcudart -lnppi -lnpps nvcc_libs = -lgl -lglu -lx11 -lglut -lglew # release mode cuda.input = cuda_sources cuda.output = $$cuda_objects_dir/${qmake_file_base}_cuda.o cuda.commands = $$cuda_dir/bin/nvcc -xcompiler="-fpic" -shared -dc $$nvcc_options $$cuda_inc $$nvcc_libs --machine $$system_type -gencode arch=compute_50,code=compute_50 -gencode arch=compute_52,code=compute_52 -c -o ${qmake_file_out} ${qmake_file_name} cuda.dependency_type = type_c qmake_extra_compilers += cuda cuda_sources_link = blending_cuda.o cudalink.input = cuda_sources_link cudalink.output = $$cuda_objects_dir/${target}_cuda.o cudalink.commands = $$cuda_dir/bin/nvcc -xcompiler="-fpic" -shared -ccbin g++ -dlink $$nvcc_options $$cuda_inc $$nvcc_libs --machine $$system_type -gencode arch=compute_50,code=compute_50 -gencode arch=compute_52,code=compute_52 resizer_cuda.o -o ${target}_cuda.o qmake_extra_compilers += cudalink headers += \ cuda/resizer.h \ version = 1.3.5 # major.minor.patch
here use of library in qt project:
#------------------------------------------------- # project created qtcreator 2017-02-27t11:16:54 #------------------------------------------------- qt += core gui qt += widgets target = gui template = app sources += src/main.cpp headers += \ include/main.h \ distfiles += config += link_pkgconfig pkgconfig += opencv includepath += /usr/local/include includepath += /usr/local/include/opencv includepath += $$pwd/../../.release/libmylivrarycuda/include libs += -l/usr/local/lib libs += -l/usr/lib/x86_64-linux-gnu libs += -l/usr/local/share/opencv/3rdparty/lib libs += -lm libs += -lopencv_core libs += -lopencv_imgproc libs += -lopencv_highgui libs += -lopencv_objdetect libs += -lopencv_calib3d libs += -lgl -lglu -lx11 -lglut -lglew -lpthread libs += -l /usr/lib/x86_64-linux-gnu -lcuda -lcudart libs += -l/lib libs += -lmylivrarycuda
and main file:
#include <qapplication> #include "cuda/resizer.h" int main(int argc, char *argv[]) { qapplication a(argc, argv); mainwindow w; w.show(); gpu::resizer *p = new gpu::resizer(640,480,gpu::resizer::downsampling,gpu::resizer::gray,2); // ligne error return a.exec(); }
when comment line gpu::resizer *p ...
program works when use line there segmentation fault. when use gpu::resizer
without qt sdk works fine when both mixed there problem on second computer.
Comments
Post a Comment