libVLC | make:对`libvlc_new'的未定义引用

问题描述 投票:0回答:1

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

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

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})

但当我这样做,cmake然后make我得到以下错误:

[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 ++ cmake的世界的新手。

c++ makefile cmake libvlc
1个回答
0
投票

谢谢@Tsyvarev和其他给我画正确方向的人。

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

LIBVLC_INCLUDE_DIRSLIBVLC_INCLUDE_DIR

LIBVLC_LIBRARIESLIBVLC_LIBRARY

谢谢大家!

© www.soinside.com 2019 - 2024. All rights reserved.