Author Topic: Tutorial: Visual C++ 2008 Express Edition  (Read 14350 times)

Offline AmIMeYet

  • Full Member
  • ***
  • Posts: 128
Tutorial: Visual C++ 2008 Express Edition
« on: June 20, 2009, 12:11:31 PM »
This tutorial might be obsolete. The SVN version of the OP2SDK supports VC 2008 thanks to Hooman. Download the updated SDK from there.

As some of you might know, it is impossible so use the SDK to create maps in Visual C++ 2008 (Express Edition). (Hereafter called VC 2008 Express)
VC 2008 Express is basically the free version of VC 2008.
After a lot of tinkering, I got it to work!

Note: I only tested this on my sytem: VC 2008 Express, on Vista Home Premium SP1. I can not guarantee that this edit will work on other setups.

Okay, so, first up: Download and install VC 2008 Express(download here).
It doesn't really matter where you place this.
This should all go smoothely.

If you haven't already, download OP2, and save that somewhere you will keep it. (I have this in D:\Program Files\OP2\Game\).

Next, download the OP2 SDK.
Edit: You can also try the direct file here.

Then, create a folder somewhere on your drive, to place all your coding-files (I have it in D:\Program Files\OP2\SDK\).
Then, copy the downloaded SDK there.
That folder should now contain these sub-folders:
  • Lib
  • Outpost2DLL
  • OP2Helper
  • Multiplayer
  • Multiplayer Hooville
Next, copy either /Multiplayer/ or /Multiplayer Hooville/ in that same directory, and rename it to your new dll's name (this name is just for clarity).

Next, go in that directory and open OP2Script.dsp. That should launch VC, and ask you if you want to convert your project. Click 'yes'.

This is where the fun begins.
You'd expect after all this, you would be able to compile.
Try it (F7). It will then ask you to save the .sln. Just click 'save', as it should automatically get the correct name and folder.
BAM! Error: " cannot open file 'LIBC.lib' ".
This is because VC 2008 doesn't support this old file anymore :(

To fix this, go to the top menu of VC, and click 'Project > OP2Script Properties' (or hit ALT+F7).
Then, open up 'Configuration Properties > Linker > Input' inside the tree-menu on the left.

Select the text next to 'Aditional Dependencies', and delete "..\lib\libctiny.lib", so that only "..\lib\op2.lib" remains.
Then, select the text next to 'Ignore Specific Librarys', and delete "libcmt.lib" (it should be blank now).

Press 'ok', and hit F7 again.
Tadaa! Build succeeded.

You can now start coding away!

One more thing though: It might be smart to keep a copy of this new project, so you don't have to go into the settings again. (I simply called it template).
So from then on, you can just copy that folder, instead of doing all of the points above.

The finished dll will be called 'OP2Script.dll', and will be placed in /ReleaseMinSize/ .

To really see if your build was successfull, go to one of the first lines of main.cpp (around line 25), and change the DeskBlock's MultiLastOneStanding into Tutorial.
Recompile, rename to t15 (tutorial 15 [change number if needed]), and look it up in OP2.

WOW, long post.. :heh:
« Last Edit: April 04, 2010, 05:43:43 AM by AmIMeYet »

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Tutorial: Visual C++ 2008 Express Edition
« Reply #1 on: June 20, 2009, 01:45:26 PM »
Hmm, why thank you for posting this. I'd completely forgotten about using VC 2008 Express.
 

Offline AmIMeYet

  • Full Member
  • ***
  • Posts: 128
Tutorial: Visual C++ 2008 Express Edition
« Reply #2 on: June 20, 2009, 01:52:29 PM »
Yeah, but it was really due! :lol:
Seriously, I'm really glad I figured this out.

Oh.. should I add this to the wiki or something?

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Tutorial: Visual C++ 2008 Express Edition
« Reply #3 on: June 20, 2009, 02:13:45 PM »
No idea. I never use the wiki. I don't even know if anyone is still around that can setup accounts on it.
 

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3237
Tutorial: Visual C++ 2008 Express Edition
« Reply #4 on: June 20, 2009, 02:57:59 PM »
Editing on the Wiki has been permanently disabled.

Tell me if this makes saved games work properly.  I might use it if it does.
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline AmIMeYet

  • Full Member
  • ***
  • Posts: 128
