Hendrik Unger
Hendrik Unger

Reputation: 11

libcvd - undefined reference to "x..." while compiling c++

I am trying to build libCVD in order to use with ROS (from www.ros.org). My Problem is that I am getting the following errors:

make[3]: Entering directory `/opt/ros/groovy/stacks/tum_ardrone/thirdparty/libcvd/build'
/usr/bin/g++-4.6 -o progs/cvd_display_image progs/cvd_display_image.o -L. -lcvd  -ltiff -ljpeg -lpng -lpng -llapack -lGLU -lGL -lrt  -L -lX11 -lXext -pthread

./libcvd.so: undefined reference to `XMoveWindow'
./libcvd.so: undefined reference to `XCreateGlyphCursor'
./libcvd.so: undefined reference to `XStoreName'
./libcvd.so: undefined reference to `XLookupString'
./libcvd.so: undefined reference to `XFreeFont'
./libcvd.so: undefined reference to `XSetClassHint'
./libcvd.so: undefined reference to `XCreateWindow'
./libcvd.so: undefined reference to `XCreateColormap'
./libcvd.so: undefined reference to `XOpenDisplay'
./libcvd.so: undefined reference to `XDestroyWindow'
./libcvd.so: undefined reference to `XCloseDisplay'
./libcvd.so: undefined reference to `XUnmapWindow'
./libcvd.so: undefined reference to `XNextEvent'
./libcvd.so: undefined reference to `XSetWMProtocols'
./libcvd.so: undefined reference to `XResizeWindow'
./libcvd.so: undefined reference to `XMapWindow'
./libcvd.so: undefined reference to `XSelectInput'
./libcvd.so: undefined reference to `XFlush'
./libcvd.so: undefined reference to `XWarpPointer'
./libcvd.so: undefined reference to `XLoadQueryFont'
./libcvd.so: undefined reference to `XDefineCursor'
./libcvd.so: undefined reference to `XInternAtom'
./libcvd.so: undefined reference to `XQueryPointer'
./libcvd.so: undefined reference to `XUndefineCursor'
./libcvd.so: undefined reference to `XGetWindowAttributes'
./libcvd.so: undefined reference to `XPending'
collect2: ld returned 1 exit status
make[3]: *** [progs/cvd_display_image] Error 1
make[3]: Leaving directory `/opt/ros/groovy/stacks/tum_ardrone/thirdparty/libcvd/build'
make[2]: *** [libcvd_built] Error 2

There is an other stackoverflow question with nearly similar errors (undefined reference error while compiling libcvd).

I tried like it is suggested there to find out why there is no path given with the second -L option. So I ended up in the projects configure.in file, where I believe the error happens. But I have no experience with this build system, so help would be great.

The configure.in file is available under https://dl.dropboxusercontent.com/u/16804463/configure.in

Thanks in advance.

Upvotes: 1

Views: 5490

Answers (2)

lppier
lppier

Reputation: 1987

I had similar errors. I realised that the libcvd seems to be dependent on the following 3 libraries.

  • lapack
  • blas
  • toon

These are all mathematical libraries. Install Synaptic Package Manager from Ubuntu Software Center. (assuming u are using ubuntu - if you are not you can use apt-get or some other way of installing the packages)

From Synaptic Package Manager, search for the following packages :

  • liblapack-dev
  • libblas-dev

and install.

Install TooN : git clone git clone git://github.com/edrosten/TooN.git This will create a TooN directory wherever you cloned it to. Navigate to the TooN directory and type :

./configure

make

make install

Hope this helps.

Upvotes: 2

MadScientist
MadScientist

Reputation: 100856

The chosen solution in the other SO question is not right. The right solution is the one that's not chosen: the error is that you have a missing path in your link line. Your link line contains: -L -lX11. There should be a pathname after the -L. Since there isn't, the linker assumes the pathname is the next argument, -lX11. This means the linker doesn't link the actual libX11.so library because it's treating the library reference as a path instead.

You need to look at your Makefile and find the rule to link the cvd_display_image.o target, and see what is going on here. As mentioned in the other SO answer, most likely you'll find that the link line is something like -L$(SOME_VARIABLE) and that variable is empty. You need to set that variable to some value, perhaps by running make SOME_VARIABLE=. or make SOME_VARIABLE=/usr/lib or whatever.

Seeing the configure.in file is not so useful: the important part is the makefile.

In any event you should definitely report this to the maintainers of this software so they can fix it: obviously they have a real error here as multiple people are running into it.

Upvotes: 2

Related Questions