How to convert a cmake into a qmake? - qt
I'm fairly new in the Cmake and I'm using it to run SimpleITK with the Qt Creator, but I need to insert a code that I wrote with SimpleITK into another code that has already run with qmake. Therefore I have to convert it. Here is the cmakelist:
cmake_minimum_required(VERSION 3.10)
project(Registration_ITK_CMAKE)
set(ITK_DIR "/home/felippe/SimpleITK-build/ITK-prefix/lib/cmake/ITK/")
find_package(SimpleITK REQUIRED)
#set(CMAKE_PREFIX_PATH "/home/felippe/SimpleITK-build/ITK-prefix/")
add_executable(${PROJECT_NAME} "main.cpp")
target_link_libraries ( Registration_ITK_CMAKE ${SimpleITK_LIBRARIES} )
It's important to say that the SimpleITK needs some libraries of the ITK, so I've already tried to include all the .lib files of the ITK and SimpleITK but I've got a huge number of 'undefined reference to ...' returned by the compiler. Here is my .pro:
TEMPLATE = app
CONFIG += console c++11 static
CONFIG -= app_bundle
CONFIG -= qt
INCLUDEPATH += /home/felippe/SimpleITK-build/include/SimpleITK-1.3
INCLUDEPATH += /home/felippe/SimpleITK-build/ITK-prefix/include/ITK-4.13
#SimpleITK LIB files
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libgtest.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITKBasicFilters0-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITKCommon-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITKBasicFilters1-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITKExplicit-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITKIO-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKAnisotropicSmoothing-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKAntiAlias-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKBiasCorrection-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKBinaryMathematicalMorphology-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKClassifiers-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKColormap-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKCommon-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKConnectedComponents-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKConvolution-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKCurvatureFlow-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKDeconvolution-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKDenoising-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKDisplacementField-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKDistanceMap-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKFastMarching-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKFFT-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKImageCompare-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKImageCompose-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKImageFeature-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKImageFilterBase-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKImageFunction-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKImageFusion-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKImageGradient-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKImageGrid-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKImageIntensity-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKImageLabel-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKImageNoise-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKImageSources-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKImageStatistics-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKLabelMap-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKLabelVoting-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKLevelSets-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKMathematicalMorphology-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKPDEDeformableRegistration-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKRegionGrowing-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKRegistrationCommon-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKReview-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKSmoothing-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKThresholding-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKTransform-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_ITKWatersheds-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITKRegistration-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITK_SimpleITKFilters-1.3.a"
LIBS += "/home/felippe/SimpleITK-build/SimpleITK-build/lib/libSimpleITKUnitTestBase.a"
#ITK Lib Files
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKDICOMParser-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKEXPAT-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKFEM-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkgdcmcharls-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkgdcmDICT-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkgdcmDSED-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkgdcmjpeg8-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkgdcmjpeg12-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkgdcmjpeg16-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkgdcmMEXD-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkgdcmMSFF-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkgdcmopenjp2-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkgdcmsocketxx-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkgdcmuuid-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKgiftiio-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkhdf5.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkhdf5_cpp.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOBMP-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOBruker-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOCSV-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOGE-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOGIPL-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOHDF5-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOIPL-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOLSM-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOMesh-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOMeta-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOMRC-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIONRRD-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOPNG-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOSiemens-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOStimulate-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOTIFF-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOTransformHDF5-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOTransformMatlab-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOJPEG-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOMINC-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkjpeg-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKLabelMap-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitklbfgs-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkminc2-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitknetlib-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkNetlibSlatec-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKniftiio-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKNrrdIO-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkopenjpeg-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKOptimizers-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKBioCell-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKOptimizersv4-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkpng-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKQuadEdgeMesh-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKStatistics-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitktiff-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkv3p_netlib-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkvcl-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKVideoCore-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKVideoIO-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkvnl_algo-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKznz-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKBiasCorrection-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKWatersheds-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOTransformInsightLegacy-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkzlib-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKMesh-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKMetaIO-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKPolynomials-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKTransformFactory-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIONIFTI-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKVTK-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKKLMRegionGrowing-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOTransformBase-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitktestlib-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKReview-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKPath-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkdouble-conversion-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKTransform-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKSpatialObjects-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkgdcmCommon-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkvnl-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-build/lib/libITKVNLInstantiation-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOGDCM-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKCommon-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitksys-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-build/lib/libITKIOImageBase-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libitkgdcmIOD-4.13.a"
LIBS += "/home/felippe/SimpleITK-build/ITK-prefix/lib/libITKIOXML-4.13.a"
LIBS += -lpthread
SOURCES += \
main.cpp
So how to solve this?
Thanks.
Related
How to import a c++ lib(x64) using QT creator 7 in windows 10
I follow the steps https://www.youtube.com/watch?v=jZ4NAHHr41I to add a prebuild(vs 2015) dynamic lib BuildTestLib.lib using qt creator 7 I can use class(member variable) and variable in BuildTestLib.h, but got build error when I called any function. ui->pushButton->setText("test"); //enum from BuildTestLib.lib RAD_WMK_ERROR error; // class from BuildTestLib.lib CBuildTestLib *handle; // function from BuildTestLib.lib //handle = CreatInstance(RAD_I2C, VENDOR_QUALCOMM, &error); // function from BuildTestLib.lib uint64_t test = fnBuildTestLib(); for (int i = 0; i < 256; i++) { for (int j = 0; j < 15; j++) { handle->gamma_data_10bit[i * 15 + j] = j + (i%10)*100; } } for (int i = 0; i < 4320; i++) { for (int j = 0; j < 16; j++) { handle->position_data_8bit[i * 16 + j] = j + (i % 10) * 16; } } // a member function of CBuildTestLib from BuildTestLib.lib //handle->dbg_save_all_data(); :-1: error: release/mainwindow.o:mainwindow.cpp:(.text+0x220): undefined reference to `__imp__Z14fnBuildTestLibv' :-1: error: collect2.exe: error: ld returned 1 exit status did I miss something? any suggestion? thx Note: this lib has been checked by vs 2015 c++ console application, and it works. win32: LIBS += -L'D:/Kevin.Lai/vs2015/BuildTestLib/x64/Release/' -lBuildTestLib INCLUDEPATH += 'D:/Kevin.Lai/vs2015/BuildTestLib/BuildTestLib' DEPENDPATH += 'D:/Kevin.Lai/vs2015/BuildTestLib/BuildTestLib' hope this information helps
I solved it by putting the lib, header, and the DLL in the same folder. Set win32: LIBS += -L'D:/Kevin.Lai/vs2015/BuildTestLib/x64/Release/' -lBuildTestLib INCLUDEPATH += 'D:/Kevin.Lai/vs2015/BuildTestLib/x64/Release' DEPENDPATH += 'D:/Kevin.Lai/vs2015/BuildTestLib/x64/Release' That’s really odd.
underfined to symbol 'XGetWindowAttributes'
When I used vtk in qt creator firstly, I came into this trouble. And I cannot solve it now, asking for some help. I followed this website https://csuzhangxc.gitbooks.io/vtk-simple-tutorial/content/getting_started/the_first.html but I got this: error: /usr/local/lib//libvtkRenderingOpenGL2-8.2.a(vtkXRenderWindowInteractor.cxx.o): undefined reference to symbol 'XGetWindowAttributes' /usr/lib/x86_64-linux-gnu/libX11.so.6:-1: error: error adding symbols: DSO missing from command line Somebody know what to do? Some file of the project are following: .pro: QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 DEFINES += QT_DEPRECATED_WARNINGS INCLUDEPATH += /usr/local/include/vtk-8.2/ LIBS += -L/usr/local/lib/ \ -lvtkGUISupportQt-8.2 \ -lvtkIOImage-8.2 \ -lvtkInteractionImage-8.2 \ -lvtkRenderingCore-8.2 \ -lvtkCommonExecutionModel-8.2 \ -lvtkCommonCore-8.2 \ -lvtkRenderingOpenGL2-8.2 \ -lvtkInteractionStyle-8.2 \ SOURCES += \ main.cpp \ mainwindow.cpp HEADERS += \ mainwindow.h FORMS += \ mainwindow.ui # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target main.cpp: #include "mainwindow.h" #include <QApplication> #include<vtkAutoInit.h> VTK_MODULE_INIT(vtkRenderingOpenGL2) VTK_MODULE_INIT(vtkInteractionStyle) #include "vtkImageViewer.h" #include "vtkRenderWindowInteractor.h" #include "vtkRenderer.h" #include "vtkPNGReader.h" #include "QVTKWidget.h" #include "vtkImageData.h" #include "vtkActor.h" int main(int argc, char *argv[]) { QApplication a(argc, argv); QVTKWidget widget; char filename[] = "/home/bichongke/Downloads/dinosaur.png"; vtkPNGReader* reader =vtkPNGReader::New(); reader->SetFileName(filename); reader->Update(); vtkImageViewer* imageView = vtkImageViewer::New(); imageView->SetInputConnection(reader->GetOutputPort()); widget.SetRenderWindow(imageView->GetRenderWindow()); imageView->SetupInteractor(widget.GetRenderWindow()->GetInteractor()); imageView->SetColorLevel(138.5); imageView->SetColorWindow(233); int* dims = reader->GetOutput()->GetDimensions(); widget.resize(dims[0],dims[1]); widget.show(); a.exec(); imageView->Delete(); reader->Delete(); return 0; //MainWindow w; //w.show(); //return a.exec(); }
snmp implementation in Qt in Ubuntu
Iam using Ubuntu 16.04 in which i have installed Qtcreator. I would like to work on SNMP. for this i have already installed net-snmp as well as mibs downloader. I have taken example code from net-snmp (snmpdemoapp.c) and tried implementing same in qt. #include "mainwindow.h" #include <QApplication> #include <string.h> #include <cstring> #include <net-snmp/net-snmp-config.h> #include <net-snmp/net-snmp-includes.h> #include <net-snmp/agent/net-snmp-agent-includes.h> //using namespace std; #define DEMO_USE_SNMP_VERSION_3 #ifdef DEMO_USE_SNMP_VERSION_3 const char *our_v3_passphase="The Net SNMP Pass Phrase"; #endif int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; //*******************SNMP Code starts from here netsnmp_session session,*ss; netsnmp_pdu *pdu; netsnmp_pdu *response; oid anOID[MAX_OID_LEN]; size_t anOID_len; netsnmp_variable_list *vars; int status; int count=1; //initialize the snmp library init_snmp("snmpdemoapp"); //SnmpGet //initialize the session that defines who we are going to talk to snmp_sess_init(&session); session.peername="test.net-snmp.org"; //set up the authentication parameters for talking to server #ifdef DEMO_USE_SNMP_VERSION_3 //if snmp version3 session.version=SNMP_VERSION_3; //set the SNMP v3 user name session.securityName=strdup("MD5User"); session.securityNameLen=strlen(session.securityName); //snmp security session.securityLevel=SNMP_SEC_LEVEL_AUTHNOPRIV; session.securityAuthProto=usmHMACMD5AuthProtocol; session.securityAuthProtoLen=sizeof(usmHMACMD5AuthProtocol)/sizeof(oid); session.securityAuthKeyLen=USM_AUTH_KU_LEN; /* set the authentication key to a MD5 hashed version of our passphrase "The UCD Demo Password" (which must be at least 8 characters long) */ if(generate_Ku(session.securityAuthProto,session.securityAuthProtoLen,(uchar *)our_v3_passphase, strlen(our_v3_passphase),session.securityAuthKey,&session.securityAuthKeyLen)!=SNMPERR_SUCCESS) { snmp_perror(argv[0]); snmp_log(LOG_ERR,"Error generating Ku from authentication pass phrase. \n"); exit(1); } #else //if snmp version is snmp v1 session.version=SNMP_VERSION_1; /* set the SNMPv1 community name used for authentication */ session.community="demopublic"; session.community_len=strlen(session.community); #endif SOCK_STARTUP; ss = snmp_open(&session); /* establish the session */ if (!ss) { snmp_sess_perror("ack", &session); SOCK_CLEANUP; exit(1); } /* * Create the PDU for the data for our request. * 1) We're going to GET the system.sysDescr.0 node. */ pdu = snmp_pdu_create(SNMP_MSG_GET); anOID_len = MAX_OID_LEN; if (!snmp_parse_oid(".1.3.6.1.2.1.1.1.0", anOID, &anOID_len)) { snmp_perror(".1.3.6.1.2.1.1.1.0"); SOCK_CLEANUP; exit(1); } #if OTHER_METHODS /* * These are alternatives to the 'snmp_parse_oid' call above, * e.g. specifying the OID by name rather than numerically. */ read_objid(".1.3.6.1.2.1.1.1.0", anOID, &anOID_len); get_node("sysDescr.0", anOID, &anOID_len); read_objid("system.sysDescr.0", anOID, &anOID_len); #endif snmp_add_null_var(pdu, anOID, anOID_len); /* * Send the Request out. */ status = snmp_synch_response(ss, pdu, &response); /* * Process the response. */ if (status == STAT_SUCCESS && response->errstat == SNMP_ERR_NOERROR) { /* * SUCCESS: Print the result variables */ for(vars = response->variables; vars; vars = vars->next_variable) print_variable(vars->name, vars->name_length, vars); /* manipuate the information ourselves */ for(vars = response->variables; vars; vars = vars->next_variable) { if (vars->type == ASN_OCTET_STR) { char *sp = (char *)malloc(1 + vars->val_len); memcpy(sp, vars->val.string, vars->val_len); sp[vars->val_len] = '\0'; printf("value #%d is a string: %s\n", count++, sp); free(sp); } else printf("value #%d is NOT a string! Ack!\n", count++); } } else { /* * FAILURE: print what went wrong! */ if (status == STAT_SUCCESS) fprintf(stderr, "Error in packet\nReason: %s\n", snmp_errstring(response->errstat)); else if (status == STAT_TIMEOUT) fprintf(stderr, "Timeout: No response from %s.\n", session.peername); else snmp_sess_perror("snmpdemoapp", ss); } /* * Clean up: * 1) free the response. * 2) close the session. */ if (response) snmp_free_pdu(response); snmp_close(ss); SOCK_CLEANUP; //*************************SNMP code ends here w.show(); return a.exec(); } when iam building the program, iam getting errors s below: main.o: In function `main': /home/srinivas/QT_Projects/build-SNMP_Demo_Example-Desktop_Qt_5_7_0_GCC_64bit-Debug/../SNMP_Demo_Example/main.cpp:42: undefined reference to `init_snmp' /home/srinivas/QT_Projects/build-SNMP_Demo_Example-Desktop_Qt_5_7_0_GCC_64bit-Debug/../SNMP_Demo_Example/main.cpp:48: undefined reference to `snmp_sess_init' Makefile:216: recipe for target 'SNMP_Demo_Example' failed /home/srinivas/QT_Projects/build-SNMP_Demo_Example-Desktop_Qt_5_7_0_GCC_64bit-Debug/../SNMP_Demo_Example/main.cpp:66: undefined reference to `usmHMACMD5AuthProtocol' /home/srinivas/QT_Projects/build-SNMP_Demo_Example-Desktop_Qt_5_7_0_GCC_64bit-Debug/../SNMP_Demo_Example/main.cpp:74: undefined reference to `generate_Ku' /home/srinivas/QT_Projects/build-SNMP_Demo_Example-Desktop_Qt_5_7_0_GCC_64bit-Debug/../SNMP_Demo_Example/main.cpp:77: undefined reference to `snmp_perror' /home/srinivas/QT_Projects/build-SNMP_Demo_Example-Desktop_Qt_5_7_0_GCC_64bit-Debug/../SNMP_Demo_Example/main.cpp:78: undefined reference to `snmp_log' /home/srinivas/QT_Projects/build-SNMP_Demo_Example-Desktop_Qt_5_7_0_GCC_64bit-Debug/../SNMP_Demo_Example/main.cpp:97: undefined reference to `snmp_open' /home/srinivas/QT_Projects/build-SNMP_Demo_Example-Desktop_Qt_5_7_0_GCC_64bit-Debug/../SNMP_Demo_Example/main.cpp:100: undefined reference to `snmp_sess_perror' /home/srinivas/QT_Projects/build-SNMP_Demo_Example-Desktop_Qt_5_7_0_GCC_64bit-Debug/../SNMP_Demo_Example/main.cpp:109: undefined reference to `snmp_pdu_create' /home/srinivas/QT_Projects/build-SNMP_Demo_Example-Desktop_Qt_5_7_0_GCC_64bit-Debug/../SNMP_Demo_Example/main.cpp:111: undefined reference to `snmp_parse_oid' /home/srinivas/QT_Projects/build-SNMP_Demo_Example-Desktop_Qt_5_7_0_GCC_64bit-Debug/../SNMP_Demo_Example/main.cpp:112: undefined reference to `snmp_perror' /home/srinivas/QT_Projects/build-SNMP_Demo_Example-Desktop_Qt_5_7_0_GCC_64bit-Debug/../SNMP_Demo_Example/main.cpp:127: undefined reference to `snmp_add_null_var' /home/srinivas/QT_Projects/build-SNMP_Demo_Example-Desktop_Qt_5_7_0_GCC_64bit-Debug/../SNMP_Demo_Example/main.cpp:132: undefined reference to `snmp_synch_response' /home/srinivas/QT_Projects/build-SNMP_Demo_Example-Desktop_Qt_5_7_0_GCC_64bit-Debug/../SNMP_Demo_Example/main.cpp:143: undefined reference to `print_variable' /home/srinivas/QT_Projects/build-SNMP_Demo_Example-Desktop_Qt_5_7_0_GCC_64bit-Debug/../SNMP_Demo_Example/main.cpp:163: undefined reference to `snmp_errstring' /home/srinivas/QT_Projects/build-SNMP_Demo_Example-Desktop_Qt_5_7_0_GCC_64bit-Debug/../SNMP_Demo_Example/main.cpp:169: undefined reference to `snmp_sess_perror' /home/srinivas/QT_Projects/build-SNMP_Demo_Example-Desktop_Qt_5_7_0_GCC_64bit-Debug/../SNMP_Demo_Example/main.cpp:179: undefined reference to `snmp_free_pdu' /home/srinivas/QT_Projects/build-SNMP_Demo_Example-Desktop_Qt_5_7_0_GCC_64bit-Debug/../SNMP_Demo_Example/main.cpp:180: undefined reference to `snmp_close' collect2: error: ld returned 1 exit status make: *** [SNMP_Demo_Example] Error 1 13:04:19: The process "/usr/bin/make" exited with code 2. Error while building/deploying project SNMP_Demo_Example (kit: Desktop Qt 5.7.0 GCC 64bit) When executing step "Make" what could be the error???? this is my .pro file QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = SNMP_Demo_Example TEMPLATE = app SOURCES += main.cpp\ mainwindow.cpp HEADERS += mainwindow.h FORMS += mainwindow.ui INCLUDEPATH += /usr/local/include/net-snmp INCLUDEPATH += /usr/local/include/net-snmp/agent INCLUDEPATH += /usr/local/include/net-snmp/library INCLUDEPATH += /usr/local/include/net-snmp/machine INCLUDEPATH += /usr/local/include/net-snmp/system unix:!macx: LIBS += -L$$PWD/../../../../usr/local/lib/ -lnetsnmp INCLUDEPATH += $$PWD/../../../../usr/local/include DEPENDPATH += $$PWD/../../../../usr/local/include unix:!macx: LIBS += -L$$PWD/../../../../usr/local/lib/ -lnetsnmpagent INCLUDEPATH += $$PWD/../../../../usr/local/include DEPENDPATH += $$PWD/../../../../usr/local/include unix:!macx: LIBS += -L$$PWD/../../../../usr/local/lib/ -lnetsnmphelpers INCLUDEPATH += $$PWD/../../../../usr/local/include DEPENDPATH += $$PWD/../../../../usr/local/include unix:!macx: LIBS += -L$$PWD/../../../../usr/local/lib/ -lnetsnmpmibs INCLUDEPATH += $$PWD/../../../../usr/local/include DEPENDPATH += $$PWD/../../../../usr/local/include unix:!macx: LIBS += -L$$PWD/../../../../usr/local/lib/ -lnetsnmptrapd INCLUDEPATH += $$PWD/../../../../usr/local/include DEPENDPATH += $$PWD/../../../../usr/local/include
Qt Creator 32 bit with CUDA V5
I am trying to compile simple code CUDA on Qt in release mode. My .pro TEMPLATE = app CONFIG += console QT += core CONFIG -= app_bundle QT -= gui # Define output directories DESTDIR = release OBJECTS_DIR = obj CUDA_OBJECTS_DIR = OBJECTS_DIR/cuda SOURCES += main.cpp # This makes the .cu files appear in your project OTHER_FILES += vectorAddition.cu # CUDA settings <-- may change depending on your system CUDA_SDK = "C:/ProgramData/NVIDIA Corporation/CUDA Samples/v5.0" # Path to cuda SDK install CUDA_DIR = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v5.0" # Path to cuda toolkit install SYSTEM_NAME = Win32 # Depending on your system either 'Win32', 'x64', or 'Win64' SYSTEM_TYPE = 32 # '32' or '64', depending on your system CUDA_ARCH += sm_20 # Type of CUDA architecture, for example 'compute_10', 'compute_11', 'sm_10' NVCC_OPTIONS = --use_fast_math NVCCFLAGS = --compiler-options -fno-strict-aliasing -use_fast_math --ptxas-options=-v # include paths INCLUDEPATH += $$CUDA_DIR/include \ $$CUDA_SDK/common/inc # library directories QMAKE_LIBDIR += $$CUDA_DIR/lib/$$SYSTEM_NAME \ $$CUDA_SDK/common/lib/$$SYSTEM_NAME # Add the necessary libraries LIBS += -lcuda -lcudart # The following makes sure all path names (which often include spaces) are put between quotation marks CUDA_INC = $$join(INCLUDEPATH,'" -I"','-I"','"') # Configuration of the Cuda compiler CONFIG(debug, debug|release) { # debug mode cuda.input =vectorAddition.cu cuda.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}_cuda.obj cuda.commands = $$CUDA_DIR/bin/nvcc.exe -D_DEBUG -m32 -g -G -c $$NVCCFLAGS $$NVCC_OPTIONS $$CUDA_INC $$LIBS --machine $$SYSTEM_TYPE -arch=$$CUDA_ARCH -c -o ${QMAKE_FILE_OUT}${QMAKE_FILE_NAME} cuda.dependency_type = TYPE_C QMAKE_EXTRA_COMPILERS += cuda_d } else { # Release mode cuda.input = vectorAddition.cu cuda.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}_cuda.o cuda.commands = $$CUDA_DIR/bin/nvcc.exe $$CUDA_INC $$LIBS --machine $$SYSTEM_TYPE -c -o ${QMAKE_FILE_OUT}${QMAKE_FILE_NAME} cuda.dependency_type = TYPE_C QMAKE_EXTRA_COMPILERS += cuda } vectorAddition.cu extern "C" __global__ void vectorAdditionCUDA(const float* a, const float* b, float* c, int n) { int ii = blockDim.x * blockIdx.x + threadIdx.x; if (ii < n) c[ii] = a[ii] + b[ii]; } void vectorAddition(const float* a, const float* b, float* c, int n) { float *a_cuda, *b_cuda, *c_cuda; unsigned int nBytes = sizeof(float) * n; int threadsPerBlock = 256; int blocksPerGrid = (n + threadsPerBlock - 1) / threadsPerBlock; // allocate and copy memory into the device cudaMalloc((void **)& a_cuda, nBytes); cudaMalloc((void **)& b_cuda, nBytes); cudaMalloc((void **)& c_cuda, nBytes); cudaMemcpy(a_cuda, a, nBytes, cudaMemcpyHostToDevice); cudaMemcpy(b_cuda, b, nBytes, cudaMemcpyHostToDevice); vectorAdditionCUDA<<<blocksPerGrid, threadsPerBlock>>>(a_cuda, b_cuda, c_cuda, n); // load the answer back into the host cudaMemcpy(c, c_cuda, nBytes, cudaMemcpyDeviceToHost); cudaFree(a_cuda); cudaFree(b_cuda); cudaFree(c_cuda); } Main.cpp #include <iostream> #include <QtCore/QCoreApplication> #include <QDebug> #include <cuda.h> using namespace std; extern"C" void vectorAddition(const float* a, const float* b, float* c, int n); void printArray(const float* a, const unsigned int n) { QString s = "("; unsigned int ii; for (ii = 0; ii < n - 1; ++ii) s.append(QString::number(a[ii])).append(", "); s.append(QString::number(a[ii])).append(")"); qDebug() << s; } int main() { cout << "Hello World!:" <<endl; int deviceCount = 0; int cudaDevice = 0; char cudaDeviceName [100]; unsigned int N = 50; float *a, *b, *c; cuInit(0); cuDeviceGetCount(&deviceCount); cuDeviceGet(&cudaDevice, 0); cuDeviceGetName(cudaDeviceName, 100, cudaDevice); qDebug() << "Number of devices: " << deviceCount; qDebug() << "Device name:" << cudaDeviceName; a = new float [N]; b = new float [N]; c = new float [N]; for (unsigned int ii = 0; ii < N; ++ii) { a[ii] = qrand(); b[ii] = qrand(); } // This is the function call in which the kernel is called vectorAddition(a,b,c,N); qDebug() << "input a:"; printArray(a, N); qDebug() << "input b:"; printArray(b, N); qDebug() << "output c:"; printArray(c, N); if (a) delete a; if (b) delete b; if (c) delete c; return 0; } When I try to compile I get an "undefined reference to 'vectorAddition'" error. I think the problem is Qt Creator doesn't add the vectorAddition.cu file to the project tree even though I add it to OTHER_FILES.
I think you just missed CUDA_SOURCES += vectorAddition.cu which specify the cu file for NVCC Here is my .pro file that works for me (Qt 5.2.+MSVC2012) #------------------------------------------------- # Project created by QtCreator #------------------------------------------------- TEMPLATE = app CONFIG += console QT += core CONFIG -= app_bundle QT -= gui SOURCES += main.cpp\ INCLUDEPATH += $$PWD/ DEPENDPATH += $$PWD/ DESTDIR = debug OBJECTS_DIR = debug/obj # directory where .obj files will be saved CUDA_OBJECTS_DIR = debug/obj # directory where .obj of cuda file will be saved # This makes the .cu files appear in your project OTHER_FILES += vectorAddition.cu # this is your cu file need to compile # CUDA settings <-- may change depending on your system (i think you missed this) CUDA_SOURCES += vectorAddition.cu # let NVCC know which file you want to compile CUDA NVCC CUDA_SDK = "C:\ProgramData\NVIDIA Corporation\NVIDIA GPU Computing SDK 4.0\C" # Path to cuda SDK install CUDA_DIR = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v6.5" SYSTEM_NAME = Win32 # Depending on your system either 'Win32', 'x64', or 'Win64' SYSTEM_TYPE = 32 # '32' or '64', depending on your system CUDA_ARCH = sm_20 # 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\ $$CUDA_SDK/common/inc\ $$CUDA_SDK/../shared/inc\ # library directories QMAKE_LIBDIR += $$join(CUDA_DIR,'" -I"','-I"','"')/lib/$$SYSTEM_NAME\ $$join(CUDA_SDK,'" -I"','-I"','"')/common/lib/$$SYSTEM_NAME\ $$join(CUDA_SDK,'" -I"','-I"','"')/../shared/lib/$$SYSTEM_NAME # Add the necessary libraries CUDA_LIBS= -lcuda -lcudart #add quotation for those directories contain space (Windows required) CUDA_INC +=$$join(INCLUDEPATH,'" -I"','-I"','"') LIBS += $$CUDA_LIBS #nvcc config # 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) { #Debug settings # Debug mode cuda_d.input = CUDA_SOURCES cuda_d.output = $$CUDA_OBJECTS_DIR/${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 = $$CUDA_OBJECTS_DIR/${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 }
Undefined reference to boost::thread in Qt
I'm trying to create a boost::thread application in Qt. Here is my code: #include <iostream> #include "boost/thread.hpp" #include "boost/bind.hpp" using namespace std; class A { public: void tf() { for (int i = 0; i < 100; ++i) { cout << i << endl; } } }; int main() { boost::shared_ptr<A> aPtr; cout << "Hello World!" << endl; boost::thread t = boost::thread(boost::bind(&A::tf, aPtr.get())); cout << "Thread started" << endl; return 0; } And the corresponding .pro file: TEMPLATE = app CONFIG += console CONFIG -= qt LIBS += -L"C:/Program Files (x86)/boost/boost_1_49/lib" DEPENDPATH += "C:/Program Files (x86)/boost/boost_1_49" INCLUDEPATH += "C:/Program Files (x86)/boost/boost_1_49" SOURCES += main.cpp When i try to compile it i get: {{path}}\main.cpp:21: error: undefined reference to `_imp___ZN5boost6threadD1Ev' {{path}}\main.o:-1: In function `ZN5boost6threadC1INS_3_bi6bind_tIvNS_4_mfi3mf0Iv1AEENS2_5list1INS2_5valueIPS6_EEEEEEEET_NS_10disable_ifINS_14is_convertibleIRSE_NS_6detail13thread_move_tISE_EEEEPNS0_5dummyEE4typeE': c:\Program Files (x86)\boost\boost_1_49\boost\thread\detail\thread.hpp:205: error: undefined reference to `_imp___ZN5boost6thread12start_threadEv' collect2.exe:-1: error: error: ld returned 1 exit status Whats the problem? What am i missing? M.
You aren't linking to the Boost Thread library, you are just telling Qt where it is. LIBS += -L"C:/Program Files (x86)/boost/boost_1_49/lib" -lboost_thread