Question How can I remake a DLL from a CPP file?

blixel

Donator
Donator
Joined
Jun 29, 2010
Messages
647
Reaction score
0
Points
16
Burn Time Calculator comes with the CPP file that's needed to build the DLL. What do I have to have if I want to compile that CPP file myself? The reason I want to do this is to simply change 1 word worth of code. (A color change.)

snipet
Code:
SetTextColor( hDC, BRIGHTERGRAY );
	PrintEngUnit(hDC,"Estimate Total dV:     %7.3f","m/s","ft/s",1,mToft, maxdv,5,line7);
	PrintEngUnit(hDC,"Total burn time:       %7.3f","s", TTot,5,line6);
	SetTextColor( hDC, [U][B]BLUE[/B][/U] );
	PrintEngUnit(hDC,"Current vehicle mass:  %7.3f","g","lbm", 1000,gTolb,mv,5,line11);
	PrintEngUnit(hDC,"Current stack mass:    %7.3f","g","lbm", 1000,gTolb, ms,5,line12);

I want to change BLUE to some other color that isn't so hard to see. That's it. But I'm not sure what I need or how to go about remaking the DLL.
 

N_Molson

Addon Developer
Addon Developer
Donator
Joined
Mar 5, 2010
Messages
9,290
Reaction score
3,258
Points
203
Location
Toulouse
What do I have to have if I want to compile that CPP file myself?

- Microsoft VS++ (2008 or 2010) (free download & registration)
- To learn how to compile a project :p
 

BruceJohnJennerLawso

Dread Lord of the Idiots
Addon Developer
Joined
Apr 14, 2012
Messages
2,585
Reaction score
0
Points
36
- Microsoft VS++ (2008 or 2010) (free download & registration)
- To learn how to compile a project :p

2010 is probably better, although I have both installed just so that I can work in 2010 while looking over code samples in 2008, sad I know :lol:. Both are quite massive downloads FYI. If you want to create an addon vessel, this template should probably be the best [ame="http://www.orbithangar.com/searchid.php?ID=5251"]http://www.orbithangar.com/searchid.php?ID=5251[/ame]

Can anyone confirm for me that the current info on Orbiterwiki is definitely out-of date? The tutorials on there reference Visual C++ 2005 and seem to make setting up the project a lot harder than it actually is (package above is preprepared), but Im not as wise in the ways of :probe: as some around here, so I thought Id ask.
 

orb

New member
News Reporter
Joined
Oct 30, 2009
Messages
14,020
Reaction score
4
Points
0
When you already have Visual C++ 2008, 2010 or 2012-Desktop to compile it, after opening the BurnTimeMFD.vcproj project file (and most likely converting to your version of Visual Studio), you'll need to change all the absolute paths defined in the project to your directory structure (or just add Orbiter property sheets with properly configured OrbiterDir, and then reset all those paths to be inherited instead of using custom values). This should make the code compilable and linkable.

The reason I want to do this is to simply change 1 word worth of code. (A color change.)

{...}

Code:
	SetTextColor( hDC, [U][B]BLUE[/B][/U] );

{...}

I want to change BLUE to some other color that isn't so hard to see.

It isn't as simple as changing one word. Changing "BLUE" to other word will most likely cause an "undefined symbol" compiler error, if the color wasn't already defined in code.

If you look at the beginning of the .cpp file you'll see that line:
Code:
#define BLUE RGB(0, 0, 255)
You can either define a new color and then replace "BLUE" with it in the SetTextColor, or replace it directly with "RGB (<your_red_component>, <your_green_component>, <your_blue_component>)", or change the definition of "BLUE" to some different RGB value, so all other parts of code using "BLUE" symbol will use your new color instead of R:0, G:0, B:255 (a value for the most bright and saturated blue color).

