查看: 2123|回复: 6

osg在linux的问题...

[复制链接]

该用户从未签到

发表于 2011-12-17 20:16:32 | 显示全部楼层 |阅读模式
本人的windows因为不可抗因素,怎么弄osg都以失败告终,因此转战ubuntu,在软件中心下了osg,发现在终端运行osgiewer 没有问题,但是没有库。。。。因此下载了源代码,根据教程,显示运行了config ,然后在用make 再是install 均没有问题, 库文件在usr/local/lib 然后吗一个win下面的最简单例子弄过来,然后用g++编译 ,所找不到库文件  g++ -i/usr/loacl/includu -losg -losgViewer main.cpp


没办法,就把local的include里面的直接复制到 usr/include


$ g++ -losg -losgViewer -losgDB -losgUtil main.cpp

/tmp/ccpwiCwN.o: In function `main':
main.cpp.text+0x1d): undefined reference to `osgViewer::Viewer::Viewer()'
main.cpp.text+0x37): undefined reference to `osg::Group::Group()'
main.cpp.text+0x51): undefined reference to `osg::Node::Node()'
main.cpp.text+0xe1): undefined reference to `osgUtil::Optimizer:ptimize(osg::Node*)'
/tmp/ccpwiCwN.o: In function `osg::Referenced::unref() const':
后面还有很多错误


本人水平低,希望有人指教~~
谢谢了

该用户从未签到

发表于 2011-12-19 16:48:20 | 显示全部楼层
你确定安装 "make install"成功了吗?那找一下你的头文件,和库文件到底安装在哪个目录下面了。查看环境变量里面的 LD_LIBRARY_PATH 有没有这个库文件的目录。loacl/includu 打错了?

该用户从未签到

 楼主| 发表于 2011-12-19 21:55:53 | 显示全部楼层
确定没有打错 打错了是cannot find。。。。。
linux真是不会用啊。。。

该用户从未签到

发表于 2011-12-20 10:16:30 | 显示全部楼层
已经回答了,请不要重复发帖

该用户从未签到

 楼主| 发表于 2011-12-20 23:07:11 | 显示全部楼层
array 发表于 2011-12-20 10:16
已经回答了,请不要重复发帖

实在抱歉....
没有解决T T

该用户从未签到

发表于 2011-12-23 09:35:40 | 显示全部楼层
那么先去学习一下Linux开发的基本知识吧~~

该用户从未签到

发表于 2021-5-1 21:51:08 | 显示全部楼层
大哥,10年后的我同样也遇到了这个问题,在终端执行osgviewer cow.osg是可以的,/etc/profile也改了,但是就是在VS CODE里面运行以下官方的案例:
  1. #include <osgViewer/Viewer>
  2. #include <osgDB/ReadFile>
  3. int main( )
  4. {
  5.     osgViewer::Viewer viewer;
  6.     viewer.setSceneData( osgDB::readNodeFile( "cow.osg" ) );
  7.     return viewer.run();
  8. }
复制代码

然后就一直都是这个错误:
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


求解决
您需要登录后才可以回帖 登录 | 注册

本版积分规则

OSG中国官方论坛-有您OSG在中国才更好

网站简介:osgChina是国内首个三维相关技术开源社区,旨在为国内更多的技术开发人员提供最前沿的技术资讯,为更多的三维从业者提供一个学习、交流的技术平台。

联系我们

  • 工作时间:09:00--18:00
  • 反馈邮箱:1315785073@qq.com
快速回复 返回顶部 返回列表