Undefined reference to ...

Help
Bartek
2014-03-17
2014-03-17
  • Bartek
    Bartek
    2014-03-17

    Hello everyone.

    I'm pretty new to programing in Linux (using Linux Mint 16, Eclipse IDE) and I am not really good with the linker. I have downloaded g++ and libitpp-dev packages and then I've downloaded eclipse-cdt. I've created a new project, went to project -> properties -> C/C++ General -> Paths and Symbols and under Libraries tab I've added itpp. It worked well with the examples and I didn't get any errors. But then for my project I had to add some files to the itpp comm folder (usr/include/itpp/comm). They were all correct files, because they were used in another project in the past. But now, when I try to refer to them in my program I seem to be getting undefined reference to ... error, with the reference only to the new files I've added to itpp lib. I don't get any errors to the basic itpp elements (such as vec, bvec etc.).

    Console:
    make all
    Building file: ../src/name.cpp
    Invoking: GCC C++ Compiler
    g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/name.d" -MT"src/name.d" -o "src/name.o" "../src/name.cpp"
    Finished building: ../src/name.cpp

    Building file: ../src/main.cpp
    Invoking: GCC C++ Compiler
    g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/main.d" -MT"src/main.d" -o "src/main.o" "../src/main.cpp"
    Finished building: ../src/main.cpp

    Building target: magisterka
    Invoking: GCC C++ Linker
    g++ -L/usr/include/itpp -o "magisterka" ./src/name.o ./src/main.o -litpp
    ./src/magisterka.o: In function `main':
    and here I have 100 undefined reference to ... errors.

    Thanks in advance for any help provided.

    Bartek

     
  • Bogdan Cristea
    Bogdan Cristea
    2014-03-17

    The library path is wrong "-L/usr/include/itpp", that seems to be the include path. Also, it is better to use 'itpp-config' script when compiling with IT++

     
  • Bartek
    Bartek
    2014-03-17

    Well after deleting the additional path (the usr/include/itpp was additional I suppose, because I've added itpp library before) I've the console:
    make all
    Building target: magisterka
    Invoking: GCC C++ Linker
    g++ -o "magisterka" ./src/CodeInstance.o ./src/magisterka.o -litpp
    ./src/magisterka.o: In function `main':

     
  • Bogdan Cristea
    Bogdan Cristea
    2014-03-17

    Try to compile using this approach

    g++ itpp-config --cflags -o my_prog my_prog.cpp itpp-config --libs