質問

On Ubuntu 13.04 VM, which was used to build the sc utility, the dependency looks like the below:

$ ldd sc | grep -i png
    libpng12.so.0 => /lib/i386-linux-gnu/libpng12.so.0 (0xb75c2000)

On my Fedora VM, the sc utility is not linking libpng correctly. It has libpng15 but it is trying to link to libpng12:

$ ldd sc | grep -i png
    libpng12.so.0 => not found
    libpng15.so.15 => /lib/libpng15.so.15 (0xb6f40000)

I am using cmake to build my executables, and I am using the default FindPNG cmake file. My executable is statically linking to ImageMagick, which is configured to use libPNG.

find_package(ImageMagick COMPONENTS MagickWand MagickCore REQUIRED)
find_package(ZLIB)
find_package(Threads)
find_package(JPEG)
find_package(PNG)
find_package(LibLZMA)
find_package(OpenMP)
find_package(Cairo)

include_directories(${ImageMagick_INCLUDE_DIRS})
include_directories(${CAIRO_INCLUDE_DIRS})

target_link_libraries(sc
  ${LIBCAIRO}
  ${ImageMagick_LIBRARIES}
  ${JPEG_LIBRARIES}
  ${PNG_LIBRARIES}
  ${LIBLZMA_LIBRARIES}
  ${ZLIB_LIBRARIES}
  ${CMAKE_THREAD_LIBS_INIT}
  ${X11_LIBRARIES}
  ${OpenMP_LIB}
  )

I've tried making my own FindPNG cmake to target libpng.so. I still get the same result...

Is there any way to make that so that my executable will link to whatever libpng is found on user's machine?

役に立ちましたか?

解決

It looks like there is nothing that I can do with cmake, and the problem is coming from libraries that I am linking against (Cairo and ImageMagick).

The reason that there are two libpng dependencies on the deployed system is that I am deploying a prebuild ImageMagick (statically) which is built on a machine with libpng12. I assumed that the deploy system will have Cairo and libpng, and it does, but it does not have libpng12. It has libpng15 and Cairo, which is linking against it. Therefore, ldd shows that my executable is dependent on libpng12 and libpng15.

To resolve this, I statically link against libpng12 and any libraries that are linking it.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top