I am trying to compile a Qt project that uses ITK but I am receiving linker errors (see below) from the ITK libraries. I am running on Ubuntu 16.04 and building with Qt 5.9.1. I compiled the ITK version 4.12.1 but I have also tried 4.13 as well as a pre-built version of 4.12.2 from a colleague. I have tried compiling with CMake 3.5 and later with CMake 3.10 but I get the same errors for all of these combinations.
I have generated the list of libraries that I include in my Qt project using the command lorder * | tsort while in the lib folder of the ITK build. This should generate the correct order of include libraries right?
The compiler is complaining about not finding vnl_vector, but I checked the list of linked libraries and -litkvnl as well as -litkvnl_algo are in there and above -lITKCommon which seems to be the problem.
Below I have provided the compile errors as well as the .pri file in which I link to the libraries. Any help would be greatly appreciated!
Error message:
//usr/local/lib/libITKCommon-4.12.a(itkMetaDataObject.cxx.o): In function `itk::MetaDataObject<itk::Array<char> >::~MetaDataObject()':
itkMetaDataObject.cxx:(.text._ZN3itk14MetaDataObjectINS_5ArrayIcEEED2Ev[_ZN3itk14MetaDataObjectINS_5ArrayIcEEED5Ev]+0x2a): undefined reference to `vnl_vector<char>::~vnl_vector()'
//usr/local/lib/libITKCommon-4.12.a(itkMetaDataObject.cxx.o): In function `itk::MetaDataObject<itk::Array<int> >::~MetaDataObject()':
itkMetaDataObject.cxx:(.text._ZN3itk14MetaDataObjectINS_5ArrayIiEEED2Ev[_ZN3itk14MetaDataObjectINS_5ArrayIiEEED5Ev]+0x2a): undefined reference to `vnl_vector<int>::~vnl_vector()'
Makefile:249: recipe for target 'mesh2binary' failed
//usr/local/lib/libITKCommon-4.12.a(itkMetaDataObject.cxx.o): In function `itk::MetaDataObject<itk::Array<float> >::~MetaDataObject()':
itkMetaDataObject.cxx:(.text._ZN3itk14MetaDataObjectINS_5ArrayIfEEED2Ev[_ZN3itk14MetaDataObjectINS_5ArrayIfEEED5Ev]+0x2a): undefined reference to `vnl_vector<float>::~vnl_vector()'
//usr/local/lib/libITKCommon-4.12.a(itkMetaDataObject.cxx.o): In function `itk::MetaDataObject<itk::Array<char> >::SetMetaDataObjectValue(itk::Array<char> const&)':
itkMetaDataObject.cxx:(.text._ZN3itk14MetaDataObjectINS_5ArrayIcEEE22SetMetaDataObjectValueERKS2_[_ZN3itk14MetaDataObjectINS_5ArrayIcEEE22SetMetaDataObjectValueERKS2_]+0x26): undefined reference to `vnl_vector<char>::set_size(unsigned long)'
itkMetaDataObject.cxx:(.text._ZN3itk14MetaDataObjectINS_5ArrayIcEEE22SetMetaDataObjectValueERKS2_[_ZN3itk14MetaDataObjectINS_5ArrayIcEEE22SetMetaDataObjectValueERKS2_]+0x39): undefined reference to `vnl_vector<char>::operator=(vnl_vector<char> const&)'
//usr/local/lib/libITKCommon-4.12.a(itkMetaDataObject.cxx.o): In function `itk::MetaDataObject<itk::Array<int> >::SetMetaDataObjectValue(itk::Array<int> const&)':
itkMetaDataObject.cxx:(.text._ZN3itk14MetaDataObjectINS_5ArrayIiEEE22SetMetaDataObjectValueERKS2_[_ZN3itk14MetaDataObjectINS_5ArrayIiEEE22SetMetaDataObjectValueERKS2_]+0x26): undefined reference to `vnl_vector<int>::set_size(unsigned long)'
itkMetaDataObject.cxx:(.text._ZN3itk14MetaDataObjectINS_5ArrayIiEEE22SetMetaDataObjectValueERKS2_[_ZN3itk14MetaDataObjectINS_5ArrayIiEEE22SetMetaDataObjectValueERKS2_]+0x39): undefined reference to `vnl_vector<int>::operator=(vnl_vector<int> const&)'
//usr/local/lib/libITKCommon-4.12.a(itkMetaDataObject.cxx.o): In function `itk::MetaDataObject<itk::Array<float> >::SetMetaDataObjectValue(itk::Array<float> const&)':
itkMetaDataObject.cxx:(.text._ZN3itk14MetaDataObjectINS_5ArrayIfEEE22SetMetaDataObjectValueERKS2_[_ZN3itk14MetaDataObjectINS_5ArrayIfEEE22SetMetaDataObjectValueERKS2_]+0x26): undefined reference to `vnl_vector<float>::set_size(unsigned long)'
itkMetaDataObject.cxx:(.text._ZN3itk14MetaDataObjectINS_5ArrayIfEEE22SetMetaDataObjectValueERKS2_[_ZN3itk14MetaDataObjectINS_5ArrayIfEEE22SetMetaDataObjectValueERKS2_]+0x39): undefined reference to `vnl_vector<float>::operator=(vnl_vector<float> const&)'
collect2: error: ld returned 1 exit status
make: *** [mesh2binary] Error 1
11:24:11: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project mesh2binary (kit: Desktop Qt 5.9.1 GCC 64bit2)
When executing step "Make"
.pri file which I include in my .pro file:
ITKDIR=/usr/local/ITK/InsightToolkit-4.12.1-Release/include/ITK-4.12
ITKLIB=/usr/local/ITK/InsightToolkit-4.12.1-Release/build/lib
VERSIONNUMBER=4.12
#Include ITK Headers
INCLUDEPATH += $${ITKDIR}
# ITK Libs
LIBS += -L$${ITKLIB} -lITKBiasCorrection-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKBioCell-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKDICOMParser-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKFEM-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOBMP-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOBioRad-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOCSV-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOGDCM-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOGE-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOGIPL-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOHDF5-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOJPEG-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOLSM-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOMRC-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOMesh-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOMeta-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIONIFTI-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIONRRD-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOPNG-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOSiemens-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOSpatialObjects-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOStimulate-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOTransformBase-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOTransformHDF5-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOTransformInsightLegacy-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOTransformMatlab-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOVTK-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKKLMRegionGrowing-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKLabelMap-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKMesh-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKOptimizers-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKOptimizersv4-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKPath-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKPolynomials-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKQuadEdgeMesh-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKSpatialObjects-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKStatistics-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKTransform-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKVNLInstantiation-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKVTK-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKVideoCore-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKVideoIO-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKWatersheds-$${VERSIONNUMBER}
#LIBS += -L$${ITKLIB} -lhdf5
LIBS += -L$${ITKLIB} -litkgdcmMEXD-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litknetlib-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litktestlib-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOTIFF-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKgiftiio-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKMetaIO-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKNrrdIO-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litkpng-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOIPL-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOXML-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKTransformFactory-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litkhdf5_cpp
LIBS += -L$${ITKLIB} -litkNetlibSlatec-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litkvnl_algo-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litkgdcmMSFF-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litkgdcmsocketxx-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litktiff-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKniftiio-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKIOImageBase-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litkhdf5
LIBS += -L$${ITKLIB} -litkvnl-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litkv3p_netlib-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litkgdcmDICT-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litkgdcmcharls-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litkgdcmuuid-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litkgdcmopenjpeg-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litkgdcmjpeg8-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litkgdcmjpeg16-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litkgdcmjpeg12-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litkjpeg-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKznz-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKCommon-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litkvcl-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litkgdcmIOD-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litksys-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litkdouble-conversion-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litkgdcmDSED-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -lITKEXPAT-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litkgdcmCommon-$${VERSIONNUMBER}
LIBS += -L$${ITKLIB} -litkzlib-$${VERSIONNUMBER}
I would suggest you to convert your project's build system into CMake. I do not advice build ITK with any other system than CMake. Since 2.8.10 it is quite stable, and if you even have a current version, there should be no problems.
Your CMakeLists.txt file would probably look similiar to this:
cmake_minimum_required(VERSION 3.1)
set (CMAKE_CXX_STANDARD 11)
project(HelloWorldItkQt)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc and uic automatically when needed.
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
# Find the Qt libraries
find_package(Qt5Gui)
find_package(Qt5Widgets)
find_package(Qt5Core)
#find and enable ITK
find_package(ITK)
include(${ITK_USE_FILE})
# Tell CMake to create the helloworld executable
add_executable(HelloWorldItkQt WIN32 mainwindow.h simpledialog.h mainwindow.cpp simpledialog.cpp main.cpp)
# Use the Widgets module from Qt 5.
target_link_libraries(HelloWorldItkQt Qt5::Widgets Qt5::Gui Qt5::Core ${ITK_LIBRARIES})
Here you will find some more information:
Qt5 and Cmake manual
Similar SO problem
Related
I'm trying to build gRPC library with Windows 10 with QT. Im using QT creator 5.15.2 MSVC 2019 compiler kit. I installed protobuf and grpc using vcpkg. I can able to successfully test protobuf libraries. But failing to do so with gRPC.
Getting the following error.
grpc.lib(check_gcp_environment_windows.cc.obj):-1: error: LNK2019: unresolved external symbol imp_RegGetValueA referenced in function "bool cdecl grpc_core::internal::check_windows_registry_product_name(struct HKEY *,char const *,char const *)" (?check_windows_registry_product_name#internal#grpc_core##YA_NPEAUHKEY##PEBD1#Z)
I have tried linking the libraries one by one in QT like below. Attached my .pro file here
QT -= gui
CONFIG += c++17 console
CONFIG -= app_bundle
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/zlibd.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/abseil_dll.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_cord_internal.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_cordz_functions.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_cordz_handle.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_cordz_info.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_cordz_sample_token.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_commandlineflag.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_commandlineflag_internal.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_config.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_internal.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_marshalling.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_parse.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_private_handle_accessor.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_program_name.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_reflection.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_usage.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_flags_usage_internal.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_low_level_hash.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_random_internal_distribution_test_util.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_statusor.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/absl_strerror.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/address_sorting.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/cares.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/descriptor_upb_proto.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/gpr.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/grpc.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/grpc_plugin_support.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/grpc_unsecure.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/grpc++.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/grpc++_alts.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/grpc++_error_details.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/grpc++_reflection.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/grpc++_unsecure.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/grpcpp_channelz.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/libcrypto.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/libprotobufd.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/libprotobuf-lited.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/libprotocd.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/libssl.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/re2.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/upb.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/upb_collections.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/upb_extension_registry.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/upb_fastdecode.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/upb_json.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/upb_mini_table.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/upb_reflection.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/upb_textformat.lib
LIBS += C:/vcpkg/installed/x64-windows/debug/lib/upb_utf8_range.lib
INCLUDEPATH += C:\vcpkg\installed\x64-windows\include
HEADERS += \
helloworld.grpc.pb.h \
helloworld.pb.h
SOURCES += \
main.cpp \
helloworld.grpc.pb.cc \
helloworld.pb.cc
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
There were few errors w.r.2 ws2_32 lib. which I have neglected using the following pragma statement.
#pragma comment(lib, "Ws2_32.lib")
But the error LNK2019: unresolved external symbol __imp_RegGetValueA referenced in function . I couldnt find any. I believe its something related to re2.lib linked. Kindly add your thoughts. Thanks
I am trying to link liblas library to Qt.I am using following code in .pro file to link it.
//////////////code to link liblas to Qt/////////////////////////////////
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../OSGeo4W/lib/ -lliblas
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../OSGeo4W/lib/ -lliblas
else:unix: LIBS += -L$$PWD/../../../../OSGeo4W/lib/ -lliblas
INCLUDEPATH += $$PWD/../../../../OSGeo4W/include
DEPENDPATH += $$PWD/../../../../OSGeo4W/include
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../OSGeo4W/lib/ -llaszip
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../OSGeo4W/lib/ -llaszipd
else:unix: LIBS += -L$$PWD/../../../../OSGeo4W/lib/ -llaszip
INCLUDEPATH += $$PWD/../../../../OSGeo4W/include
DEPENDPATH += $$PWD/../../../../OSGeo4W/include
///////////////////////////////////////////////////////////////
and when i am running the code given below, I am getting undefined reference error
ifstream stream;
stream.open("lidar_sample.las", std::ios::in | std::ios::binary);
ReaderFactory f;
Reader reader = f.CreateWithStream(stream);
error: undefined reference to `liblas::ReaderFactory::CreateWithStream(std::istream&)'
only two possible answers here.
your liblas is not found by the linker
your liblas is not
the same version as your headers.
I have included the headers in Qt for my project, but the compiler is still not able to identify the headers. Libraries once included created its own includepath and depend.
Any help appriciated:
`INCLUDEPATH += $$PWD/../HDE/x86.linux/include
DEPENDPATH += $$PWD/../HDE/x86.linux/include
unix:!macx: LIBS += -L$$PWD/../HDE/x86.linux/lib/ -lddskernel
INCLUDEPATH += $$PWD/../HDE/x86.linux/include
DEPENDPATH += $$PWD/../HDE/x86.linux/include
unix:!macx: LIBS += -L$$PWD/../HDE/x86.linux/examples/dcps/Tutorial/cpp/standalone/ -lsacpp_tutorial_types
INCLUDEPATH += $$PWD/../HDE/x86.linux/examples/dcps/Tutorial/cpp/standalone
DEPENDPATH += $$PWD/../HDE/x86.linux/examples/dcps/Tutorial/cpp/standalone
unix:!macx: LIBS += -L$$PWD/../../../usr/lib/i386-linux-gnu/ -lpthread
INCLUDEPATH += $$PWD/../../../usr/lib/i386-linux-gnu
DEPENDPATH += $$PWD/../../../usr/lib/i386-linux-gnu`
All you have to do is also include the path for the header files in .pro file.
for instance if the header file is at location /home/jack/Myproject
then just write the below in the .pro file
INCLUDEPATH +=$$PWD/../Myproject
I have compiled OpenCV 2.4.10 to work with Qt 5.4 mingw for 64 bits. When I compile the most basic example of loading a picture it gives the following error:
exited with code -1073741515
Does anyone knows what this means and how I could fix it?
QT += core
QT += gui
TEMPLATE = app
CONFIG += console
CONFIG -= app_bundle
CONFIG -= qt
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += C://opencv2_build//install//include
LIBS += C://opencv2_build//bin//*.dll
The error code means "Dependency missing". A working configuration for OpenCV in QT should looks like this:
LIBS += -LC:\\Programs\\opencv24\\opencv_bin2\\bin \
libopencv_core240d \
libopencv_highgui240d \
libopencv_imgproc240d \
libopencv_features2d240d \
libopencv_calib3d240d \
Source: here
Looks like an error where you're not linking with OpenCV correctly. This is an example of how you can link your application correctly (put it in your .pro file):
win32 {
OPENCV_LIB_DIR = $$PWD/libs/opencv/Windows
INCLUDEPATH += $$PWD/include/opencv/Windows
}
linux {
OPENCV_LIB_DIR = $$PWD/libs/opencv/Linux
INCLUDEPATH += $$PWD/include/opencv/Linux
LIBS += -L$$OPENCV_LIB_DIR
}
message(OpenCV Library directory: $$OPENCV_LIB_DIR)
LIBS += -L$$OPENCV_LIB_DIR
win32 {
LIBS += -lopencv_core248
LIBS += -lopencv_calib3d248
LIBS += -lopencv_contrib248
LIBS += -lopencv_features2d248
LIBS += -lopencv_flann248
LIBS += -lopencv_gpu248
LIBS += -lopencv_highgui248
LIBS += -lopencv_imgproc248
LIBS += -lopencv_legacy248
LIBS += -lopencv_ml248
LIBS += -lopencv_nonfree248
LIBS += -lopencv_objdetect248
LIBS += -lopencv_ocl248
LIBS += -lopencv_photo248
LIBS += -lopencv_stitching248
LIBS += -lopencv_superres248
LIBS += -lopencv_video248
LIBS += -lopencv_videostab248
}
linux {
LIBS += -lopencv_core
LIBS += -lopencv_calib3d
LIBS += -lopencv_contrib
LIBS += -lopencv_cuda
LIBS += -lopencv_cudaarithm
LIBS += -lopencv_cudabgsegm
LIBS += -lopencv_cudacodec
LIBS += -lopencv_cudafeatures2d
LIBS += -lopencv_cudafilters
LIBS += -lopencv_cudaimgproc
LIBS += -lopencv_cudaoptflow
LIBS += -lopencv_cudastereo
LIBS += -lopencv_cudawarping
LIBS += -lopencv_features2d
LIBS += -lopencv_flann
LIBS += -lopencv_highgui
LIBS += -lopencv_imgproc
LIBS += -lopencv_legacy
LIBS += -lopencv_ml
LIBS += -lopencv_nonfree
LIBS += -lopencv_objdetect
LIBS += -lopencv_optim
LIBS += -lopencv_photo
LIBS += -lopencv_shape
LIBS += -lopencv_softcascade
LIBS += -lopencv_stitching
LIBS += -lopencv_superres
LIBS += -lopencv_ts
LIBS += -lopencv_video
LIBS += -lopencv_videostab
}
Notice that I use the -L flag to tell what the library folder is, and then the -l flag against each DLL (Windows) or .so (Linux). You have a few different options in regards to how you actually want to link the library, but this method works for me. Hope this helps!
I'm trying to add jasoncpp library to my C++ qt project.
I included the header, and linked (I think) the library but I get these errors:
"symbol(s) not found for architecture x86_64" and "linker command failed with exit code 1 (use -v to see invocation)".
The symbols not found are obviously the ones concerning jsoncpp library.
This is my makefile:
QT += core gui webkitwidgets
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = JsonTest
TEMPLATE = app
SOURCES += main.cpp\
mainwindow.cpp
HEADERS += mainwindow.h
FORMS += mainwindow.ui
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../../../usr/local/Cellar/jsoncpp/0.5.0/lib/release/ -ljson
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../../../usr/local/Cellar/jsoncpp/0.5.0/lib/debug/ -ljson
else:unix: LIBS += -L$$PWD/../../../../../../../usr/local/Cellar/jsoncpp/0.5.0/lib/ -ljson
INCLUDEPATH += $$PWD/../../../../../../../usr/local/Cellar/jsoncpp/0.5.0/include
DEPENDPATH += $$PWD/../../../../../../../usr/local/Cellar/jsoncpp/0.5.0/include
I really don't know how to proceed so thanks in advance.
If you installed it using cmake, try this commands:
mkdir -p build/debug
cd build/debug
cmake -DCMAKE_BUILD_TYPE=debug -DJSONCPP_LIB_BUILD_STATIC=ON -DJSONCPP_LIB_BUILD_SHARED=OFF -G "Unix Makefiles" ../..
make
change
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../../../usr/local/Cellar/jsoncpp/0.5.0/lib/release/ -ljson
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../../../usr/local/Cellar/jsoncpp/0.5.0/lib/debug/ -ljson
else:unix: LIBS += -L$$PWD/../../../../../../../usr/local/Cellar/jsoncpp/0.5.0/lib/ -ljson
INCLUDEPATH += $$PWD/../../../../../../../usr/local/Cellar/jsoncpp/0.5.0/include
DEPENDPATH += $$PWD/../../../../../../../usr/local/Cellar/jsoncpp/0.5.0/include
for this:
unix|win32: LIBS += -ljsoncpp
and ready to use jsoncpp