Tutorial: Visual C++ 2008 Express Edition
« Reply #5 on: June 20, 2009, 03:09:20 PM »
Hm.. I have no idea.. is there a chance it doesn't? ..what could prevent the saving?

Edit: In-game saving works perfectly. (latest OP2 from download page, tested in colony game)

Edit 2: I really don't get how saving could not work. The multiplayer (/+ Hooville) example implements GetSaveRegions(struct BufferDesc &bufDesc). Is this the thing you're talking about?
« Last Edit: June 20, 2009, 03:48:55 PM by AmIMeYet »

Offline Kayedon

  • Sr. Member
  • ****
  • Posts: 378
Tutorial: Visual C++ 2008 Express Edition
« Reply #6 on: June 20, 2009, 05:18:11 PM »
If you're cool like me you get the full VS 2008 entirely for free without pirating. Yay school software. <3
"Trust me, I'm crazy."

Offline Brazilian Fan

  • Sr. Member
  • ****
  • Posts: 302
Tutorial: Visual C++ 2008 Express Edition
« Reply #7 on: June 20, 2009, 05:21:43 PM »
Quote
If you're cool like me you get the full VS 2008 entirely for free without pirating. Yay school software. <3
Lol?
If you're cool like me you'd get full GCC entirely free without pirating. Yay open-source software!

Offline AmIMeYet

  • Full Member
  • ***
  • Posts: 128
Tutorial: Visual C++ 2008 Express Edition
« Reply #8 on: June 20, 2009, 05:26:43 PM »
@Kayedon: Ah yes.. ..DreamSpark right?
Shame they don't allow Dutch students.. :(

And lol @ Brazilian Fan.
« Last Edit: June 20, 2009, 05:27:48 PM by AmIMeYet »

Offline Kayedon

  • Sr. Member
  • ****
  • Posts: 378
Tutorial: Visual C++ 2008 Express Edition
« Reply #9 on: June 20, 2009, 05:54:25 PM »
Nope, not DreamSpark.
"Trust me, I'm crazy."

Offline jcj94

  • Sr. Member
  • ****
  • Posts: 407
    • http://techfusion-279.com
Tutorial: Visual C++ 2008 Express Edition
« Reply #10 on: February 14, 2010, 05:20:14 PM »
i cant figure out how 2 rename the file and save it as a.. as a mission i guess
+ does anyonee know what the ore under your name means... sry im a total newb to this kinda thing  
« Last Edit: February 14, 2010, 08:34:34 PM by jcj94 »

Offline jcj94

  • Sr. Member
  • ****
  • Posts: 407
    • http://techfusion-279.com
Tutorial: Visual C++ 2008 Express Edition
« Reply #11 on: February 15, 2010, 08:09:40 AM »
Quote
Quote
If you're cool like me you get the full VS 2008 entirely for free without pirating. Yay school software. <3
Lol?
If you're cool like me you'd get full GCC entirely free without pirating. Yay open-source software!
more like no self deletion after time experation...
 

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Tutorial: Visual C++ 2008 Express Edition
« Reply #12 on: April 04, 2010, 04:41:59 AM »
I've made a slight update to the SDK inthe SVN repository so it will work with Visual Studio 2008 right out of the box. It still uses MSVC 6 project files, which can be auto converted to the 2008 format during load. I've tested all template and the tutorial level projects to ensure they can auto convert, build, and produce a DLL (but I didn't test each DLL that was generated).


The problem was in the link step with the custom LibCTiny C-RunTime (CRT) library we were using. It works nicely with MSVC 6, producing nice small DLL files (about 3KB for a blank template), but didn't work with Visual Studio 2008. If you disable the custom runtime and use the standard one, then everything compiles with Visual Studio 2008, but the DLLs are going to be around 41KB for a blank template.

The way the libraries are loaded in the newer version of the SDK is through linker pragmas in the header files. It's been like that for a while now but wasn't that way in the previous packaged release. The pragma method is the easiest way to add library files for new APIs without people needing to play with project settings. The main header file Outpost2DLL.h has a linker pragma for LibCTiny. I simply added a version guard around the relevant lines. Now it will only use LibCTiny if you're using MSVC 6. This also means that MSVC 6 will produce substantially smaller DLL files than Visual Studio 2008 will.

I also made a slight update to the output location of the Outpost2DLL.lib file of that same project. As the Outpost2DLL project is a header file only API, it doesn't actually emit a library file. Instead, programs are expected to link to the pregenerated one. By having the output location set to the pregenerated file, Visual Studio 2008 won't error out looking for a library that doesn't exist. Now since no library will be emited due to no source code to compile (header files only), the pregenerated library will not get overwritten if you try to build the project.


If anyone can figure out how to build a LibCTiny equivalent that works with Visual Studio 2008, that would be useful. I'd be most interested in the steps to build the runtime, rather than a prepared library. (Largely to make sure there's no real possibility for tampering). The "LibCTiny" project can be googled, and I think it was written by someone with some affiliation with Microsoft. I could be wrong on that last part though.


