1

I am new to pangolin and trying to compile a 'hello world' code of pangolin on Qt Creator. I have run into this "undefined reference" issue while compiling it. My code is simple :

#include <iostream>
#include <pangolin/pangolin.h>
using namespace std;
int main()
{
  pangolin::CreateWindowAndBind("Main",640,480);
  return 0;
 }

My .pro file looks as following :

QT += core
QT -= gui

TARGET = hellopangolin
CONFIG += c++11
CONFIG -= app_bundle

TEMPLATE = app

SOURCES += main.cpp

INCLUDEPATH += /home/mavbot/Pangolin/include /home/mavbot/Pangolin/build/src/include

LIBS += -L "/home/mavbot/Pangolin/build/src"
-lpangolin \

LIBS += -lGLEW \
        -lGL \
        -lEGL

I have successfully compiled and build the pangolin library as the example programs run smoothly on my system.I ran a ldd on the executable of the examples and found the dependent libraries and tried to link them in QT Creator. I am new to OpenGL too. The error I run into is :

error: undefined reference to `pangolin::CreateWindowAndBind(std::__cxx11::basic_string, std::allocator >, int, int, pangolin::Params const&)'

I build pangolin as follows :

git clone https://github.com/stevenlovegrove/Pangolin.git
cd Pangolin
mkdir build
cd build
cmake ..
make -j8

EDIT 2: After Botje's suggestion, inserting the / after the library path helped it to compile. However now I have a run time error :

/home/mavbot/Documents/qtcodes/build-hellopangolin-Desktop-Debug/hellopangolin: error while loading shared libraries: libpangolin.so: cannot open shared object file: No such file or directory

EDIT 3: -rwxrwxr-x 1 mavbot mavbot 2333648 Mar 10 23:55 /home/mavbot/Pangolin/build/src/libpangolin.so

linux-vdso.so.1 =>  (0x00007ffedc5b8000)
libGL.so.1 => /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 (0x00007f05e3401000)
libGLEW.so.1.13 => /usr/lib/x86_64-linux-gnu/libGLEW.so.1.13 (0x00007f05e317e000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f05e2e44000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f05e2c3c000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f05e2a1f000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f05e269d000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f05e2394000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f05e217e000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f05e1db4000)
/lib64/ld-linux-x86-64.so.2 (0x00007f05e3a5a000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f05e1b9a000)
libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f05e1971000)
libxcb-dri3.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-dri3.so.0 (0x00007f05e176e000)
libxcb-present.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-present.so.0 (0x00007f05e156b000)
libxcb-sync.so.1 => /usr/lib/x86_64-linux-gnu/libxcb-sync.so.1 (0x00007f05e1364000)
libxshmfence.so.1 => /usr/lib/x86_64-linux-gnu/libxshmfence.so.1 (0x00007f05e1161000)
libglapi.so.0 => /usr/lib/x86_64-linux-gnu/libglapi.so.0 (0x00007f05e0f30000)
libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f05e0d1e000)
libXdamage.so.1 => /usr/lib/x86_64-linux-gnu/libXdamage.so.1 (0x00007f05e0b1b000)
libXfixes.so.3 => /usr/lib/x86_64-linux-gnu/libXfixes.so.3 (0x00007f05e0915000)
libX11-xcb.so.1 => /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1 (0x00007f05e0713000)
libxcb-glx.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0 (0x00007f05e04fa000)
libxcb-dri2.so.0 => /usr/lib/x86_64-linux-gnu/libxcb-dri2.so.0 (0x00007f05e02f5000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f05e00d3000)
libXxf86vm.so.1 => /usr/lib/x86_64-linux-gnu/libXxf86vm.so.1 (0x00007f05dfecd000)
libdrm.so.2 => /usr/lib/x86_64-linux-gnu/libdrm.so.2 (0x00007f05dfcbb000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f05dfab7000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f05df8b3000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f05df6ad000)
3
  • How did you build and install Pangolin? Commented Mar 10, 2020 at 13:24
  • 2
    That looks okay. Can you show the full commandline used for linking? I'm asking because there is no \ on the line LIBS += -L "/home/mavbot/Pangolin/build/src", so I'm not sure if the -lpangolin on the next line is taken along or not. Commented Mar 10, 2020 at 13:44
  • 1
    @rotating_image try add LIBS += -L "/home/mavbot/Pangolin/build/src" -lpangolin Commented Mar 10, 2020 at 14:58

1 Answer 1

1

As /home/mavbot/Pangolin/build/src is not a default place to look for libraries, you have to inform the dynamic linker (ld.so) to look there.

You can do this by:

  • either setting the environment variable LD_LIBRARY_PATH=/home/mavbot/Pangolin/build/src every time you run your program, or
  • compiling your program with a "runpath". This will instruct ld.so to look there first. The flag is as follows:
-Wl,-rpath=/home/mavbot/Pangolin/build/src
  • or just installing pangolin globally, where the linker looks by default (check the contents of /etc/ld.so.conf and/or /etc/ld.so.conf.d/* for the default paths.
Sign up to request clarification or add additional context in comments.

2 Comments

I did the 1st by adding this line "export LD_LIBRARY_PATH=/home/mavbot/Pangolin/build/src" to the bottom of bashrc file...but still no luck..i did echo $LD_LIBRARY_PATH and the correct value that is the path to the libpangoli.so is shown
edit your question with the output of ls -l /home/mavbot/Pangolin/build/src/libpangolin* and ldd /home/mavbot/Pangolin/build/src/libpangolin.so

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.