cmake_minimum_required(VERSION 3.10) project(ogg2mp3) set(CMAKE_CXX_STANDARD 11) # 手动指定 Vorbis 和 MP3Lame 库的路径 set(VORBIS_INCLUDE_DIRS /usr/include) set(VORBIS_LIBRARIES /usr/lib/x86_64-linux-gnu/libvorbisfile.so /usr/lib/x86_64-linux-gnu/libvorbis.so /usr/lib/x86_64-linux-gnu/libogg.so) set(MP3LAME_INCLUDE_DIRS /usr/include) set(MP3LAME_LIBRARIES /usr/lib/x86_64-linux-gnu/libmp3lame.so) # 包含头文件目录 include_directories(${VORBIS_INCLUDE_DIRS}) include_directories(${MP3LAME_INCLUDE_DIRS}) # 添加源文件 set(SOURCES ogg2mp3.cpp) # 创建静态库 add_library(ogg2mp3 STATIC ${SOURCES}) # 链接库 target_link_libraries(ogg2mp3 ${VORBIS_LIBRARIES} ${MP3LAME_LIBRARIES})