Edit: One last note. If you've previously compiled stuff using MSVC 6, and then try Visual Studio 2008, make sure you "clean" all project outputs first. If you don't, it may still try to use a library that was compiled with a reference to LibCTiny and give you the error message at the top of this thread.
 
« Last Edit: April 04, 2010, 04:45:57 AM by Hooman »

Offline AmIMeYet

  • Full Member
  • ***
  • Posts: 128
Tutorial: Visual C++ 2008 Express Edition
« Reply #13 on: April 04, 2010, 05:41:18 AM »
This might work: http://github.com/leepa/libctiny

(& updated main post with SVN reference)

Edit: Couldn't get LibC[New]Tiny to work.. I've tried in in 2 ways:
Additional Dependencies in Linker>Input:
Quote
1>------ Build started: Project: OP2Script, Configuration: Release MinSize Win32 ------
1>Compiling...
1>LevelMain.cpp
1>BaseData.cpp
1>Generating Code...
1>Linking...
1>   Creating library .\ReleaseMinSize/OP2Script.lib and object .\ReleaseMinSize/OP2Script.exp
1>LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol _main referenced in function ___tmainCRTStartup
1>.\ReleaseMinSize/OP2Script.dll : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Program Files\Outpost2\SDK\Levels\Flashy\ReleaseMinSize-IntermediateFiles\BuildLog.htm"
1>OP2Script - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
#pragma in Outpost2DLL (as an #else for the #if _MSC_VER == 1200)
Quote
1>------ Rebuild All started: Project: OP2Script, Configuration: Release MinSize Win32 ------
1>Deleting intermediate and output files for project 'OP2Script', configuration 'Release MinSize|Win32'
1>Compiling...
1>LevelMain.cpp
1>DllMain.cpp
1>BaseData.cpp
1>Generating Code...
1>Linking...
1>   Creating library .\ReleaseMinSize/OP2Script.lib and object .\ReleaseMinSize/OP2Script.exp
1>OP2Helper.lib(OP2Helper.obj) : error LNK2019: unresolved external symbol ___CxxFrameHandler3 referenced in function __ehhandler$?CreateStarshipVictoryCondition@@YAXXZ
1>OP2Helper.lib(OP2Helper.obj) : error LNK2019: unresolved external symbol __EH_epilog3 referenced in function "void __cdecl CreateStarshipVictoryCondition(void)" (?CreateStarshipVictoryCondition@@YAXXZ)
1>OP2Helper.lib(OP2Helper.obj) : error LNK2019: unresolved external symbol __EH_prolog3 referenced in function "void __cdecl CreateStarshipVictoryCondition(void)" (?CreateStarshipVictoryCondition@@YAXXZ)
1>.\ReleaseMinSize/OP2Script.dll : fatal error LNK1120: 3 unresolved externals
1>Build log was saved at "file://c:\Program Files\Outpost2\SDK\Levels\Flashy\ReleaseMinSize-IntermediateFiles\BuildLog.htm"
1>OP2Script - 4 error(s), 0 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
« Last Edit: April 04, 2010, 04:25:47 PM by AmIMeYet »

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Tutorial: Visual C++ 2008 Express Edition
« Reply #14 on: April 04, 2010, 06:16:20 PM »
What you probably need to do, is add the LibCTiny library, and then remove the standard CRT library that gets linked in by default. You can try adding an explicit exclude, or check the box to ignore all standard libraries. Checking the box might remove too much though.

