获取 LNK1107 无效或损坏的文件:尝试为 OpenSceneGraph 教程链接 .dll 时无法读取 0x378 [英] Getting LNK1107 invalid or corrupt file: cannot read at 0x378 when trying to link .dll for OpenSceneGraph tutorial

查看:50
本文介绍了获取 LNK1107 无效或损坏的文件:尝试为 OpenSceneGraph 教程链接 .dll 时无法读取 0x378的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 Visual Studio 上设置 OpenSceneGraph,以便我可以运行一些教程,我相信我的问题是我不知道如何在 Visual Studio 上正确设置环境并让程序查看库文件正确.

I'm trying to get OpenSceneGraph set up on visual studio so I can run through some tutorials and I believe my issue is that I do not know how to correctly set up the environment on visual studios and get the program to look at the library files correctly.

有问题的代码仅用于 osg 智能指针演示

The code in question is just for a osg smart pointer demonstration

    #include <osg/ref_ptr>
    #include <osg/Referenced>
    #include <iostream>
    using namespace std;

    class MonitoringTarget : public osg::Referenced
    {
    public:
        MonitoringTarget(int id) : _id(id)
        {
            cout << "Constructing target " << _id << endl;
        }
    protected:
        int _id;
        virtual ~MonitoringTarget()
        {
            cout << "Destroy " << _id << endl;
        }
    };

    int main()
    {
        osg::ref_ptr<MonitoringTarget> target = new MonitoringTarget(0);
        cout << "Reference count before referring: "
            << target->referenceCount() << endl;
        osg::ref_ptr<MonitoringTarget> anotherTarget = target;
        cout << "Referenced count after referring: "
            << target->referenceCount() << endl;
    }

如果我在属性"->链接器"->附加依赖项"中指向 osgd.lib,这将构建,但是当我尝试运行它时,会出现系统错误,它指出程序无法启动,因为您的计算机中缺少 osgd.ll",但是如果我指向 osgd.dll 它将无法构建并抛出以下错误:LNK1107 无效或损坏的文件:无法读取 0x378 OSG1 C:\Users\Monkone\source\OpenSceneGraph-3.6.3-VC2017-64-Debug\bin\osgd.dll"

If I point to osgd.lib in Properties->Linker->additional dependencies this will build but when I try to run it a system error occurs whereby it states the program cannot start because "osgd.ll is missing from your computer", however if I point to osgd.dll it will fail to build and throw up the following error: "LNK1107 invalid or corrupt file: cannot read at 0x378 OSG1 C:\Users\Monkone\source\OpenSceneGraph-3.6.3-VC2017-64-Debug\bin\osgd.dll"

我在这里做错了什么?

推荐答案

您需要链接到 .lib,而不是 .dll.dll 路径必须在您的 PATH 中才能工作或与可执行文件位于同一文件夹中.

You need to link against the .lib, not the .dll. The dll path must be in your PATH to work or in the same folder as the executable.

这篇关于获取 LNK1107 无效或损坏的文件:尝试为 OpenSceneGraph 教程链接 .dll 时无法读取 0x378的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