Error Compiling ERRORS

NOMAD

Member
Joined
Aug 10, 2009
Messages
111
Reaction score
1
Points
18
Hello,
I build a Rocket (no verniers and RCS)and try to compile it ,but there are 4 errors show in c++. I managed to find the problems but I failed.I don't know what's wrong with my code,so I post it here and hope someone can help me find the solution. Thanks!

Here is the code:


Code:
#define ORBITER_MODULE
#define STRICT
#include "Orbitersdk.h"

//=============================================================
//Some Parameters of the Rocket
//=============================================================
const double MAX_MAIN_FUEL = 1.6e3;
const double MAX_MAIN_Thrust = 5.4e4;
const double VAC_MAIN_ISP = 5400;
const double NML_MAIN_ISP = 4500;
const double P_NML = 101.4e3;
//=============================================================
class Rocket: public VESSEL2 {
public:
    Rocket (OBJHANDLE hObj, int fmodel): VESSEL2 (hObj, fmodel) {}
    ~Rocket () {} 
        PROPELLANT_HANDLE ph_main;
        THRUSTER_HANDLE th_main;
        void Rocket::clbkSetClassCaps (FILEHANDLE cfg)
        {
        SetSize (23.0);
        SetEmptyMass (2000);
        SetCrossSections (_V(179.19,12.02,179.06));
        SetPMI (_V(632.84,1.74,632.85));
        AddMesh ("test_rocket");
        ph_main = CreatePropellantResource (MAX_MAIN_FUEL);
        th_main = CreateThruster (_V(0,2.2,0), _V(0,3,0), MAX_MAIN_Thrust, ph_main ,VAC_MAIN_ISP, NML_MAIN_ISP, P_NML);
        AddExhaust (th_main, 18, 3);
        }
}
//=============================================================

DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel)
{
    return new Rocket (hvessel, flightmodel);
}
DLLCLBK void ovcExit (VESSEL *vessel)
{
    if (vessel) delete (Rocket*)vessel;
}


Error messages:

Code:
1>------ 已启动生成: 项目: ROCKET, 配置: Release Win32 ------
1>正在编译...
1>ROCKET.cpp
1>.\ROCKET.cpp(34) : error C2143: 语法错误 : 缺少“;”(在“字符串”的前面)
1>.\ROCKET.cpp(34) : error C2059: 语法错误 : “字符串”
1>.\ROCKET.cpp(35) : error C2143: 语法错误 : 缺少“;”(在“{”的前面)
1>.\ROCKET.cpp(35) : error C2447: “{”: 缺少函数标题(是否是老式的形式表?)
1>生成日志保存在“file://d:\My Documents\Visual Studio 2008\Projects\ROCKET\ROCKET\Release\BuildLog.htm”
1>ROCKET - 4 个错误,0 个警告
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========


I translate it into English:

Code:
1 >------ Build started: Project: ROCKET, Configuration: Release  Win32 ------ 
1> Compiling ... 
1> ROCKET.cpp 
1>. \ ROCKET.cpp (34):  error C2143: syntax error: missing ";" (in the "string" in front) 
1>. \  ROCKET.cpp (34): error C2059: syntax error: "string" 
1>. \ ROCKET.cpp (35):  error C2143: syntax error: missing ";" (in "{" in front) 
1>. \ ROCKET.cpp  (35): error C2447: "{": missing function header (whether in the form of  old-fashioned table?) 
1> Build log was saved at "file: / / d: \ My Documents  \ Visual Studio 2008 \ Projects \ ROCKET \ ROCKET \ Release \ BuildLog.htm"  
1> ROCKET - 4 errors, 0 warnings ======== == Build: 0 succeeded, 1 failed,  the latest 0, 0 skipped ==========
 
Last edited:

dbeachy1

O-F Administrator
Administrator
Orbiter Contributor
Addon Developer
Donator
Beta Tester
Joined
Jan 14, 2008
Messages
9,217
Reaction score
1,563
Points
203
Location
VA
Website
alteaaerospace.com
Preferred Pronouns
he/him
You need a semicolon after the closing brace in your class definition. :)

i.e.,
Code:
class Rocket: public VESSEL2 {
...snip...
}[COLOR="Red"];[/COLOR]
 

eveningsky339

Resident Orbiter Slave
Addon Developer
Donator
Joined
May 3, 2008
Messages
1,062
Reaction score
1
Points
0
Location
Western Maine
You need a semicolon after the closing brace in your class definition. :)

