简体   繁体   中英

Linking with a newer library rather than the old one

I am trying to compile the Point Cloud Library from source ( http://pointclouds.org/ ). After running cmake and make, I receive the following linking error:

Linking CXX executable ../../bin/pcl_convert_pcd_ascii_binary
../../lib/libpcl_io.so.1.7.2: undefined reference to `png_set_longjmp_fn'

As a newbie, I'm not sure what this error means, but I am assuming: the executable file plc_convert_pcd_ascii_binary which it is trying to build, needs to be linked to the library libpcl_io.so.1.7.2 , but this library contains the function png_set_longjump_fun , and the definition of this function cannot be found?

So, I have tried looked at some similar questions on Stack Overflow, and it turns out that png_set_longjump_fun is contained in the libpng library, but was only introduced after libpng-1.4.x . After running dpkg -l | grep libpng* dpkg -l | grep libpng* , I get the following output:

ii  libpng12-0:amd64                                      1.2.50-1ubuntu2                                     amd64        PNG library - runtime
ii  libpng12-dev                                          1.2.50-1ubuntu2                                     amd64        PNG library - development

So it looks like I need to upgrade from libpng12-dev to at least libpng14-dev . From the libpng website, I see that I can download the source for the latest version (but the latest version I can get through apt-get is only libpng12-dev ). But I am worried that there may be some conflictions if I have one version installed via apt-get, and another version installed manually. However, uninstalling libpng12-dev may cause issues if there are packages which depend on this, but are not compatible with the newer version.

Therefore, what I would like to know, is whether I should uninstall/purge libpng12-dev , and then install the new version manually, or to simply install the new version whilst keeping the old version. And if I do the latter, how can I be sure that the PCL binary I am trying to compile, will link with this new library, rather than the old one?

Thanks :)

If you compile from source, you probably don't even need to install. Once you have compiled libpng, set the CMAKE_PREFIX_PATH when you compile PCL to point at the right place in the libpng build tree. This generally is what is done with cmake, so should work in this case. More information:

http://www.cmake.org/cmake/help/v3.0/variable/CMAKE_PREFIX_PATH.html

https://blogs.kde.org/2008/12/12/how-get-cmake-find-what-you-want-it

cmake - find_library - custom library location

How to point cmake at specific directory for library?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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