Orbiter-Forum  

Go Back   Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter SDK
Register Blogs Orbinauts List Social Groups FAQ Projects Mark Forums Read

Orbiter SDK Orbiter software developers post your questions and answers about the SDK, the API interface, LUA, meshing, etc.

Reply
 
Thread Tools
Old 08-26-2019, 03:14 PM   #1
musashi
Orbinaut
Default Visual studio 2017 error LNK2001: unresolved external symbol

Hello guys, I'm trying to compile a simple module following the API_Guide.
That's the code:
Code:
// Dll1.cpp : Defines the exported functions for the DLL application.
//

#include "stdafx.h"

//======================
//Module initialisation
//======================
#define ORBITER_MODULE
#include "orbitersdk.h"
HINSTANCE g_hDLL;

DLLCLBK void InitModule(HINSTANCE hModule)
{
	g_hDLL = hModule;
	// perform global module initialisation here
}
DLLCLBK void ExitModule(HINSTANCE hModule)
{
	// perform module cleanup here
}


//======================
//Vessel initialisation
//======================
class MyVessel : public VESSEL2 
{
    public: 
		MyVessel(OBJHANDLE hObj, int fmodel) : VESSEL2(hObj, fmodel) {} 
		~MyVessel() {} 
		// add more vessel methods here 
        void clbkLoadStateEx(FILEHANDLE scn, void *status); 
        void clbkSaveState(FILEHANDLE scn); 
		void clbkSetClassCaps(FILEHANDLE cfg);
    
    private: 
		double myparam;
}; 


void MyVessel::clbkLoadStateEx(FILEHANDLE scn, void *status) 
{
	char *line; while (oapiReadScenario_nextline(scn, line)) 
	{ 
		if (!_strnicmp(line, "MYPARAM", 7)) 
		{ 
			sscanf_s(line + 7, "%lf", &myparam);
		} 
		else 
		{ 
			ParseScenarioLineEx(line, status); 
		} 
	} 
}

void MyVessel::clbkSaveState(FILEHANDLE scn) 
{ 
	VESSEL2::clbkSaveState(scn);
	oapiWriteScenario_float(scn,"MYPARAM", myparam);
}

void MyVessel::clbkSetClassCaps(FILEHANDLE cfg) 
{
	SetEmptyMass(1000.0); 
	SetSize(10.0); 
	//AddMesh(oapiLoadMeshGlobal(“MyVessel.msh”)); 
	// define vessel capabilities here 
}


DLLCLBK VESSEL *ovcInit (OBJHANDLE hvessel, int flightmodel) 
{ 
	return new MyVessel (hvessel, flightmodel); 
}

DLLCLBK void ovcExit(VESSEL *vessel) 
{
	if (vessel) delete (MyVessel*)vessel; 
}
when trying to compile it gives me the following:
Code:
Dll1.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl oapiWriteScenario_float(void *,char const *,double)" ([email protected]@[email protected])
Now...I think the reason for that is I have changed in orbiterAPI.h:
Code:
OAPIFUNC void oapiWriteScenario_float (FILEHANDLE scn, char *item, double d);
with
Code:
OAPIFUNC void oapiWriteScenario_float (FILEHANDLE scn,const char *item, double d);
this because
Code:
oapiWriteScenario_float(scn,"MYPARAM", myparam);
gave me an error, marked in red on the code, more specifically:
Code:
argument of type "const char*" is incompatible with parameter of type "char*"
same was happening for
Code:
#ifdef ORBITER_MODULE
void dummy();
void calldummy () { dummy(); }
DLLCLBK char *ModuleDate () { return __DATE__; }
#endif
with __DATE__ marked in red and which I changed with
Code:
#ifdef ORBITER_MODULE
void dummy();
void calldummy () { dummy(); }
DLLCLBK const char *ModuleDate () { return __DATE__; }
#endif
So what do you think should I do? Am I missing something or doing something wrong?
Thanks in advance.
musashi is offline   Reply With Quote
Old 08-26-2019, 03:22 PM   #2
GLS
Addon Developer
 
GLS's Avatar
Default

Quote:
Originally Posted by musashi View Post
 Now...I think the reason for that is I have changed in orbiterAPI.h
Hi!
Yeah, you can't change the OrbiterSDK files....
They are your interface to the Orbiter libraries, and those don't change once Martin compiles them. If there are any errors and/or warnings, it's because the user isn't respecting the interface.
GLS is offline   Reply With Quote
Thanked by:
Reply

  Orbiter-Forum > Orbiter Space Flight Simulator > Orbiter SDK


Thread Tools

Posting Rules
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Jump


All times are GMT. The time now is 12:00 AM.

Quick Links Need Help?


About Us | Rules & Guidelines | TOS Policy | Privacy Policy

Orbiter-Forum is hosted at Orbithangar.com
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2019, vBulletin Solutions Inc.
Copyright ©2007 - 2017, Orbiter-Forum.com. All rights reserved.