首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >libVLC\make:未定义的对`libvlc_new‘的引用

libVLC\make:未定义的对`libvlc_new‘的引用
EN

Stack Overflow用户
提问于 2019-04-02 22:36:03
回答 1查看 644关注 0票数 1

对于一个小项目,我决定使用libvlc,因此使用C/C++。

使用不同的引用,我以某种方式安装了opencv和libvlc库,并编写了以下CMake文件:

代码语言:javascript
复制
cmake_minimum_required(VERSION 3.10)
project(untitled1)

set(CMAKE_CXX_STANDARD 14)
SET(CMAKE_MODULE_PATH
        ${CMAKE_SOURCE_DIR}/cmake
        ${CMAKE_SOURCE_DIR}/config
        ${CMAKE_SOURCE_DIR}/config/platform
        )

find_package(OpenCV REQUIRED)
find_package(LIBVLC REQUIRED)



file(GLOB SOURCE_FILES
        "${CMAKE_CURRENT_SOURCE_DIR}/*.h"
        "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
        )
add_executable(untitled1 ${SOURCE_FILES})

# If the package has been found, several variables will
# be set, you can find the full list with descriptions
# in the OpenCVConfig.cmake file.
# Print some message showing some of them
message(STATUS "OpenCV library status:")
message(STATUS "    version: ${OpenCV_VERSION}")
message(STATUS "    libraries: ${OpenCV_LIBS}")
message(STATUS "    include path: ${OpenCV_INCLUDE_DIRS}")

if(CMAKE_VERSION VERSION_LESS "2.8.11")
    # Add OpenCV headers location to your include paths
    include_directories(${OpenCV_INCLUDE_DIRS})
endif()


include_directories(${OpenCV_INCLUDE_DIRS})
include_directories(${LIBVLC_INCLUDE_DIRS})

set(LIBS ${LIBS} ${OpenCV_LIBS})
set(LIBS ${LIBS} ${LIBVLC_LIBRARIES} )



target_link_libraries( untitled1 ${LIBS})

但是,当我这样做时,cmakemake会得到以下错误:

代码语言:javascript
复制
[100%] Linking CXX executable untitled1
CMakeFiles/untitled1.dir/VLCReader.cpp.o: In function `VLCReader::VLCReader(char*)':
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:17: undefined reference to `libvlc_new'
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:18: undefined reference to `libvlc_media_player_new'
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:21: undefined reference to `libvlc_video_set_callbacks'
CMakeFiles/untitled1.dir/VLCReader.cpp.o: In function `VLCReader::~VLCReader()':
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:26: undefined reference to `libvlc_media_player_stop'
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:27: undefined reference to `libvlc_media_player_release'
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:28: undefined reference to `libvlc_release'
CMakeFiles/untitled1.dir/VLCReader.cpp.o: In function `VLCReader::start(int, int)':
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:33: undefined reference to `libvlc_media_player_pause'
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:34: undefined reference to `libvlc_media_new_location'
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:35: undefined reference to `libvlc_media_player_set_media'
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:36: undefined reference to `libvlc_media_release'
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:38: undefined reference to `libvlc_video_set_format'
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:39: undefined reference to `libvlc_media_player_play'
CMakeFiles/untitled1.dir/VLCReader.cpp.o: In function `VLCReader::pause(bool)':
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:45: undefined reference to `libvlc_media_player_set_pause'
CMakeFiles/untitled1.dir/VLCReader.cpp.o: In function `VLCReader::updataSize()':
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:51: undefined reference to `libvlc_video_get_width'
/home/ravinder/CLionProjects/untitled1/VLCReader.cpp:52: undefined reference to `libvlc_video_get_height'
collect2: error: ld returned 1 exit status
CMakeFiles/untitled1.dir/build.make:166: recipe for target 'untitled1' failed

请帮我继续前进。我对基于C/C++的C/C++ cmake世界非常陌生。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-04-04 18:05:21

谢谢,Tsyvarev和其他人帮助我朝正确的方向发展。

我在CMake文件中的错误是,我使用了错误的变量名,或者说使用了未定义的变量。

LIBVLC_INCLUDE_DIRSLIBVLC_INCLUDE_DIR

LIBVLC_LIBRARIESLIBVLC_LIBRARY

谢谢大家!

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55484472

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档