[osg-users] invalid use of incomplete type ‘std::ifstream in readNodeFile

Robert Osfield robert.osfield at gmail.com
Tue Sep 13 08:59:13 PDT 2016


Hi Hong,

Thanks for the example code.  You're Cmake script is hardwired to
certain locations of the OSG I've created a CMakeLists.txt file that
is a bit more flexible utilizing the CMake find scripts for the OSG.
Attached,

I can build and run the example using this cmake script without
problems against the OSG-3.4 branch and master. I don't have 3.4.0 on
my system right now so can't test it right away.

The compiler version that my OSG is building against is:

> c++ --version
c++ (Ubuntu 5.4.0-6ubuntu1~16.04.2) 5.4.0 20160609

Could you try the CMakeLists.txt attached and see if you can reproduce
the compile problem.

Robert.


On 13 September 2016 at 16:37, kyungsoo hong <chesed71 at gmail.com> wrote:
> Hi,
>
> this is the whole code
> #include <iostream>
> #include <osgDB/ReadFile>
> #include <osgViewer/Viewer>
>
> int main() {
>     osg::ref_ptr<osg::Node> root = osgDB::readNodeFile( std::string("cessna.osg" ));
>
>     osgViewer::Viewer viewer;
>     viewer.setSceneData( root.get() );
>     return viewer.run();
> }
>
> and using cmake with below CMakeList
>
> cmake_minimum_required(VERSION 3.6)
> project(osgTester)
> set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}")
> set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
>
> INCLUDE_DIRECTORIES(/usr/local/include/osg)
> INCLUDE_DIRECTORIES(/usr/local/include/OpenThreads)
> INCLUDE_DIRECTORIES(/usr/local/include/osgViewer)
> INCLUDE_DIRECTORIES(/usr/local/include/osgDB)
> INCLUDE_DIRECTORIES(/usr/local/include/osgUtil)
> LINK_DIRECTORIES(/usr/local/lib64/)
>
> add_executable(osgTester main.cpp)
> TARGET_LINK_LIBRARIES(osgTester osg OpenThreads osgViewer osgDB osgUtil)
>
>
>
> Thank you!
>
> Cheers,
> kyungsoo
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=68592#68592
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
-------------- next part --------------
cmake_minimum_required(VERSION 2.6)

SET(PROJECT_NAME test)
PROJECT(${PROJECT_NAME})

FIND_PACKAGE(OpenThreads)
FIND_PACKAGE(osg)
FIND_PACKAGE(osgDB)
FIND_PACKAGE(osgUtil)
FIND_PACKAGE(osgGA)
FIND_PACKAGE(osgViewer)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

SET(SOURCES
    main.cpp
)

INCLUDE_DIRECTORIES(${OPENTHREADS_INCLUDE_DIR} ${OSG_INCLUDE_DIR})

LINK_DIRECTORIES(${OSG_LIB_DIR})

ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCES})

TARGET_LINK_LIBRARIES(${PROJECT_NAME}
    ${OSG_LIBRARIES} ${OSGDB_LIBRARIES} ${OSGVIEWER_LIBRARIES} ${OSGUTIL_LIBRARIES} ${OSGGA_LIBRARIES}
    ${OPENTHREADS_LIBRARIES})


More information about the osg-users mailing list