在Linux上静态编译osgconv并支持obj文件

时间:2016-04-29 12:45:22

标签: c++ linux cmake static-linking openscenegraph

我在Linux(32位)上编译了OpenSceneGraph 3.4.0,设置了OFF DYNAMIC_OPENSCENEGRAPH和DYNAMIC_OPENTHREADS标志,并在CMake上启用了应用程序和示例。

构建成功,我有静态库,并且示例osgstaticviewer正常工作。

然后我尝试使用静态库编译osgconv,使用从osgstaticviewer复制的CMakeLists.txt并修改添加obj支持和osgconv原始源文件。编译工作和生成的可执行文件工作,但我无法将obj文件转换为osg文件。特别是,如果我尝试命令:

./osgconv myModel.obj myModel.osg

我收到以下警告:

Warning: Could not find plugin to read objects from file "myModel.obj".
Error no data loaded.

关于静态osg插件的链接程序是什么?

在用于编译osgconv的CMakeLists.txt下面:

#this file is automatically generated 

SET(TARGET_ADDED_LIBRARIES osgdb_obj osgdb_ive osgdb_openflight osgdb_osg osgdb_rgb osgdb_osg )
SET(TARGET_ADDED_LIBRARIES ${TARGET_ADDED_LIBRARIES}
    osgdb_deprecated_osg osgdb_deprecated_osgparticle osgdb_deprecated_osganimation
    osgdb_deprecated_osgfx osgdb_deprecated_osgsim osgdb_deprecated_osgtext
    osgdb_deprecated_osgviewer osgdb_deprecated_osgshadow osgdb_deprecated_osgterrain
    osgdb_deprecated_osgvolume osgdb_deprecated_osgwidget
)
SET(TARGET_ADDED_LIBRARIES ${TARGET_ADDED_LIBRARIES}
    osgdb_serializers_osg osgdb_serializers_osgparticle osgdb_serializers_osgtext
    osgdb_serializers_osgterrain osgdb_serializers_osganimation osgdb_serializers_osgfx
    osgdb_serializers_osgshadow osgdb_serializers_osgmanipulator osgdb_serializers_osgsim
    osgdb_serializers_osgvolume
)

IF(FREETYPE_FOUND)
    ADD_DEFINITIONS(-DUSE_FREETYPE)
    SET(TARGET_ADDED_LIBRARIES ${TARGET_ADDED_LIBRARIES} osgdb_freetype)
ENDIF(FREETYPE_FOUND)

SET(TARGET_SRC
    OrientationConverter.cpp 
    osgconv.cpp
)
SET(TARGET_H
    OrientationConverter.h
)

SETUP_APPLICATION(osgconv)

1 个答案:

答案 0 :(得分:1)

您需要修改osgconv的源代码,以使USE_OSGPLUGIN宏看到各种插件的绑定支持: http://trac.openscenegraph.org/projects/osg//browser/OpenSceneGraph/trunk/examples/osgstaticviewer/osgstaticviewer.cpp#L40