gcc link single library from custom path but not others

Viewed 119

I'm writing a custom video player for Raspberry Pi that uses ffmpeg for decoding the video and OpenGL on top of GDB and DRM to render it.

To decode video on Raspberry Pi, ffmpeg has to be compiled with MMAL enabled as that's the recommended API for HW accelerated video decoding.

The problem:

Almost all libraries are located in standard path, except MMAL, which is located in /opt/vc/lib/libmmal.so.

Sure, the first thing that everybody thinks of is, just add -L/opt/vc/lib, but it's not that simple:

  • I'm also using /usr/lib/libEGL.so in my program, provided by Mesa.
  • There's also /opt/vc/lib/libEGL.so which I don't want to use because it's the legacy implementation that doesn't work for my case.

If I add -L/opt/vc/lib, it will prioritize that path and pick up the wrong library /opt/vc/lib/libEGL.so.

Is there a way to do something like -L/opt/vc/lib but only for one specific library, while for other libraries it keeps using the standard path? Or is there any other way to solve this problem?

I tried stuff like -l/opt/vc/lib/libmmal.so and that didn't work and I wasn't able find much help, since this is a very specific problem.

Bonus points to anyone, who also knows how to do the same thing in CMake.

1 Answers
src
   Library
       CMakeLists.txt
       lib_main.cpp
   MainProject
       main.cpp
   CMakeLists.txt
CMakeLists.txt

src:CMakeLists.txt

cmake_minimum_required(VERSION 2.8)
project(test)

add_subdirectory(MainProject)
add_subdirectory(Library)

src/Library:CMakeLists.txt

project(MyLibrary)

set(TARGET ${PROJECT_NAME})

set(SOURCES
    lib_main.cpp
)

# additional library paths
link_directories( /usr/local/lib64 )

add_library(${TARGET} SHARED ${SOURCES})

src/MainProject:CMakeLists.txt project(MainProject)

set(TARGET ${PROJECT_NAME})

set(SOURCES
    main.cpp
)

# Target to build
add_executable(${TARGET} ${SOURCES})

### Library linking
target_link_libraries(${TARGET}
    MyLibrary
)
Related