Error Visual studio 2017 error LNK2001: unresolved external symbol

musashi

New member
Joined
Jun 17, 2019
Messages
3
Reaction score
0
Points
0
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.
 

GLS

Well-known member
Orbiter Contributor
Addon Developer
Joined
Mar 22, 2008
Messages
5,207
Reaction score
2,007
Points
188
Website
github.com
Now...I think the reason for that is I have changed in orbiterAPI.h

Hi!
Yeah, you can't change the OrbiterSDK files.... :uhh:
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. :shrug:
 
Top