I'm not sure what the name of the current CRT library is.



I'm impressed someone picked up on this so quickly.
 

Offline AmIMeYet

  • Full Member
  • ***
  • Posts: 128
Tutorial: Visual C++ 2008 Express Edition
« Reply #15 on: April 05, 2010, 11:41:00 AM »
Thanks :)

From the log of the Additional-Dependencies-method I guess that the lib is, just like in MSVC6, libcmt.lib. Adding this to ignored dependencies gives me the same error as the pragma-method. Now I realize that this is because I also copied #pragma comment(linker, "/nodefaultlib:libcmt.lib").

Ignoring all didn't quite work out either...

:/

Offline elwood_s

  • Jr. Member
  • **
  • Posts: 74
Tutorial: Visual C++ 2008 Express Edition
« Reply #16 on: April 28, 2010, 03:47:24 PM »
Quote
Okay, so, first up: Download and install VC 2008 Express(download here).

This link now takes you to the download page for  Visual C++ 2010 Express. :blink:

Anybody know if this works with OP2?  

If not,  where can I download   VC 2008 Express ?

Offline evecolonycamander

  • Hero Member
  • *****
  • Posts: 602
Tutorial: Visual C++ 2008 Express Edition
« Reply #17 on: April 28, 2010, 03:57:50 PM »
i'll google it for you and in next post tell ya
''The blight cant get us up here!''
-famous last words
--------------o0o--------------
Outpost 2: EoM project status: Re-planning

Offline elwood_s

  • Jr. Member
  • **
  • Posts: 74
Tutorial: Visual C++ 2008 Express Edition
« Reply #18 on: April 28, 2010, 07:05:43 PM »
Thanks!  :)  

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3237
Tutorial: Visual C++ 2008 Express Edition
« Reply #19 on: April 28, 2010, 07:32:48 PM »
I don't see why it wouldn't...
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline Kayedon

  • Sr. Member
  • ****
  • Posts: 378
Tutorial: Visual C++ 2008 Express Edition
« Reply #20 on: April 28, 2010, 08:08:06 PM »
I fail to see how Googling VS2010 would tell you whether or not we can still program.
There is no reason it wouldn't. Most of the things they change are stability, UI, add new technologies, etc. It's not like it'll just "forget" part of the language.

And if you were saying if it was still possible to find VS2008, probably.
"Trust me, I'm crazy."

Offline CK9

  • Administrator
  • Hero Member
  • *****
  • Posts: 6226
    • http://www.outpost2.net/~ck9
Tutorial: Visual C++ 2008 Express Edition
« Reply #21 on: April 28, 2010, 09:20:29 PM »
finding a list of changes could provide an inkling to whether or not it will work...
CK9 in outpost
Iamck in runescape (yes, I still play...sometimes...)
srentiln in minecraft (I like legos, and I like computer games...it was only a matter of time...) and youtube...
xdarkinsidex on deviantart

yup, I have too many screen names

Offline Sirbomber

  • Hero Member
  • *****
  • Posts: 3237
Tutorial: Visual C++ 2008 Express Edition
« Reply #22 on: April 28, 2010, 09:37:50 PM »
Trying it out would provide a definite "yes" or "no" answer though.  :P  
"As usual, colonist opinion is split between those who think the plague is a good idea, and those who are dying from it." - Outpost Evening Star

Outpost 2 Coding 101 Tutorials

Offline Hooman

  • Administrator
  • Hero Member
  • *****
  • Posts: 4954
Tutorial: Visual C++ 2008 Express Edition
« Reply #23 on: April 29, 2010, 12:36:52 AM »
I highly suspect it will just work. If not, let us know, and then we'll know we have to fix something.
 

Offline CK9

  • Administrator
  • Hero Member
  • *****
  • Posts: 6226
    • http://www.outpost2.net/~ck9
Tutorial: Visual C++ 2008 Express Edition
« Reply #24 on: April 29, 2010, 09:22:46 AM »
okay, bomber, if it doesn't work, seeing a list of changes helps us learn why :P
CK9 in outpost
Iamck in runescape (yes, I still play...sometimes...)
srentiln in minecraft (I like legos, and I like computer games...it was only a matter of time...) and youtube...
xdarkinsidex on deviantart

yup, I have too many screen names