简体   繁体   English

libcvd - 编译c ++时对“x ...”的未定义引用

[英]libcvd - undefined reference to “x…” while compiling c++

I am trying to build libCVD in order to use with ROS (from www.ros.org). 我正在尝试构建libCVD以便与ROS一起使用(来自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 ). 还有一个其他stackoverflow问题,几乎有类似的错误( 编译libcvd时未定义的引用错误 )。

I tried like it is suggested there to find out why there is no path given with the second -L option. 我试着建议那里找出第二个-L选项没有路径的原因。 So I ended up in the projects configure.in file, where I believe the error happens. 所以我最终在项目configure.in文件中,我相信错误发生。 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 configure.in文件位于https://dl.dropboxusercontent.com/u/16804463/configure.in下。

Thanks in advance. 提前致谢。

The chosen solution in the other SO question is not right. 在另一个SO问题中选择的解决方案是不对的。 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 . 您的链接行包含: -L -lX11 There should be a pathname after the -L . -L后应该有一个路径名。 Since there isn't, the linker assumes the pathname is the next argument, -lX11 . 由于没有,链接器假定路径名是下一个参数-lX11 This means the linker doesn't link the actual libX11.so library because it's treating the library reference as a path instead. 这意味着链接器不链接实际的libX11.so库,因为它将库引用视为路径。

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. 你需要查看你的Makefile并找到链接cvd_display_image.o目标的规则,看看这里发生了什么。 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. 正如在另一个SO答案中所提到的,很可能你会发现链接行类似于-L$(SOME_VARIABLE)并且该变量是空的。 You need to set that variable to some value, perhaps by running make SOME_VARIABLE=. 您需要将该变量设置为某个值,可能是通过运行make SOME_VARIABLE=. or make SOME_VARIABLE=/usr/lib or whatever. 或者make SOME_VARIABLE=/usr/lib等等。

Seeing the configure.in file is not so useful: the important part is the makefile. 看到configure.in文件并不是那么有用:重要的部分是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. 在任何情况下,你都应该向这个软件的维护者报告这个问题,以便他们能够解决这个问题:显然,当有多个人遇到它时,他们会遇到真正的错误。

I had similar errors. 我有类似的错误。 I realised that the libcvd seems to be dependent on the following 3 libraries. 我意识到libcvd似乎依赖于以下3个库。

  • lapack LAPACK
  • blas 布拉斯
  • toon 香椿

These are all mathematical libraries. 这些都是数学库。 Install Synaptic Package Manager from Ubuntu Software Center. 从Ubuntu软件中心安装Synaptic Package Manager。 (assuming u are using ubuntu - if you are not you can use apt-get or some other way of installing the packages) (假设您正在使用ubuntu - 如果您不是,您可以使用apt-get或其他方式安装软件包)

From Synaptic Package Manager, search for the following packages : 从Synaptic Package Manager中,搜索以下包:

  • liblapack-dev liblapack-dev的
  • libblas-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. 安装TooN:git clone git clone git://github.com/edrosten/TooN.git这将在你克隆到的任何地方创建一个TooN目录。 Navigate to the TooN directory and type : 导航到TooN目录并键入:

./configure 。/配置

make 使

make install make install

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM