Problem Multiple errors in Orbiter headers at compile time

Matias Saibene

Development hell
Joined
Jul 7, 2012
Messages
1,055
Reaction score
642
Points
128
Location
Monte Hermoso - Argentina
Website
de-todo-un-poco-computacion-e-ideas.blogspot.com.ar
Hello friends of the forum. As I mentioned recently, I am taking my first small steps in programming add-ons for Orbiter.
On Linux I haven't had any problems, but when I try to compile on Windows I get errors on the header files in the Orbiter 2016 include folder.
It's very puzzling because I expected a barrage of bugs in my code, but according to the CodeBlocks log the bugs are in the Orbiter headers.

Unfortunately due to my internet speed I don't have access to Visual Studio Community, but I managed to correctly configure CodeBlocks to search and include Orbiter header files (Orbitersdk\includes) and libraries (Orbitersdk\lib).

Here is my build log:
C++:
||=== Build: Release in Luna3_module (compiler: GNU GCC Compiler) ===|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\OrbiterAPI.h|44|warning: ignoring #pragma warning  [-Wunknown-pragmas]|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\OrbiterAPI.h||In function 'VECTOR3 POINTERTOREF(VECTOR3*)':|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\OrbiterAPI.h|7215|warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\OrbiterAPI.h||In function 'char* ModuleDate()':|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\OrbiterAPI.h|7227|warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\CelBodyAPI.h|441|error: 'ATMOSPHERE' does not name a type|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\CelBodyAPI.h|486|error: 'ATMOSPHERE' has not been declared|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\CelBodyAPI.h|523|error: 'ATMOSPHERE' does not name a type|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\VesselAPI.h||In member function 'bool AnimState::Move(double)':|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\VesselAPI.h|6369|error: 'max' was not declared in this scope|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\VesselAPI.h|6369|note: suggested alternative:|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\bits\stl_algobase.h|265|note:   'std::max'|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\VesselAPI.h|6371|error: 'min' was not declared in this scope|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\VesselAPI.h|6371|note: suggested alternative:|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\bits\stl_algobase.h|243|note:   'std::min'|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\MFDAPI.h|265|error: 'Instrument_User' does not name a type|
C:\Users\Matías Saibene\Desktop\Luna3_orbiter_addon-master\Luna3_CBP\Luna3_module\Luna3.h|47|error: 'int Luna3::clbkConsumeBufferedKey(int, bool, char*)' marked 'override', but does not override|
C:\Users\Matías Saibene\Desktop\Luna3_orbiter_addon-master\Luna3_CBP\Luna3_module\Luna3.cpp||In member function 'virtual void Luna3::clbkSaveState(FILEHANDLE)':|
C:\Users\Matías Saibene\Desktop\Luna3_orbiter_addon-master\Luna3_CBP\Luna3_module\Luna3.cpp|189|warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]|
C:\Users\Matías Saibene\Desktop\Luna3_orbiter_addon-master\Luna3_CBP\Luna3_module\Luna3.cpp||In function 'void ovcExit(VESSEL*)':|
C:\Users\Matías Saibene\Desktop\Luna3_orbiter_addon-master\Luna3_CBP\Luna3_module\Luna3.cpp|247|warning: deleting object of polymorphic class type 'Luna3' which has non-virtual destructor might cause undefined behavior [-Wdelete-non-virtual-dtor]|
||=== Build failed: 7 error(s), 5 warning(s) (0 minute(s), 3 second(s)) ===|

Feel free to correct me if I'm wrong or if I don't know something. Maybe I was too hasty because I thought it would be just as easy as on Linux.
 

nbcfrosty

Active member
Joined
Jun 16, 2023
Messages
173
Reaction score
202
Points
43
Location
US
Hello, what are you trying to compile? Is it an addon? In windows I believe you need to use the vc++ compiler toolkit. Fact that you are using code blocks throws up red flags for me. You should be using visual studio.
 

Matias Saibene

