未定义对“ libvlc_new”的引用但链接正确吗? [英] Undefined reference to 'libvlc_new" but linked correctly?

查看:480
本文介绍了未定义对“ libvlc_new”的引用但链接正确吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在使用C ++的基于ROS的项目中使用VLC库。我使用QT Creator作为代码编辑器。

I want to use the VLC library in a ROS-based project using C++. I am using QT Creator as code editor.

我试图按照以下教程来实现mp3文件的简单播放:使用libvlc播放mp3的简单C程序

I tried to follow the following tutorial to implement a simple playback of a mp3 file: A simple C program to play mp3 using libvlc

Since then I'm getting the following exceptions:
undefined reference to `libvlc_new'
undefined reference to `libvlc_media_new_path'
undefined reference to `libvlc_media_player_new_from_media'
undefined reference to `libvlc_media_release'
undefined reference to `libvlc_media_player_play'
undefined reference to `libvlc_media_player_stop'
undefined reference to `libvlc_media_player_release'
undefined reference to `libvlc_release'
collect2: ld returned 1 exit status
make[2]: *** [../bin/my_face_tracker_demo] Error 1
make[1]: *** [CMakeFiles/my_face_tracker_demo.dir/all] Error 2
make: *** [all] Error 2
The process "/usr/bin/make" exited with code 2.
Error while building project my_qbo_interaction (target: Desktop)
When executing build step 'Make'

我当然将 #include vlc / vlc.h 添加到文件中。此外,我按照 http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries上的说明进行操作以确保我添加了链接器的引用。这是我添加到cmakelist.txt文件中的内容:

Of course I added #include "vlc/vlc.h" to the file. Furthermore, I followed the instructions on http://www.cmake.org/Wiki/CMake:How_To_Find_Libraries to make sure I add the references for the linker. This is what I added to the cmakelist.txt-file:

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
find_package(LIBVLC REQUIRED)
include_directories(${LIBVLC_INCLUDE_DIRS})
set(LIBS ${LIBS} ${LIBVLC_LIBRARIES})

make能够编译文件。它还能够找到LIBVLC库。这里是make输出的一部分:

make is able to compile the file. It is also able to find the LIBVLC libraries. Here a part of the output from make:


-找到了LibVLC include-dir路径:/ usr / include
-找到LibVLC库路径:/usr/lib/libvlc.so
-找到LibVLCcore库路径:/usr/lib/libvlccore.so
-找到LibVLC版本:1.1.12(搜索:0.0 )
-配置完成的
-生成完成的CMake警告:项目未使用手动指定的变量:

-- Found LibVLC include-dir path: /usr/include -- Found LibVLC library path:/usr/lib/libvlc.so -- Found LibVLCcore library path:/usr/lib/libvlccore.so -- Found LibVLC version: 1.1.12 (searched for: 0.0) -- Configuring done -- Generating done CMake Warning: Manually-specified variables were not used by the project:

CMAKE_TOOLCHAIN_FILE


但我仍然收到上述错误消息...有人可以帮助我吗?

But I still get the above error messages... Can anybody help me?

推荐答案

似乎已正确找到VLC库,但是您实际上需要将它们链接到可执行文件中。

It looks like the VLC libraries have been correctly found, but you need to actually link them into your executable.

您可以通过 target_link_库 命令。例如:

You do this via the target_link_libraries command. For example:

set(LIBS ${LIBS} ${LIBVLC_LIBRARIES})
add_executable(MyExe ${TheSources})
target_link_libraries(MyExe ${LIBS})

这篇关于未定义对“ libvlc_new”的引用但链接正确吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