【发布时间】:2014-05-21 20:58:17
【问题描述】:
我在这个项目中使用 Ogre3D,它是一个 3D 引擎。 实际上我使用 cmake ( add_executable function ) 构建项目
但为了我的项目的利益,我需要获取共享库而不是可执行文件。
这是我的 CMakeLists.txt
project(TestOgre)
cmake_minimum_required(VERSION 2.6)
set(CMAKE_MODULE_PATH "/usr/local/lib/OGRE/cmake/")
#set(CMAKE_CXX_FLAGS "-Wall -W -Werror -ansi -pedantic -g")
# Il s'agit du tutoriel d'exemple, qui utilise quelques fichiers prédéfinis de Ogre. Il faut indique\
r à cmake où se trouvent les includes en question
include_directories ("/usr/local/include/OGRE/")
# Bien sûr, pour compiler Ogre, il faut le chercher, et définir le répertoire contenant les includes\
.
find_package(OGRE REQUIRED)
include_directories (${OGRE_INCLUDE_DIRS})
# L'exemple dépend aussi de OIS, une lib pour gérer la souris, clavier, joystick...
find_package(OIS REQUIRED)
# On définit les sources qu'on veut compiler
SET(SOURCES
main.cpp
Map.cpp
Case.cpp
AObject.cpp
Player.cpp
Game.cpp
UpdateOgre.cpp
InitOgre.cpp
AppDemarrage.cpp)
# On les compile
#add_executable (
# TestOgre ${SOURCES}
#)
// what i have add to get a shared library
add_library (
TestOgre SHARED &{SOURCES}
)
target_link_libraries(TestOgre ${OGRE_LIBRARY} ${OIS_LIBRARY} "/usr/lib/x86_64-linux-gnu/libboost_sy\
stem.so.1.53.0")
【问题讨论】:
-
add_library (TesShared SHARED ${SOURCES})
-
无法为非本项目构建的目标“TestOgre”指定链接库。
-
这是意料之中的。你注释掉了 TestOgre
-
找不到源文件:&{SOURCES} 尝试过扩展 .c 。
-
&{SOURCES} 应该是 ${SOURCES}
标签: makefile cmake shared-libraries ogre