0

我正在开发一个在这里托管的项目:https ://github.com/gtorrent

现在,我们正在尝试实现更好的 Windows 支持。库本身(gtorrent-core)构建良好。然而,每当我们链接它时,都会有许多对各种 libtorrent 函数(我们正在构建的库)的未定义引用。我目前正在使用 MSYS2 和 MinGW-w64-x86_64 来构建项目本身以及所有必需的库。

对于 ncurses gui,我们的 CMakeLists.txt 文件如下

gtorrent-ncurses/CMakelists.txt:

###############
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

PROJECT(gtorrent-ncurses)

SET(gtorrent-ncurses_VERSION_MAJOR 0)
SET(gtorrent-ncurses_VERSION_MINOR 0)
SET(gtorrent-ncurses_VERSION_PATCH 1)
###############

# Configure version into Version.hpp
SET (VERSION ${gtorrent-ncurses_VERSION_MAJOR}.${gtorrent-ncurses_VERSION_MINOR}.${gtorrent-ncurses_VERSION_PATCH})
CONFIGURE_FILE (src/utils/Version.hpp.in Version.hpp @ONLY)

# Set compiler options
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g -Wall")

# Set Cmake to build runtime in cwd
SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})

# Find Boost
SET (Boost_USE_STATIC_LIBS ON)
SET (Boost_USE_MULTITHREADED ON)
SET (Boost_USE_STATIC_RUNTIME OFF)
FIND_PACKAGE(Boost COMPONENTS system REQUIRED)

# Find libtorrent
INCLUDE (FindPkgConfig)
PKG_SEARCH_MODULE (LIBTORRENT REQUIRED libtorrent-rasterbar)

# Find ncurses
INCLUDE(CheckLibraryExists)
PKG_SEARCH_MODULE (NCURSESPP REQUIRED ncurses++w)
PKG_SEARCH_MODULE (NCURSES REQUIRED ncursesw)
PKG_SEARCH_MODULE (NCURSESPANEL REQUIRED panelw)

# To find version
INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})

ADD_DEFINITIONS (
    ${LIBTORRENT_CFLAGS}
    )

ADD_SUBDIRECTORY(gtorrent-core)
ADD_SUBDIRECTORY(src)

gtorrent-ncurses/src/CMakeLists.txt

INCLUDE_DIRECTORIES (
  ${Boost_INCLUDE_DIRS}
  ${LIBTORRENT_INCLUDE_DIRS}
  ${NCURSESPP_INCLUDE_DIRS}
  ${NCURSES_INCLUDE_DIRS}
  ${CMAKE_SOURCE_DIR}/gtorrent-core/include
  )

ADD_DEFINITIONS (
  ${LIBTORRENT_CFLAGS}
  )

ADD_EXECUTABLE ( gtorrent-ncurses
  main.cpp
  Application.cpp
  MainWindow.cpp
  TorrentView.cpp
  StatusView.cpp
  AddTorrent.cpp
  )

ADD_DEPENDENCIES (gtorrent-ncurses
  gtorrent
  )

LINK_DIRECTORIES (
  ${Boost_LIBRARY_DIRS}
  ${LIBTORRENT_LIBRARY_DIRS}
  )

TARGET_LINK_LIBRARIES ( gtorrent-ncurses
  ${CMAKE_BINARY_DIR}/gtorrent-core/src/libgtorrent.a
  ${Boost_LIBRARIES}
  ${LIBTORRENT_LIBRARIES}
  ${NCURSESPP_LIBRARIES}
  ${NCURSES_LIBRARIES}
  ${NCURSESPANEL_LIBRARIES}
  )

INSTALL (TARGETS gtorrent-ncurses RUNTIME DESTINATION ${PREFIX}/bin/ PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

这是编译器错误(太大而无法发布): http: //pastebin.com/v3fPXXAE

有什么想法有什么问题吗?

4

1 回答 1

0

您在 LIBTORRENT_LIBRARIES 之前链接 BOOST_LIBRARIES。尝试切换顺序,先链接LIBTORRENT_LIBRARIES,再链接BOOST_LIBRARIES。链接器仅链接库中那些实际被之前已链接的对象使用的对象。

于 2014-08-13T15:18:18.473 回答