我已经构建了自己的 Ogre3D http://ogre3d.org二进制文件,现在我想将我在 Qt 中的项目链接到它们(我使用 CMake 作为我的构建工具)。这是我的CMakeLists.txt
文件:
project(ogre_face_test)
cmake_minimum_required(VERSION 2.8)
aux_source_directory(. SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})
include_directories( "/home/XXX/programming/SDKs/OGRE_1.8.1_BUILD/include" "." )
link_directories("/home/XXX/programming/SDKs/OGRE_1.8.1_BUILD/lib")
target_link_libraries( ogre_face_test "OgreMain" )
在.../BUILD/lib
目录中,我有 : 等libOgreMain.so
文件libOgreMain.so.1.8.1
。
我在 Qt Creator 中链接时收到此错误:
/usr/bin/cmake -H/home/XXX/programming/c++/ogre_face_sample/ogre_face_test -B/home/XXX/programming/c++/ogre_face_sample/ogre_face_test-build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/XXX/programming/c++/ogre_face_sample/ogre_face_test-build/CMakeFiles /home/XXX/programming/c++/ogre_face_sample/ogre_face_test-build/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory `/home/XXX/programming/c++/ogre_face_sample/ogre_face_test-build'
make -f CMakeFiles/ogre_face_test.dir/build.make CMakeFiles/ogre_face_test.dir/depend
make[2]: Entering directory `/home/XXX/programming/c++/ogre_face_sample/ogre_face_test-build'
cd /home/XXX/programming/c++/ogre_face_sample/ogre_face_test-build && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/XXX/programming/c++/ogre_face_sample/ogre_face_test /home/XXX/programming/c++/ogre_face_sample/ogre_face_test /home/XXX/programming/c++/ogre_face_sample/ogre_face_test-build /home/XXX/programming/c++/ogre_face_sample/ogre_face_test-build /home/XXX/programming/c++/ogre_face_sample/ogre_face_test-build/CMakeFiles/ogre_face_test.dir/DependInfo.cmake --color=
make[2]: Leaving directory `/home/XXX/programming/c++/ogre_face_sample/ogre_face_test-build'
make -f CMakeFiles/ogre_face_test.dir/build.make CMakeFiles/ogre_face_test.dir/build
make[2]: Entering directory `/home/XXX/programming/c++/ogre_face_sample/ogre_face_test-build'
Linking CXX executable ogre_face_test
/usr/bin/cmake -E cmake_link_script CMakeFiles/ogre_face_test.dir/link.txt --verbose=1
/usr/bin/c++ CMakeFiles/ogre_face_test.dir/main.cpp.o CMakeFiles/ogre_face_test.dir/FacialAnimation.cpp.o -o ogre_face_test -rdynamic -lOgreMain
/usr/bin/ld: cannot find -lOgreMain
collect2: error: ld returned 1 exit status
make[2]: *** [ogre_face_test] Error 1
make[2]: Leaving directory `/home/XXX/programming/c++/ogre_face_sample/ogre_face_test-build'
make[1]: *** [CMakeFiles/ogre_face_test.dir/all] Error 2
make[1]: Leaving directory `/home/XXX/programming/c++/ogre_face_sample/ogre_face_test-build'
make: *** [all] Error 2
编辑
另一方面,如果我使用qmake
而不是CMake
这个文件:
TARGET = qt_test_1
TEMPLATE = app
SOURCES += main.cpp\
FacialAnimation.cpp
HEADERS += FacialAnimation.h
INCLUDEPATH += /usr/include\
/home/monkey/programming/SDKs/OGRE_1.8.1_BUILD/include
DEPENDPATH += /usr/include
LIBS += -L/home/monkey/programming/SDKs/OGRE_1.8.1_BUILD/lib -lOgreMain
它链接得很好。