Development hell
Joined
Jul 7, 2012
Messages
1,055
Reaction score
642
Points
128
Location
Monte Hermoso - Argentina
Website
de-todo-un-poco-computacion-e-ideas.blogspot.com.ar
Hello, what are you trying to compile? Is it an addon? In windows I believe you need to use the vc++ compiler toolkit. Fact that you are using code blocks throws up red flags for me. You should be using visual studio.
I am trying to compile a dll module for an add-on for Orbiter. Luna3 is my add-on. So I'm trying to compile Luna3.cpp into Luna3.o and then Luna3.dll. I have bugs in my code that I'm going to fix, but what caught my attention is that I was finding bugs in the Orbiter headers code.

You recommended me VC++ Compiler Toolkit, is it the same as Build Tools for Visual Studio? Because I found a stand-alone package on Microsoft that provides build tools without the need to use Visual Studio.

I have tried to download Visual Studio Community but the download is very large and my internet is very very slow and I couldn't do it. That's why I think I can use VS Build Toolkit to compile and CodeBlocks or VSCode to edit the code. To link the libraries and headers I'm going to use the command line.
 

n72.75

Move slow and try not to break too much.
Orbiter Contributor
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 21, 2008
Messages
2,696
Reaction score
1,353
Points
128
Location
Saco, ME
Website
mwhume.space
Preferred Pronouns
he/him
@D-mo can probably speak better to it than I can, but you do not need the whole Visual Studio. There is a way to build Orbiter add-ons without installing VS.
 

Matias Saibene

Development hell
Joined
Jul 7, 2012
Messages
1,055
Reaction score
642
Points
128
Location
Monte Hermoso - Argentina
Website
de-todo-un-poco-computacion-e-ideas.blogspot.com.ar
@D-mo can probably speak better to it than I can, but you do not need the whole Visual Studio. There is a way to build Orbiter add-ons without installing VS.
Thanks for the warning, I'm going to try downloading VS Studio Community again anyway because I'm getting an absurd amount of header errors. Nonsense errors like fstream could not be found, windows.h, etc.
 

Gondos

Well-known member
Joined
Apr 18, 2022
Messages
231
Reaction score
268
Points
78
Location
On my chair
Hello friends of the forum. As I mentioned recently, I am taking my first small steps in programming add-ons for Orbiter.
On Linux I haven't had any problems, but when I try to compile on Windows I get errors on the header files in the Orbiter 2016 include folder.
It's very puzzling because I expected a barrage of bugs in my code, but according to the CodeBlocks log the bugs are in the Orbiter headers.

Unfortunately due to my internet speed I don't have access to Visual Studio Community, but I managed to correctly configure CodeBlocks to search and include Orbiter header files (Orbitersdk\includes) and libraries (Orbitersdk\lib).

Here is my build log:
C++:
||=== Build: Release in Luna3_module (compiler: GNU GCC Compiler) ===|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\OrbiterAPI.h|44|warning: ignoring #pragma warning  [-Wunknown-pragmas]|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\OrbiterAPI.h||In function 'VECTOR3 POINTERTOREF(VECTOR3*)':|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\OrbiterAPI.h|7215|warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\OrbiterAPI.h||In function 'char* ModuleDate()':|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\OrbiterAPI.h|7227|warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\CelBodyAPI.h|441|error: 'ATMOSPHERE' does not name a type|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\CelBodyAPI.h|486|error: 'ATMOSPHERE' has not been declared|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\CelBodyAPI.h|523|error: 'ATMOSPHERE' does not name a type|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\VesselAPI.h||In member function 'bool AnimState::Move(double)':|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\VesselAPI.h|6369|error: 'max' was not declared in this scope|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\VesselAPI.h|6369|note: suggested alternative:|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\bits\stl_algobase.h|265|note:   'std::max'|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\VesselAPI.h|6371|error: 'min' was not declared in this scope|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\VesselAPI.h|6371|note: suggested alternative:|
C:\Program Files\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\bits\stl_algobase.h|243|note:   'std::min'|
C:\Users\Matías Saibene\Saved Games\Orbiter2016\Orbitersdk\include\MFDAPI.h|265|error: 'Instrument_User' does not name a type|
C:\Users\Matías Saibene\Desktop\Luna3_orbiter_addon-master\Luna3_CBP\Luna3_module\Luna3.h|47|error: 'int Luna3::clbkConsumeBufferedKey(int, bool, char*)' marked 'override', but does not override|
C:\Users\Matías Saibene\Desktop\Luna3_orbiter_addon-master\Luna3_CBP\Luna3_module\Luna3.cpp||In member function 'virtual void Luna3::clbkSaveState(FILEHANDLE)':|
C:\Users\Matías Saibene\Desktop\Luna3_orbiter_addon-master\Luna3_CBP\Luna3_module\Luna3.cpp|189|warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]|
C:\Users\Matías Saibene\Desktop\Luna3_orbiter_addon-master\Luna3_CBP\Luna3_module\Luna3.cpp||In function 'void ovcExit(VESSEL*)':|
C:\Users\Matías Saibene\Desktop\Luna3_orbiter_addon-master\Luna3_CBP\Luna3_module\Luna3.cpp|247|warning: deleting object of polymorphic class type 'Luna3' which has non-virtual destructor might cause undefined behavior [-Wdelete-non-virtual-dtor]|
||=== Build failed: 7 error(s), 5 warning(s) (0 minute(s), 3 second(s)) ===|

