My JNI project links against 3 shared libraries: libogg, libvorbis and libtheora.
On Windows everything works fine, and on Linux there are no errors when building my shared library. However, I'm getting a missing symbol: oggpack_readinit
.
My CMakeLists.txt:
cmake_minimum_required(VERSION 3.15)
project(theoraplayer)
set(CMAKE_CXX_STANDARD 14)
include_directories(include)
include_directories(jnihelpers)
link_directories(lib)
if(ANDROID)
set(CMAKE_C_CFLAGS "${CMAKE_C_FLAGS} -D__GXX_EXPERIMENTAL_CXX0X__")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
else()
find_package(JNI REQUIRED)
endif(ANDROID)
include_directories(${JNI_INCLUDE_DIRS})
if (JNI_FOUND)
message (STATUS "JNI_INCLUDE_DIRS=${JNI_INCLUDE_DIRS}")
message (STATUS "JNI_LIBRARIES=${JNI_LIBRARIES}")
else()
message(STATUS "JNI Not found")
endif()
file(GLOB libJniHelpers_SOURCES jnihelpers/*.cpp)
file(GLOB libJniHelpers_HEADERS jnihelpers/*.h)
add_library(theoraplayer SHARED TheoraPlayer.h TheoraPlayer.cpp theoraplay/theoraplay.c ${libJniHelpers_SOURCES} ${libJniHelpers_HEADERS} NativeLogger.h NativeLogger.cpp VideoFrame.h VideoFrame.cpp TheoraDecoder.h TheoraDecoder.cpp MediaInfo.h MediaInfo.cpp AudioPacket.h AudioPacket.cpp)
set_target_properties(theoraplayer PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
set_target_properties(theoraplayer PROPERTIES INSTALL_RPATH "./")
target_link_libraries(theoraplayer ogg vorbis theora)
if(${UNIX})
set(CMAKE_CXX_FLAGS "-fPIC -O2 -Wl,--no-as-needed")
elseif(${WINDOWS})
set(CMAKE_CXX_FLAGS "/MP /EHsc /O2 /GL")
endif(${UNIX})
When I run ldd
on the built library, none of the 3 libraries show up:
ldd libtheoraplayer.so
linux-vdso.so.1 (0x00007fffadd8c000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fdfc9ed0000)
libm.so.6 => /lib64/libm.so.6 (0x00007fdfc9d88000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fdfc9d68000)
libc.so.6 => /lib64/libc.so.6 (0x00007fdfc9b98000)
/lib64/ld-linux-x86-64.so.2 (0x00007fdfca138000)
question from:
https://stackoverflow.com/questions/65882986/jni-missing-symbol-in-library-built-on-linux 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…