You can get the 0-255 RGB values for colors from many sources, like Wikipedia, or on-line color pickers (e.g. http://www.colorschemer.com/online.html, http://www.colorspire.com/rgb-color-wheel/, http://www.colorpicker.com/).
 

dgatsoulis

ele2png user
Donator
Joined
Dec 2, 2009
Messages
1,927
Reaction score
340
Points
98
Location
Sparta
I tried to recompile the source code of [ame="http://orbithangar.com/searchid.php?ID=4530"]Burn Time Calculator 2.32 [/ame] using Visual C++ 2010 Express. I did not make any changes to the .cpp file, so I wasn't expecting any errors, but this is what I got when I compiled:

Code:
1>------ Build started: Project: BurnTimeMFD, Configuration: Debug Win32 ------
1>  BurnTimeMFD.cpp
1>c:\users\δημήτρης\desktop\orbiterfresh\orbitersdk\samples\burntimecalculator\burntimemfd.cpp(477): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\δημήτρης\desktop\orbiterfresh\orbitersdk\samples\burntimecalculator\burntimemfd.cpp(566): error C2275: 'std::string' : illegal use of this type as an expression
1>c:\users\δημήτρης\desktop\orbiterfresh\orbitersdk\samples\burntimecalculator\burntimemfd.cpp(566): error C2228: left of '.npos' must have class/struct/union
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The first one (warning C4018) was easy to fix, I changed line 477 from this
Code:
for (int laufNumber=0; laufNumber<SearchString.length()-1;laufNumber++)
to this
Code:
for ([B]unsigned int[/B] laufNumber=0; laufNumber<SearchString.length()-1;laufNumber++)

The other two (C2275 and C2228 at the same line), I have no idea what to do.
The part of the code is this (line 566 in red):
Code:
//checking if string is a part of the entered value
		for (unsigned int i = 0; i < oapiGetObjectCount();i++)
		{
			char ObjectNameCharStr[255];
			OBJHANDLE hobj = oapiGetObjectByIndex(i);
			oapiGetObjectName (hobj,ObjectNameCharStr,255);
			std::string StrObjectName(ObjectNameCharStr);
			std::transform(StrObjectName.begin(), StrObjectName.end(), StrObjectName.begin(), std::tolower);
			size_t pos;	
			
			pos = StrObjectName.find(SearchString);
			[COLOR="red"]if (pos != std::string.npos)[/COLOR]
			{
			   IndexCenterObj = i;
			   inputmode=INPUTMODE_NONE;
			   return true;
			}
		}
		return false;
	}
}

Is this something that can be easily fixed?
 

BruceJohnJennerLawso

Dread Lord of the Idiots
Addon Developer
Joined
Apr 14, 2012
Messages
2,585
Reaction score
0
Points
36
I tried to recompile the source code of Burn Time Calculator 2.32 using Visual C++ 2010 Express. I did not make any changes to the .cpp file, so I wasn't expecting any errors, but this is what I got when I compiled:

Code:
1>------ Build started: Project: BurnTimeMFD, Configuration: Debug Win32 ------
1>  BurnTimeMFD.cpp
1>c:\users\δημήτρης\desktop\orbiterfresh\orbitersdk\samples\burntimecalculator\burntimemfd.cpp(477): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\δημήτρης\desktop\orbiterfresh\orbitersdk\samples\burntimecalculator\burntimemfd.cpp(566): error C2275: 'std::string' : illegal use of this type as an expression
1>c:\users\δημήτρης\desktop\orbiterfresh\orbitersdk\samples\burntimecalculator\burntimemfd.cpp(566): error C2228: left of '.npos' must have class/struct/union
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

The first one (warning C4018) was easy to fix, I changed line 477 from this
Code:
for (int laufNumber=0; laufNumber<SearchString.length()-1;laufNumber++)
to this
Code:
for ([B]unsigned int[/B] laufNumber=0; laufNumber<SearchString.length()-1;laufNumber++)

The other two (C2275 and C2228 at the same line), I have no idea what to do.
The part of the code is this (line 566 in red):
Code:
//checking if string is a part of the entered value
		for (unsigned int i = 0; i < oapiGetObjectCount();i++)
		{
			char ObjectNameCharStr[255];
			OBJHANDLE hobj = oapiGetObjectByIndex(i);
			oapiGetObjectName (hobj,ObjectNameCharStr,255);
			std::string StrObjectName(ObjectNameCharStr);
			std::transform(StrObjectName.begin(), StrObjectName.end(), StrObjectName.begin(), std::tolower);
			size_t pos;	
			
			pos = StrObjectName.find(SearchString);
			[COLOR="red"]if (pos != std::string.npos)[/COLOR]
			{
			   IndexCenterObj = i;
			   inputmode=INPUTMODE_NONE;
			   return true;
			}
		}
		return false;
	}
}

