Menu

Linker error plus some curiosity questions

2008-03-05
2012-09-26
  • Dario Figueira

    Dario Figueira - 2008-03-05

    First the Basic 3:
    Dev C++ version is 4.9.9.2
    my simple example of code:
    /****THE CODE***/

    include <cstdlib>

    include <yarp/os/Module.h>

    using namespace yarp::os;

    class DepthYARP : public Module {
    public:
    // // constructor & destructor
    DepthYARP();

    };

    //// standard constructor
    DepthYARP::DepthYARP(){

    }

    int main(int argc, char argv[])
    {
    return 0;
    }
    ********
    ***/

    /***THE****/
    /***LOG****
    /
    Compiler: Default compiler
    Building Makefile: "C:\Dario\College\iCub\Testing YARP\Makefile.win"
    Executing make clean
    rm -f main.o "Test Yarp + OpenCV.exe"

    g++.exe -DDEBUG -c main.cpp -o main.o -I"C:/Programas/Dev-Cpp/lib/gcc/mingw32/3.4.2/include" -I"C:/Programas/Dev-Cpp/include/c++/3.4.2/backward" -I"C:/Programas/Dev-Cpp/include/c++/3.4.2/mingw32" -I"C:/Programas/Dev-Cpp/include/c++/3.4.2" -I"C:/Programas/Dev-Cpp/include" -I"C:/Programas/OpenCV/cv/include" -I"C:/Programas/OpenCV/cvaux/include" -I"C:/Programas/OpenCV/cxcore/include" -I"C:/Programas/OpenCV/otherlibs/cvcam/include" -I"C:/Programas/OpenCV/otherlibs/highgui" -I"C:/Dario/College/iCub/yarp-2.1.8/src/libYARP_OS/include" -I"C:/Dario/College/iCub/yarp-2.1.8/src/libYARP_sig/include" -I"C:/Dario/College/iCub/yarp-2.1.8/src/libYARP_dev/include" -I"C:/Dario/College/iCub/ACE-5.5/ACE_wrappers" -g3

    g++.exe -DDEBUG main.o -o "Test Yarp + OpenCV.exe" -L"C:/Programas/Dev-Cpp/lib" -L"C:/Programas/OpenCV/lib" -L"C:/Dario/College/iCub/yarp-2.1.8/lib" -L"C:/Dario/College/iCub/ACE-5.5/ACE_wrappers/lib" ../yarp-2.1.8/lib/release/YARP_OS.lib ../../../../Programas/OpenCV/lib/highgui.lib ../../../../Programas/OpenCV/lib/cv.lib -g3

    main.o(.text+0xd): In function ZN4yarp2os7IConfig4openERNS0_10SearchableE': C:/Dario/College/iCub/yarp-2.1.8/src/libYARP_OS/include/yarp/os/IConfig.h: undefined reference toyarp::os::Module::Module()'
    main.o(.text+0x29): In function ZN9DepthYARPC1Ev': C:/Dario/College/iCub/Testing YARP/main.cpp:17: undefined reference toyarp::os::Module::Module()'
    main.o(.rdata$_ZTV9DepthYARP[vtable for DepthYARP]+0x28):C:/Dario/College/iCub/Testing YARP/main.cpp:17: undefined reference to yarp::os::Module::runModule()' main.o(.rdata$_ZTV9DepthYARP[vtable for DepthYARP]+0x2c):C:/Dario/College/iCub/Testing YARP/main.cpp:17: undefined reference toyarp::os::Module::runModule(int, char**, bool)'
    main.o(.rdata$_ZTV9DepthYARP[vtable for DepthYARP]+0x30):C:/Dario/College/iCub/Testing YARP/main.cpp:17: undefined reference to yarp::os::Module::openFromCommand(int, char**, bool)' main.o(.rdata$_ZTV9DepthYARP[vtable for DepthYARP]+0x38): In functionmain':
    C:/Dario/College/iCub/Testing YARP/main.cpp:22: undefined reference to `yarp::os::Module::attach(yarp::os::Port&)'

    main.o(.rdata$_ZTV9DepthYARP[vtable for DepthYARP]+0x3c):C:/Dario/College/iCub/Testing YARP/main.cpp:22: undefined reference to yarp::os::Module::attach(yarp::os::TypedReader&lt;yarp::os::Bottle&gt;&amp;, bool)' main.o(.rdata$_ZTV9DepthYARP[vtable for DepthYARP]+0x40):C:/Dario/College/iCub/Testing YARP/main.cpp:22: undefined reference toyarp::os::Module::attachTerminal()'
    main.o(.rdata$_ZTV9DepthYARP[vtable for DepthYARP]+0x44):C:/Dario/College/iCub/Testing YARP/main.cpp:22: undefined reference to `yarp::os::Module::basicRespond(yarp::os::Bottle const&, yarp::os::Bottle&)'

    main.o(.text$_ZN4yarp2os6Module12updateModuleEv[yarp::os::Module::updateModule()]+0x10): In function ZN4yarp2os7IConfig4openERNS0_10SearchableE': C:/Dario/College/iCub/yarp-2.1.8/src/libYARP_OS/include/yarp/os/IConfig.h: undefined reference toyarp::os::Time::delay(double)'
    main.o(.text$_ZN9DepthYARPD1Ev[DepthYARP::~DepthYARP()]+0x16):C:/Dario/College/iCub/yarp-2.1.8/src/libYARP_OS/include/yarp/os/IConfig.h: undefined reference to yarp::os::Module::~Module()' main.o(.text$_ZN9DepthYARPD0Ev[DepthYARP::~DepthYARP()]+0x16):C:/Dario/College/iCub/yarp-2.1.8/src/libYARP_OS/include/yarp/os/IConfig.h: undefined reference toyarp::os::Module::~Module()'
    collect2: ld returned 1 exit status

    make.exe: *** ["Test] Error 1

    Execution terminated
    /*********/
    /
    *********/

    And now the story,

    My pain: I have two codes, one deals with SIFT's (very nifty vision algorithm to recognize known images in other images), the other uses YARP (even more nifty code that hides the network layer from the programer, it's increadibly easy with YARP to open ports and send stuff from one place to the other, be it in the same PC, or through the network).

    None of this codes were made by me :P

    The SIFT's one's was made in Dev-C++, and compiles there.
    The other was made with CMAKE (even more increadibly nifty thing, a pseudo-code that generates makefiles ^^! It truly makes it possible to work in two diferent platforms on the same code with NO trouble) in Microsoft Visual Studio 2005, and so there compiles.

    My task, to put them together.

    What happens, neither the YARP one compiles in Dev-C++, nor the SIFT's one compile in MSVS...

    CMake is a great tool that makes a lot of aspects in programing automatic, but i feel i have to first understand those aspects before i can safely use it,
    therefor i'm trying to compile the YARP one in Dev-C++, and that above is the result.

    Details that may be useful (or Not), the project generated by CMake to MSVS set as
    "additional library directories:"
    c:\Dario\College\iCub\yarp-2.1.8\lib\$(OutDir)\$(OutDir),
    c:\Dario\College\iCub\yarp-2.1.8\lib\$(OutDir),
    c:\Dario\College\iCub\ACE-5.5\ACE_wrappers\lib\$(OutDir),
    c:\Dario\College\iCub\ACE-5.5\ACE_wrappers\lib,c:\Programas\OpenCV\lib\$(OutDir),
    c:\Programas\OpenCV\lib

    and
    "additional dependencies:"
    $(NOINHERIT) kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib
    YARP_dev.lib YARP_sig.lib YARP_OS.lib ACE.lib
    winmm.lib
    cv.lib cvaux.lib cxcore.lib highgui.lib
    YARP_dev.lib YARP_sig.lib YARP_OS.lib ACE.lib
    winmm.lib

    Any hints would be greatly appreciated

    PS: the curiosity question: what's the point of setting in Dev-C++ the "library directories" when we have to set specific files and their paths when linking?

     
    • Dario Figueira

      Dario Figueira - 2008-03-26

      I've tried changing in DevC++, in Tools -> COmpiler Options -> Programs the g++.exe from Dev C++ to the g++.exe that comes with MinGW, but.. :( same error

       
      • cpns

        cpns - 2008-03-26

        Aaaaarrrrrrrgggggggggghhhhhhhhh!

        You did not need to change anything! Dev-C++ comes with MinGW - you were using it all the time. Now all you have now is two MinGW installations - which may be asking for trouble if you don't know what you are doing.

        If you were attempting to use the the GCC 4 "Technology Preview" version, then I suggest that that is for experts only. Either way you need to change more than just the gcc executable path to get a consistent toolchain. I suggest that you leave it alone.

        What I suggested was rather than you re-built the library using MinGW/GCC.

        Clifford

         
    • Dario Figueira

      Dario Figueira - 2008-03-05

      PS: (P of pre XD) Is it bad to link libraries in excess? to link libraries that your program doesn't need? What happens?
      PPS: Oh, and the the Module.h only supposedly deals with YARP stuff, and the only YARP libs are those 3, and i've tried linking them all, with equal results

       
    • cpns

      cpns - 2008-03-08

      Your problem is probably that you are trying to ling a Microsoft PE format object file with a GNU linker that uses ELF format object files. Consequently nothing in YARP_OS.lib makes any sense to the linker so it is ignored. Conventionally GNU archives have a .a extension and a 'lib' prefix (e.g. libOpenCV.a would be the convention for OpenCV), so generally is a library has a .lib extension you might not expect it to link with GNU code. This makes me suspicious of your openCV library, but it may be simply that whoever built it did not follow conventions.

      I understand that later versions of MinGW, not shipped with Dev-C++ understand PE libraries. A firther issue is that in C++, different name-mangling schemes are used by different compilers, so the symbols won't match even if the library were teh correct format. The name mangling issue is usually only a problem for C++ DLLs.

      Your best bet is to build teh YARP library yourself from source.

      >>Is it bad to link libraries in excess?

      It may extend the build time because teh linker has to search all libraries. If teh nibraries do not use namespaces there is also the possibility that two librraies define a symbol of the same name and you will link the wrong one. In terms of size, only the object modules in the archive that are required to resolve symbols referenced in your code are actually linked.

       
      • Dario Figueira

        Dario Figueira - 2008-03-26

        I've built YARP from source myself, using CMAKE to generate a Microsoft Visual Studio project, and then clicking build on MSVS.

        So what should i try to make it link correctly?

         
        • cpns

          cpns - 2008-03-26

          ...uh... built it with MinGW. Sorry but I thouhgt that was what I said previously.

           
          • Dario Figueira

            Dario Figueira - 2008-03-26

            i'm sorry.. I wasn't even aware what MinGW even WAS, so i didn't understand the first time.

            Ok :), i've downloaded MinGW, is there a way to use it in conjunction with DevC++? or do i have to compile outside of DevC++?

             

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.