i.e.,
Code:
class Rocket: public VESSEL2 {
...snip...
}[COLOR=Red];[/COLOR]
Semi-colons: the Satans of C programming.
 

NOMAD

Member
Joined
Aug 10, 2009
Messages
111
Reaction score
1
Points
18
Thanks for your help,I have add the semicolon.But there is a problem disturbing me.The c++ show 38 errors,the error is error LNK2001:Unresolved external symbol. This error looks very strange! How can I do? Thanks!
Here is the error messages:

Code:
1>------ 已启动生成: 项目: ROCKET, 配置: Release Win32 ------
1>正在编译...
1>ROCKET.cpp
1>正在链接...
1>   正在创建库 D:\My Documents\Visual Studio 2008\Projects\ROCKET\Release\ROCKET.lib 和对象 D:\My Documents\Visual Studio 2008\Projects\ROCKET\Release\ROCKET.exp
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: unsigned int __thiscall VESSEL::AddExhaust(void *,double,double,void *)const " (__imp_?AddExhaust@VESSEL@@QBEIPAXNN0@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: unsigned int __thiscall VESSEL::AddMesh(char const *,union VECTOR3 const *)const " (__imp_?AddMesh@VESSEL@@QBEIPBDPBTVECTOR3@@@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: void * __thiscall VESSEL::CreateThruster(union VECTOR3 const &,union VECTOR3 const &,double,void *,double,double,double)const " (__imp_?CreateThruster@VESSEL@@QBEPAXABTVECTOR3@@0NPAXNNN@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: void * __thiscall VESSEL::CreatePropellantResource(double,double,double)const " (__imp_?CreatePropellantResource@VESSEL@@QBEPAXNNN@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: void __thiscall VESSEL::SetPMI(union VECTOR3 const &)const " (__imp_?SetPMI@VESSEL@@QBEXABTVECTOR3@@@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: void __thiscall VESSEL::SetCrossSections(union VECTOR3 const &)const " (__imp_?SetCrossSections@VESSEL@@QBEXABTVECTOR3@@@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: void __thiscall VESSEL::SetEmptyMass(double)const " (__imp_?SetEmptyMass@VESSEL@@QBEXN@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: void __thiscall VESSEL::SetSize(double)const " (__imp_?SetSize@VESSEL@@QBEXN@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual bool __thiscall VESSEL2::clbkVCRedrawEvent(int,int,void *)" (__imp_?clbkVCRedrawEvent@VESSEL2@@UAE_NHHPAX@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual bool __thiscall VESSEL2::clbkVCMouseEvent(int,int,union VECTOR3 &)" (__imp_?clbkVCMouseEvent@VESSEL2@@UAE_NHHAATVECTOR3@@@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual bool __thiscall VESSEL2::clbkLoadVC(int)" (__imp_?clbkLoadVC@VESSEL2@@UAE_NH@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual bool __thiscall VESSEL2::clbkPanelRedrawEvent(int,int,void *)" (__imp_?clbkPanelRedrawEvent@VESSEL2@@UAE_NHHPAX@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual bool __thiscall VESSEL2::clbkPanelMouseEvent(int,int,int,int)" (__imp_?clbkPanelMouseEvent@VESSEL2@@UAE_NHHHH@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual bool __thiscall VESSEL2::clbkLoadPanel(int)" (__imp_?clbkLoadPanel@VESSEL2@@UAE_NH@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual bool __thiscall VESSEL2::clbkLoadGenericCockpit(void)" (__imp_?clbkLoadGenericCockpit@VESSEL2@@UAE_NXZ)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual int __thiscall VESSEL2::clbkConsumeBufferedKey(unsigned long,bool,char *)" (__imp_?clbkConsumeBufferedKey@VESSEL2@@UAEHK_NPAD@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual int __thiscall VESSEL2::clbkConsumeDirectKey(char *)" (__imp_?clbkConsumeDirectKey@VESSEL2@@UAEHPAD@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual void __thiscall VESSEL2::clbkAnimate(double)" (__imp_?clbkAnimate@VESSEL2@@UAEXN@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual void __thiscall VESSEL2::clbkDockEvent(int,void *)" (__imp_?clbkDockEvent@VESSEL2@@UAEXHPAX@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual void __thiscall VESSEL2::clbkNavMode(int,bool)" (__imp_?clbkNavMode@VESSEL2@@UAEXH_N@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual void __thiscall VESSEL2::clbkMFDMode(int,int)" (__imp_?clbkMFDMode@VESSEL2@@UAEXHH@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual void __thiscall VESSEL2::clbkHUDMode(int)" (__imp_?clbkHUDMode@VESSEL2@@UAEXH@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual void __thiscall VESSEL2::clbkADCtrlMode(unsigned long)" (__imp_?clbkADCtrlMode@VESSEL2@@UAEXK@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual void __thiscall VESSEL2::clbkRCSMode(int)" (__imp_?clbkRCSMode@VESSEL2@@UAEXH@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual void __thiscall VESSEL2::clbkDrawHUD(int,struct HUDPAINTSPEC const *,struct HDC__ *)" (__imp_?clbkDrawHUD@VESSEL2@@UAEXHPBUHUDPAINTSPEC@@PAUHDC__@@@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual void __thiscall VESSEL2::clbkVisualDestroyed(void *,int)" (__imp_?clbkVisualDestroyed@VESSEL2@@UAEXPAXH@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual void __thiscall VESSEL2::clbkVisualCreated(void *,int)" (__imp_?clbkVisualCreated@VESSEL2@@UAEXPAXH@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual bool __thiscall VESSEL2::clbkPlaybackEvent(double,double,char const *,char const *)" (__imp_?clbkPlaybackEvent@VESSEL2@@UAE_NNNPBD0@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual void __thiscall VESSEL2::clbkPostStep(double,double,double)" (__imp_?clbkPostStep@VESSEL2@@UAEXNNN@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual void __thiscall VESSEL2::clbkPreStep(double,double,double)" (__imp_?clbkPreStep@VESSEL2@@UAEXNNN@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual void __thiscall VESSEL2::clbkFocusChanged(bool,void *,void *)" (__imp_?clbkFocusChanged@VESSEL2@@UAEX_NPAX1@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual void __thiscall VESSEL2::clbkPostCreation(void)" (__imp_?clbkPostCreation@VESSEL2@@UAEXXZ)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual void __thiscall VESSEL2::clbkSetStateEx(void const *)" (__imp_?clbkSetStateEx@VESSEL2@@UAEXPBX@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual void __thiscall VESSEL2::clbkLoadStateEx(void *,void *)" (__imp_?clbkLoadStateEx@VESSEL2@@UAEXPAX0@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: virtual void __thiscall VESSEL2::clbkSaveState(void *)" (__imp_?clbkSaveState@VESSEL2@@UAEXPAX@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "__declspec(dllimport) public: __thiscall VESSEL2::VESSEL2(void *,int)" (__imp_??0VESSEL2@@QAE@PAXH@Z)
1>ROCKET.obj : error LNK2001: 无法解析的外部符号 "void __cdecl dummy(void)" (?dummy@@YAXXZ)
1>D:\My Documents\Visual Studio 2008\Projects\ROCKET\Release\ROCKET.dll : fatal error LNK1120: 37 个无法解析的外部命令
1>生成日志保存在“file://d:\My Documents\Visual Studio 2008\Projects\ROCKET\ROCKET\Release\BuildLog.htm”
1>ROCKET - 38 个错误,0 个警告
========== 生成: 成功 0 个,失败 1 个,最新 0 个,跳过 0 个 ==========
 

dbeachy1

O-F Administrator
Administrator
Orbiter Contributor
Addon Developer
Donator
Beta Tester
Joined
Jan 14, 2008
Messages
9,217
Reaction score
1,563
Points
203
Location
VA
Website
alteaaerospace.com
Preferred Pronouns
he/him
Please make sure you are linking with the Orbiter libraries (orbiter.lib and Orbitersdk.lib). A good place to start from a template project standpoint is to look at a sample Orbiter C++ project such as Orbitersdk\samples\ShuttlePB\ShuttlePB.sln.
 

NOMAD

Member
Joined
Aug 10, 2009
Messages
111
Reaction score
1
Points
18
Yes ,you're right! I only add the lib path but forget adding orbiter.lib and Orbitersdk.lib .
Now I compile it sucessfully! Thanks very much!
 
Top