|
发表于 2021-5-1 21:51:08
|
显示全部楼层
大哥,10年后的我同样也遇到了这个问题,在终端执行osgviewer cow.osg是可以的,/etc/profile也改了,但是就是在VS CODE里面运行以下官方的案例:
- #include <osgViewer/Viewer>
- #include <osgDB/ReadFile>
- int main( )
- {
- osgViewer::Viewer viewer;
- viewer.setSceneData( osgDB::readNodeFile( "cow.osg" ) );
- return viewer.run();
- }
复制代码
然后就一直都是这个错误:
Code_WorkSpace/Test$ cd "/home/liukai/Documents/Code_WorkSpace/Test/" && g++ my.cpp -o my && "/home/liukai/Documents/Code_WorkSpace/Test/"my
/usr/bin/ld: /tmp/ccntCwhW.o: in function `main':
my.cpp.text+0x2a): undefined reference to `osgViewer::Viewer::Viewer()'
/usr/bin/ld: my.cpp:(.text+0x7a): undefined reference to `osgViewer::Viewer::setSceneData(osg::Node*)'
/usr/bin/ld: my.cpp:(.text+0xa7): undefined reference to `osgViewer::Viewer::run()'
/usr/bin/ld: my.cpp:(.text+0xb9): undefined reference to `osgViewer::Viewer::~Viewer()'
/usr/bin/ld: my.cpp:(.text+0x112): undefined reference to `osgViewer::Viewer::~Viewer()'
/usr/bin/ld: /tmp/ccntCwhW.o: in function `osgDB::readNodeFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
my.cpp:(.text._ZN5osgDB12readNodeFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN5osgDB12readNodeFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x16): undefined reference to `osgDB::Registry::instance(bool)'
/usr/bin/ld: my.cpp:(.text._ZN5osgDB12readNodeFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE[_ZN5osgDB12readNodeFileERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE]+0x30): undefined reference to `osgDB::readNodeFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, osgDB::Options const*)'
collect2: error: ld returned 1 exit status
求解决 |
|