Pekaziz
Pekaziz

Reputation: 83

undefined reference error while compiling libcvd

I am trying to compile libcvd to use PTAM. When I get to the command "make" while compiling it gives me following error:

ln -s libcvd.so.0.7 libcvd.so.0
ln -s libcvd.so.0 libcvd.so
g++ -o progs/se3_exp progs/se3_exp.o -L.  -lcvd  -ltiff -ljpeg -lpng -llapack -lGLU -lGL -ldc1394  -L -lX11 -lXext -pthread
./libcvd.so: error: undefined reference to 'XQueryPointer'
./libcvd.so: error: undefined reference to 'XPending'
./libcvd.so: error: undefined reference to 'XNextEvent'
./libcvd.so: error: undefined reference to 'XFlush'
./libcvd.so: error: undefined reference to 'XSelectInput'
./libcvd.so: error: undefined reference to 'XStoreName'
./libcvd.so: error: undefined reference to 'XUnmapWindow'
./libcvd.so: error: undefined reference to 'XDestroyWindow'
./libcvd.so: error: undefined reference to 'XCloseDisplay'
./libcvd.so: error: undefined reference to 'XOpenDisplay'
./libcvd.so: error: undefined reference to 'XCreateColormap'
./libcvd.so: error: undefined reference to 'XCreateWindow'
./libcvd.so: error: undefined reference to 'XMapWindow'
./libcvd.so: error: undefined reference to 'XDefineCursor'
./libcvd.so: error: undefined reference to 'XUndefineCursor'
./libcvd.so: error: undefined reference to 'XWarpPointer'
./libcvd.so: error: undefined reference to 'XMoveWindow'
./libcvd.so: error: undefined reference to 'XResizeWindow'
./libcvd.so: error: undefined reference to 'XGetWindowAttributes'
./libcvd.so: error: undefined reference to 'XSetClassHint'
./libcvd.so: error: undefined reference to 'XInternAtom'
./libcvd.so: error: undefined reference to 'XSetWMProtocols'
./libcvd.so: error: undefined reference to 'XLoadQueryFont'
./libcvd.so: error: undefined reference to 'XCreateGlyphCursor'
./libcvd.so: error: undefined reference to 'XFreeFont'
./libcvd.so: error: undefined reference to 'XLookupString'
collect2: ld returned 1 exit status
make: *** [progs/se3_exp] Error 1

I could not find any appropriate solution to this error.

Thank you for your helping.

Upvotes: 0

Views: 4278

Answers (3)

Devesh
Devesh

Reputation: 897

I did two things.

First, I added an extra -lX11 in the following places. The new lines look like this -

thirdparty/libcvd/installfiles/configure:  LIBS="-lX11 -lX11 $LIBS"
thirdparty/libcvd/installfiles/configure:       LIBS="$LIBS -L$x_libraries -lX11 -lX11 -lXext"
thirdparty/libcvd/installfiles/configure.in:        APPEND(LIBS, [-L$x_libraries -lX11 -lX11 -lXext])

Next, I followed this answer of installing all 3 mentioned below (note: you need to install liblapack-dev as well. I had just liblapack3 installed but needed dev as well). https://stackoverflow.com/a/21432657/771650

Upvotes: 1

John Marshall
John Marshall

Reputation: 7005

Your problem is here:

g++ -o progs/se3_exp progs/se3_exp.o -L. -lcvd [...] -ldc1394 -L -lX11 -lXext -pthread

Unlike the first -L., the second library path (-L) option has no path argument after it, so it steals whatever comes next to use as an (unlikely!) path. To really fix this problem, you need to look at your Makefile's LOADLIBES definition and figure out how this incomplete -L option is getting into it. Most likely, the Makefile has ...-L$(SOME_PATH)... or similar, and the SOME_PATH variable is unexpectedly empty.

Upvotes: 0

Pekaziz
Pekaziz

Reputation: 83

I found the solution,

In the makefile change the order of the library references in this order:

LOADLIBES = -lX11 -ltiff -ljpeg -lpng -llapack -lGLU -lGL -ldc1394  -L -lXext -pthread

Upvotes: 1

Related Questions