Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Error during compiling the Project Test(Kit: Desktop Qt 5.2.0 MinGW 32bit)



  • Hi there,

    I am new at QT and also new at C++
    I want to have access to a batterysystem using a CAN interface. Therefore i downloaded the PCAN Basic API that consists of a .lib .dll and .h
    I already included them in my .pro-file and now I want to initialize the CAN but following errors occur:

    My .pro file:
    QT += core gui
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    TARGET = Test
    TEMPLATE = app
    SOURCES += main.cpp
    mainwindow.cpp
    HEADERS += mainwindow.h
    PCANBasic.h
    FORMS += mainwindow.ui
    INCLUDEPATH += C:/Qt/Projekte/Test
    LIBS += -LC:/Qt/Projekte/Test-lPCANBasic
    DESTDIR += Test

    my .cpp

    #include "mainwindow.h"
    #include <QApplication>
    #include <QtCore>
    #include <QtGui>
    #include <PCANBasic.h>
    #include <qdebug.h>
    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);

    MainWindow w;
    
    w.show();
    
    TPCANStatus result;
    
    char strMsg[256];
    
    result=CAN_Initialize(PCAN_USBBUS1,PCAN_BAUD_500K);
    
    if (result!= PCAN_ERROR_OK)
    
    {
    
        CAN_GetErrorText(result,0,strMsg);
        qDebug()<<strMsg;
    

    }

    else
    
    {
    
     qDebug()<<"PCAN_USB Channel 1 was initialized";
    }
    
    return a.exec&#40;&#41;;
    

    }

    here the comiling errors:

    10:24:37: Unchanged configuration, qmake-step was jumped over.
    10:24:37: Start "C:\Qt\Qt5.2.0\Tools\mingw48_32\bin\mingw32-make.exe"
    C:\Qt\Qt5.2.0\5.2.0\mingw48_32\bin\qmake.exe -spec win32-g++ -o Makefile ..\Test\Test.pro
    C:/Qt/Qt5.2.0/Tools/mingw48_32/bin/mingw32-make -f Makefile.Release
    mingw32-make[1]: Entering directory 'C:/Qt/Projekte/build-Test-Desktop_Qt_5_2_0_MinGW_32bit-Release'
    g++ -c -pipe -fno-keep-inline-dllexport -O2 -frtti -Wall -Wextra -fexceptions -mthreads -DUNICODE -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_NEEDS_QMAIN -I..\Test -I"..\Test" -I"....\Qt5.2.0\5.2.0\mingw48_32\include" -I"....\Qt5.2.0\5.2.0\mingw48_32\include\QtWidgets" -I"....\Qt5.2.0\5.2.0\mingw48_32\include\QtGui" -I"....\Qt5.2.0\5.2.0\mingw48_32\include\QtCore" -I"release" -I"." -I"." -I"....\Qt5.2.0\5.2.0\mingw48_32\mkspecs\win32-g++" -o release\main.o ..\Test\main.cpp
    g++ -Wl,-s -Wl,-subsystem,windows -mthreads -o Test\Test.exe release/main.o release/mainwindow.o release/moc_mainwindow.o -lglu32 -lopengl32 -lgdi32 -luser32 -lmingw32 -lqtmain -LC:/Qt/Projekte/Test-lPCANBasic -LC:\Qt\Qt5.2.0\5.2.0\mingw48_32\lib -lQt5Widgets -lQt5Gui -lQt5Core

    release/main.o:main.cpp:(.text+0x77): undefined reference to CAN_Initialize@20' release/main.o:main.cpp:(.text+0x9a): undefined reference toCAN_GetErrorText@12'

    Makefile.Release:80: recipe for target 'Test\Test.exe' failed
    mingw32-make[1]: Leaving directory 'C:/Qt/Projekte/build-Test-Desktop_Qt_5_2_0_MinGW_32bit-Release'
    makefile:34: recipe for target 'release' failed
    c:/qt/qt5.2.0/tools/mingw48_32/bin/../lib/gcc/i686-w64-mingw32/4.8.0/../../../../i686-w64-mingw32/bin/ld.exe: release/main.o: bad reloc address 0x20 in section `.text$_ZN7QStringD1Ev[__ZN7QStringD1Ev]'
    collect2.exe: error: ld returned 1 exit status
    mingw32-make[1]: *** [Test\Test.exe] Error 1
    mingw32-make: *** [release] Error 2
    10:24:41: The process "C:\Qt\Qt5.2.0\Tools\mingw48_32\bin\mingw32-make.exe" was finished with the return value 2.
    Error at Deployment of the projcet Test(Kit: Desktop Qt 5.2.0 MinGW 32bit)
    At the execution of the step 'Make'

    Can you help me?


  • Moderators

    Was the CAN library built with the same compiler at the same version you are using (and all the other libs)?



  • The .h file is a c++ headerfile,
    and I have the choise between two different .lib

    \BB_LIB
        32-bit LIB file for C++ Builder.
    
    \VC_LIB
        32-bit LIB file for Visual C/C++.
    

    I used the one for c++ builder.
    and a 32-bit interface DLL.


Log in to reply