Linking problem with C static Library



  • Hi,

    I'm trying to use the classicladder plc as a library in my sample application. Classicladder is developed using the C programming language.

    But when i trying to compile , i got the linking undefined reference error , please help me guys,

    @g++ -Wl,-O1 -Wl,-rpath,/opt/QtSDK/Desktop/Qt/4.8.1/gcc/lib -o checkClassicLadder2 main.o checkclassicladder2.o moc_checkclassicladder2.o -L/opt/QtSDK/Desktop/Qt/4.8.1/gcc/lib -L../../../Downloads/classicladder -lladder -lQtGui -L/opt/QtSDK/Desktop/Qt/4.8.1/gcc/lib -L/usr/X11R6/lib -lQtCore -lpthread
    checkclassicladder2.o: In function checkClassicLadder2::checkClassicLadder2(QWidget*)': checkclassicladder2.cpp:(.text+0x112): undefined reference toClassicLadder_AllocAll()'
    checkclassicladder2.o: In function checkClassicLadder2::checkClassicLadder2(QWidget*)': checkclassicladder2.cpp:(.text+0x3c2): undefined reference toClassicLadder_AllocAll()'
    collect2: ld returned 1 exit status
    make: *** [checkClassicLadder2] Error 1
    @

    thanks



  • Hi,

    How you .pro file looks?
    Did you add library in which ClassicLadder_AllocAll() is defined?

    BR



  • sorry for the late reply

    yes i did add the library which contains the ClassicLadder_AllocAll(). But in the library it declared with the extern keyword



  • What about the C-Library header file?

    You may need the 'external "C" {};' declaration for the methods provided in pure C like this:
    @
    #ifdef cplusplus
    external "C" {
    #endif

    void C_method1(void);

    #ifdef cplusplus
    };
    #endif
    @


Log in to reply
 

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