简体   繁体   English

编译Orbiter示例时发生C ++错误-LNK2019无法解析的外部符号

[英]C++ error when compiling Orbiter sample - LNK2019 unresolved external symbol

I have a very specific problem when trying to compile a 'sample' project for the Orbiter space flight simulator. 尝试为Orbiter太空飞行模拟器编译“样本”项目时,我遇到一个非常具体的问题。 I'm trying to compile the sample for the space shuttle 'Atlantis' using the preview version of Visual Studio 2019, and I'm getting an error like: 我正在尝试使用Visual Studio 2019的预览版编译航天飞机'Atlantis'的示例,但出现类似以下错误:

LNK2019 unresolved external symbol "__declspec(dllimport) public: __thiscall VESSEL2::VESSEL2(class VESSEL2 &&)" (__imp_??0VESSEL2@@QAE@$$QAV0@@Z) referenced in function "public: __thiscall Atlantis_SRB::Atlantis_SRB(class Atlantis_SRB &&)" (??0Atlantis_SRB@@QAE@$$QAV0@@Z)

This is happening in the Atlantis_SRB project. 这发生在Atlantis_SRB项目中。 My code is located at: 我的代码位于:

C:\\Orbiter2016\\Orbitersdk\\samples\\Atlantis\\ C:\\ Orbiter2016 \\ Orbitersdk \\ \\样品亚特兰蒂斯\\

I have a lot of experience in software engineering, but I'm a C++ noob. 我在软件工程方面有很多经验,但是我是C ++新手。 I've looked at general help for this error, so I understand that there is something that needs to be linked, but I'm not sure what, or how to do it. 我已经看过该错误的一般帮助,因此我知道需要链接某些内容,但是我不确定该怎么做或如何做。

I looked at this question on the Orbiter forum: 我在Orbiter论坛上看了这个问题:

https://www.orbiter-forum.com/showthread.php?t=24247 https://www.orbiter-forum.com/showthread.php?t=24247

It suggests checking the following under project > properties: 建议在项目>属性下检查以下内容:

Linker - Input - Additional libraries 链接器-输入-其他库

and

Linker - Advanced - Library search paths 链接器-高级-库搜索路径

When I check under the 1st one, I have the following under Linker > Input > Additional Dependencies: 当我检查第一个选项时,在链接器>输入>其他依赖项下有以下内容:

orbiter.lib;orbitersdk.lib;%(AdditionalDependencies)

The 2nd location (Linker - Advanced - Library search paths) doesn't exist. 第二个位置(链接器-高级-库搜索路径)不存在。

I'm used to C# reference errors when dlls are missing from 'references' and know how to solve them quickly, but I'm not sure what to do with this type of C++ issue. 当“参考”中缺少dll时,我习惯了C#参考错误,并且知道如何快速解决它们,但是我不确定如何处理此类C ++问题。

How do I identify what the specific problem is, and what do I need to link, where (and how?!) 我如何确定具体的问题是什么,以及在哪里(以及如何?)需要链接什么?

I posted this problem on the excellent Orbiter forum, and cyph0r provided a fix there which works with VS2017: 我在出色的Orbiter论坛上发布了此问题,并且cyph0r在此处提供了可与VS2017一起使用的修复程序:

https://www.orbiter-forum.com/showthread.php?p=589264&posted=1#post589264 https://www.orbiter-forum.com/showthread.php?p=589264&posted=1#post589264

Basically orbiter.lib seems to only be fully compatible 'out of the box' up to VS2013, and apparently the Atlantis sample compiles fine using VS2013. 基本上,orbiter.lib似乎仅在VS2013之前“完全兼容”,并且显然,Atlantis示例使用VS2013可以很好地进行编译。 (I went back to using VS2017 and implemented cyph0r's fix, which works - I haven't tried VS2019): (我回到使用VS2017并实现了cyph0r的修复程序,该修复程序有效-我没有尝试过VS2019):

This is the significant part of the error: 这是错误的重要部分:

__declspec(dllimport) public: __thiscall VESSEL2::VESSEL2(class VESSEL2 &&)" (__imp_??0VESSEL2@@QAE@$$QAV0@@Z) referenced in function "public: __thiscall Atlantis_SRB::Atlantis_SRB(class Atlantis_SRB &&)

It's indicating that a move constructor is being referenced by the Atlantis_SRB class declaration, which can't be found in VS2017. 这表明Atlantis_SRB类声明正在引用move构造函数,而在VS2017中找不到。 This is the part that's indicating that the move constructor is being referenced: 这是指示正在引用move构造函数的部分:

__declspec(dllimport) public: __thiscall VESSEL2::VESSEL2(class VESSEL2 &&)

The fix is to remove the expectation that this move constructor exists, by editing the Atlantis.h file within the Atlantis sample. 解决方法是通过编辑Atlantis示例中的Atlantis.h文件来消除此移动构造函数存在的期望。 The link to the question on the Orbiter forum gives full details of what you need to do. Orbiter论坛上的问题链接提供了您需要做的所有详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM