gstreamer - find_library or link_directories or find_package? What is better way? Error - Link libraries using cmake -


given
file /usr/lib/gstreamer-0.10/libgstffmpeg.so present
making changes in cmakelists.txt

approach 1 find_library()

find_library(gst_ffmpeg names gstffmpeg paths /usr/lib/gstreamer-0.10/ )
...
target_link_libraries( mylibraryormyexecutable ${gst_ffmpeg} )

when run make above configuration(approach 1), following errors

/bin/ld: warning: libvpx.so.1, needed /usr/lib/i386-linux-gnu/libavcodec.so.53, not found (try using -rpath or -rpath-link)
/bin/ld: warning: libschroedinger-1.0.so.0, needed /usr/lib/i386-linux-gnu/libavcodec.so.53, not found (try using -rpath or -rpath-link)
/bin/ld: warning: libgsm.so.1, needed /usr/lib/i386-linux-gnu/libavcodec.so.53, not found (try using -rpath or -rpath-link)

looks added library depends on more libraries not linked! can see above 3 .so files in /usr/lib. 1 possible solution approach 1 add 3 more find_library() functions. right ?

may not- this question explores issues found in above possible solution

  • q1. there other method saves effort of finding dependent libraries , linking them ? approach using dependent libraries automatically linked ?

approach 2 link_directories()

link_directories(/usr/lib/gstreamer-0.10/)
target_link_libraries( mylibraryormyexecutable gstffmpeg )

when run make above configuration(approach 2), following errors

bin/ld: cannot find -lgstffmpeg

  • q2. how solve issue above approach 2?
  • q3. approach 1 or 2 better ?

p.s. tried reading documentation cmake , searching on not resolve problem. tried 2 approaches , have issues both them

to answer q3 first, think preferred method approach 1.

from docs link_directories:

note command necessary. library locations returned find_package() , find_library() absolute paths. pass these absolute library file paths directly target_link_libraries() command. cmake ensure linker finds them.

regardless of approach take, don't know of easy way automatically list of these "sub-dependencies" , add them. i'd find_package or find_library each.

at least way, if dependency isn't found, project fails @ cmake configure time rather @ link time.


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -