我正在尝试在 Visual Studio 上设置 OpenSceneGraph,以便我可以运行一些教程,我相信我的问题是我不知道如何在 Visual Studio 上正确设置环境并让程序查看库文件正确。
有问题的代码仅用于 osg 智能指针演示
#include <osg/ref_ptr>
#include <osg/Referenced>
#include <iostream>
using namespace std;
class AClass : public osg::Referenced
{
public:
AClass(int id) : _id(id)
{
cout << "Constructing object " << _id << endl;
}
protected:
int _id;
virtual ~AClass()
{
cout << "Destroy " << _id << endl;
}
};
int main()
{
osg::ref_ptr<AClass> obj = new AClass(0);
cout << "Reference count before referring: "
<< obj->referenceCount() << endl;
osg::ref_ptr<AClass> anotherObject = object;
cout << "Referenced count after referring: "
<< object->referenceCount() << endl;
}
如果我在“属性”->“链接器”->“附加依赖项”中指向 osgd.lib,这将构建,但是当我尝试运行它时,会发生系统错误,它指出程序无法启动,因为“您的计算机中缺少 osgd.ll”如果我指向 osgd.dll,它将无法构建并抛出以下错误:“LNK1107 无效或损坏的文件:无法读取 0x378 OSG1 C:\Users\Monkone\source\OpenSceneGraph-3.6.3-VC2017-64-调试\bin\osgd.dll”
我在这里做错了什么?
您需要链接到 .lib,而不是 .dll。 dll 路径必须位于您的 PATH 中才能工作,或者与可执行文件位于同一文件夹中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)