galuodo 发表于 2011-12-17 20:16:32

osg在linux的问题...

本人的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':
后面还有很多错误


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

xuganggm 发表于 2011-12-19 16:48:20

你确定安装 "make install"成功了吗?那找一下你的头文件,和库文件到底安装在哪个目录下面了。查看环境变量里面的 LD_LIBRARY_PATH 有没有这个库文件的目录。loacl/includu 打错了?

galuodo 发表于 2011-12-19 21:55:53

确定没有打错 打错了是cannot find。。。。。
linux真是不会用啊。。。

array 发表于 2011-12-20 10:16:30

已经回答了,请不要重复发帖

galuodo 发表于 2011-12-20 23:07:11

array 发表于 2011-12-20 10:16 static/image/common/back.gif
已经回答了,请不要重复发帖

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

array 发表于 2011-12-23 09:35:40

那么先去学习一下Linux开发的基本知识吧~~

HIReaper 发表于 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+0x16): undefined reference to `osgDB::Registry::instance(bool)'
/usr/bin/ld: my.cpp:(.text._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

求解决
页: [1]
查看完整版本: osg在linux的问题...