项目中的链接错误:cmake

时间:2016-07-03 07:52:02

标签: c++ cmake

这是我项目的目录结构:

|-- CMakeLists.txt
|-- libdashframework
|   |-- Buffer
|   |   |-- IMediaObjectBufferObserver.h
|   |   |-- MediaObjectBuffer.cpp
|   |   `-- MediaObjectBuffer.h
|   |-- Input
|   |   |-- DASHReceiver.cpp
|   |   |-- DASHReceiver.h
|   |   |-- IDASHReceiverObserver.h
|   |   `-- MediaObject.h
|   |-- MPD
|   |   |-- AbstractRepresentationStream.cpp
|   |   |-- AbstractRepresentationStream.h
|   |   |-- AdaptationSetStream.cpp
|   |   |-- AdaptationSetStream.h
|   |   |-- BaseUrlResolver.cpp
|   |   |-- BaseUrlResolver.h
|   |   |-- IRepresentationStream.h
|   |   |-- RepresentationStreamFactory.cpp
|   |   |-- RepresentationStreamFactory.h
|   |   |-- SegmentListStream.cpp
|   |   |-- SegmentListStream.h
|   |   |-- SegmentTemplateStream.cpp
|   |   |-- SegmentTemplateStream.h
|   |   |-- SingleMediaSegmentStream.cpp
|   |   |-- SingleMediaSegmentStream.h
|   |   |-- TimeResolver.cpp
|   |   `-- TimeResolver.h
|   `-- Portable
|       |-- MultiThreading.cpp
|       `-- MultiThreading.h
|-- libdash_test_automoc.cpp
|-- libdash_test.cpp
`-- Makefile

我在项目中遇到链接错误,无法弄清楚如何删除它。

的CMakeLists.txt:

cmake_minimum_required(VERSION 2.8)
file(GLOB test_source RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
        libdashframework/MPD/*.cpp
        libdashframework/Buffer/*.cpp
        libdashframework/Input/*.cpp
        libdashframework/Portable/*.cpp 
        libdash_test.cpp )

add_executable(libdash_test ${test_source})
target_link_libraries(libdash_test dash -lpthread)

错误:

Linking CXX executable libdash_test
CMakeFiles/libdash_test.dir/libdashframework/Buffer/MediaObjectBuffer.cpp.o: In function `libdash::framework::buffer::MediaObjectBuffer::SetEOS(bool)':
MediaObjectBuffer.cpp:(.text+0x55d): undefined reference to `libdash::framework::input::MediaObject::AbortDownload()'
CMakeFiles/libdash_test.dir/libdashframework/Input/DASHReceiver.cpp.o: In function `libdash::framework::input::DASHReceiver::GetNextSegment()':
DASHReceiver.cpp:(.text+0x48e): undefined reference to `libdash::framework::input::MediaObject::MediaObject(dash::mpd::ISegment*, dash::mpd::IRepresentation*)'
CMakeFiles/libdash_test.dir/libdashframework/Input/DASHReceiver.cpp.o: In function `libdash::framework::input::DASHReceiver::GetSegment(unsigned int)':
DASHReceiver.cpp:(.text+0x57f): undefined reference to `libdash::framework::input::MediaObject::MediaObject(dash::mpd::ISegment*, dash::mpd::IRepresentation*)'
CMakeFiles/libdash_test.dir/libdashframework/Input/DASHReceiver.cpp.o: In function `libdash::framework::input::DASHReceiver::GetInitSegment()':
DASHReceiver.cpp:(.text+0x615): undefined reference to `libdash::framework::input::MediaObject::MediaObject(dash::mpd::ISegment*, dash::mpd::IRepresentation*)'
CMakeFiles/libdash_test.dir/libdashframework/Input/DASHReceiver.cpp.o: In function `libdash::framework::input::DASHReceiver::DownloadInitSegment(dash::mpd::IRepresentation*)':
DASHReceiver.cpp:(.text+0x9b0): undefined reference to `libdash::framework::input::MediaObject::StartDownload()'
CMakeFiles/libdash_test.dir/libdashframework/Input/DASHReceiver.cpp.o: In function `libdash::framework::input::DASHReceiver::DoBuffering(void*)':
DASHReceiver.cpp:(.text+0xa84): undefined reference to `libdash::framework::input::MediaObject::StartDownload()'
DASHReceiver.cpp:(.text+0xab5): undefined reference to `libdash::framework::input::MediaObject::WaitFinished()'
collect2: error: ld returned 1 exit status
make[2]: *** [libdash_test] Error 1
make[1]: *** [CMakeFiles/libdash_test.dir/all] Error 2
make: *** [all] Error 2

如何删除此链接错误? 在阅读其他类似问题后,我尝试并更改了file()函数中文件的顺序。该订单类似于一个工作示例项目,所以我认为这不是问题。

编辑:

虽然我已将libdash的so文件链接到/usr/bin/usr/lib/目录中。但我也更新了cmake。它仍然无济于事。

更新了CMakeLists.txt:

cmake_minimum_required(VERSION 2.8)
project(libdash_test)


set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH})
set(CMAKE_CXX_FLAGS "-D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS")  


# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc automatically when needed.
set(CMAKE_AUTOMOC ON)


#libdash has to be manually installed 
set (DASH_INCLUDE_DIR /usr/include/libdash)
find_package(DASH REQUIRED)
link_directories(${DASH_LIBRARIES})

#set(LIBDASH_LIBRARIES "../build/bin" CACHE PATH "Path to libdash.so")
#set(LIBDASH_INCLUDES "../libdash/include/" CACHE PATH "Path to libdash includes")

file(GLOB test_source RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
        libdashframework/MPD/*.cpp
        libdashframework/Buffer/*.cpp
        libdashframework/Input/*.cpp
        libdashframework/Portable/*.cpp 
        libdash_test.cpp )


add_executable(libdash_test ${test_source})
target_link_libraries(libdash_test DASH -ldash ${DASH_LIBRARIES} -lpthread)

当前CMakeLists.txt(EDIT下的那个)出错:

CMake Error at CMakeLists.txt:20 (find_package):
  By not providing "FindDASH.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "DASH", but
  CMake did not find one.

  Could not find a package configuration file provided by "DASH" with any of
  the following names:

    DASHConfig.cmake
    dash-config.cmake

  Add the installation prefix of "DASH" to CMAKE_PREFIX_PATH or set
  "DASH_DIR" to a directory containing one of the above files.  If "DASH"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!

0 个答案:

没有答案