Is this something that can be easily fixed?

Truly dont know, but the first two look a heck of a lot like grammar errors where opening/closing/demarcating/whateverating symbols may be missing. I would suggest going back to double check that whatever you did didnt accidentally omit a symbol somehwere (the < in particular)
 

dgatsoulis

ele2png user
Donator
Joined
Dec 2, 2009
Messages
1,927
Reaction score
340
Points
98
Location
Sparta
Truly dont know, but the first two look a heck of a lot like grammar errors where opening/closing/demarcating/whateverating symbols may be missing. I would suggest going back to double check that whatever you did didnt accidentally omit a symbol somehwere (the < in particular)

I did not edit anything. Simply opened the project in Visual C++ 2010 and hit the build button. But I have configured it to use the Orbiter resources and export the dll directly to the modules\plugin directory, after watching a video from computerex. I have compiled other projects successfully.

The one with the < was the first a signed/unsigned mismatch and after googling "C++ warning C4018) " , I found the fix. I tried the same for the other two errors (both in line 566), but could not make heads or tales of the answers I found.
 

SiameseCat

Addon Developer
Addon Developer
Joined
Feb 9, 2008
Messages
1,699
Reaction score
1
Points
0
Location
Ontario
I tried to recompile the source code of Burn Time Calculator 2.32 using Visual C++ 2010 Express. I did not make any changes to the .cpp file, so I wasn't expecting any errors, but this is what I got when I compiled:

Code:
1>------ Build started: Project: BurnTimeMFD, Configuration: Debug Win32 ------
1>  BurnTimeMFD.cpp
1>c:\users\δημήτρης\desktop\orbiterfresh\orbitersdk\samples\burntimecalculator\burntimemfd.cpp(477): warning C4018: '<' : signed/unsigned mismatch
1>c:\users\δημήτρης\desktop\orbiterfresh\orbitersdk\samples\burntimecalculator\burntimemfd.cpp(566): error C2275: 'std::string' : illegal use of this type as an expression
1>c:\users\δημήτρης\desktop\orbiterfresh\orbitersdk\samples\burntimecalculator\burntimemfd.cpp(566): error C2228: left of '.npos' must have class/struct/union
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
The first one (warning C4018) was easy to fix, I changed line 477 from this
Code:
for (int laufNumber=0; laufNumber<SearchString.length()-1;laufNumber++)
to this
Code:
for ([B]unsigned int[/B] laufNumber=0; laufNumber<SearchString.length()-1;laufNumber++)
The other two (C2275 and C2228 at the same line), I have no idea what to do.
The part of the code is this (line 566 in red):
Code:
//checking if string is a part of the entered value
        for (unsigned int i = 0; i < oapiGetObjectCount();i++)
        {
            char ObjectNameCharStr[255];
            OBJHANDLE hobj = oapiGetObjectByIndex(i);
            oapiGetObjectName (hobj,ObjectNameCharStr,255);
            std::string StrObjectName(ObjectNameCharStr);
            std::transform(StrObjectName.begin(), StrObjectName.end(), StrObjectName.begin(), std::tolower);
            size_t pos;    
            
            pos = StrObjectName.find(SearchString);
            [COLOR=red]if (pos != std::string.npos)[/COLOR]
            {
               IndexCenterObj = i;
               inputmode=INPUTMODE_NONE;
               return true;
            }
        }
        return false;
    }
}
Is this something that can be easily fixed?
Replace
Code:
std::string.npos
with
Code:
std::string::npos

npos is a static member of the std::string class, so you have to use :: to access it.
 

dgatsoulis

ele2png user
Donator
Joined
Dec 2, 2009
Messages
1,927
Reaction score
340
Points
98
Location
Sparta
Replace
Code:
std::string.npos
with
Code:
std::string::npos

npos is a static member of the std::string class, so you have to use :: to access it.

Thank you very much.

In my search I found something like replacing std::string.npos with std::string->npos but it didn't work.
 
Top