Feel free to correct me if I'm wrong or if I don't know something. Maybe I was too hasty because I thought it would be just as easy as on Linux.
You are trying to compile a module developped for linux on Windows but there are some incompatibilities : the first argument of clbkConsumeBufferedKey needs to be a DWORD instead of an int on the Windows version.
Also you should declare your ~Luna3() destructor as virtual.
I'm not sure which SDK you're using but if it's the one provided with the official Orbiter2016, I'm not sure it's compatible with the OpenOrbiter one that you get from github.
 

Matias Saibene

Development hell
Joined
Jul 7, 2012
Messages
1,055
Reaction score
642
Points
128
Location
Monte Hermoso - Argentina
Website
de-todo-un-poco-computacion-e-ideas.blogspot.com.ar
You are trying to compile a module developped for linux on Windows but there are some incompatibilities : the first argument of clbkConsumeBufferedKey needs to be a DWORD instead of an int on the Windows version.
Also you should declare your ~Luna3() destructor as virtual.
I'm not sure which SDK you're using but if it's the one provided with the official Orbiter2016, I'm not sure it's compatible with the OpenOrbiter one that you get from github.
I'm using the Orbiter 2016 SDK for Windows on Windows.
I know that I have errors in my code which I am going to solve and adapt the code for Windows. But what really struck me were the bugs (not in my code) but in the Orbiter SDK headers.
Now that I've done some more research it looks like I need to use the Visual Studio tools in order to build correctly.
Anyway what I have to fix first is to install the headers for Windows, the Windows 10 SDK (to get windows.h), the debugging tools (to get crtdbg.h), and the Visual Studio tools (to get cl.exe).
 

Boxx

Mars Addict
Addon Developer
Donator
Joined
Nov 15, 2009
Messages
183
Reaction score
125
Points
58
Location
Paris Area
@D-mo can probably speak better to it than I can, but you do not need the whole Visual Studio. There is a way to build Orbiter add-ons without installing VS.
Surprising!!! and I would be very interested in that.

Even worse, after compiling my add-ons with VS 2019, my complied modules could not be run with the runtime only and the fix I found was to have VS 2019 installed in windows (10GB more for a non-specialized user... a pity). I requested the runtime at compilation but it could not work. Is there a tuto for compilation setup without VS2019 or with runtime only? EDIT: see discussion for such add-on.
 
Last edited:

Boxx

Mars Addict
Addon Developer
Donator
Joined
Nov 15, 2009
Messages
183
Reaction score
125
Points
58
Location
Paris Area
Additionnally, be warned that NET4 is not supported after VS2019 (maybe no need for some compil) and the download of VS2019 is still possible but hidden behind deep layers of MS marketing to promote the last VS version. At least, that's my latest experience at setting up VS for Orbiter 2016 add-ons
 

n72.75

Move slow and try not to break too much.
Orbiter Contributor
Addon Developer
Tutorial Publisher
Donator
Joined
Mar 21, 2008
Messages
2,696
Reaction score
1,353
Points
128
Location
Saco, ME
Website
mwhume.space
Preferred Pronouns
he/him

D-mo

Member
Orbiter Contributor
Joined
Dec 11, 2014
Messages
43
Reaction score
7
Points
8
Location
US
Top