Outpost Universe Forums

Projects & Development => Outpost 2 Programming & Development => Topic started by: AmIMeYet on June 20, 2009, 12:11:31 PM

Title: Tutorial: Visual C++ 2008 Express Edition
Post by: AmIMeYet 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) (http://www.microsoft.com/express/vc/). (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) (http://www.microsoft.com/express/vc/).
It doesn't really matter where you place this.
This should all go smoothely.

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

Next, download the OP2 SDK (http://wiki.outpostuniverse.net/SDK).
Edit: You can also try the direct file here (http://www.outpostuniverse.net/files/coding/op2_dllsdk.zip).

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: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:
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: Hooman on June 20, 2009, 01:45:26 PM
Hmm, why thank you for posting this. I'd completely forgotten about using VC 2008 Express.
 
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: AmIMeYet 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?
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: Hooman 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.
 
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: Sirbomber 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.
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: AmIMeYet 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?
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: Kayedon 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
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: Brazilian Fan 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!
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: AmIMeYet on June 20, 2009, 05:26:43 PM
@Kayedon: Ah yes.. ..DreamSpark right?
Shame they don't allow Dutch students.. :(

And lol @ Brazilian Fan.
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: Kayedon on June 20, 2009, 05:54:25 PM
Nope, not DreamSpark.
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: jcj94 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  
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: jcj94 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...
 
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: Hooman 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.
 
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: AmIMeYet on April 04, 2010, 05:41:18 AM
This might work: http://github.com/leepa/libctiny (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 ==========
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: Hooman 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.
 
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: AmIMeYet 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...

:/
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: elwood_s on April 28, 2010, 03:47:24 PM
Quote
Okay, so, first up: Download and install VC 2008 Express(download here) (http://www.microsoft.com/express/vc/).

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 ?
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: evecolonycamander on April 28, 2010, 03:57:50 PM
i'll google it for you and in next post tell ya
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: elwood_s on April 28, 2010, 07:05:43 PM
Thanks!  :)  
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: Sirbomber on April 28, 2010, 07:32:48 PM
I don't see why it wouldn't...
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: Kayedon 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.
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: CK9 on April 28, 2010, 09:20:29 PM
finding a list of changes could provide an inkling to whether or not it will work...
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: Sirbomber on April 28, 2010, 09:37:50 PM
Trying it out would provide a definite "yes" or "no" answer though.  :P  
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: Hooman 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.
 
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: CK9 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
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: evecolonycamander on April 30, 2010, 07:25:24 AM
i have java - eclipse sdk. it apparently has the abilty for C++. problem is once i make the script how do i turn it into a .dll? any help would be greatfull
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: elwood_s on April 30, 2010, 10:15:53 AM
OK, I now have tried Visual C++ 2010 Express and it didn't work for me.   :(

When I double-clicked on the OP2Script.dsp file in explorer, Visual C++ started automatically and the dialog box popped up asking if I want to convert and open, just as it should.  But when I pushed the "Yes" button to convert, the dialog closed and Visual C++ instantly displayed a "Done" message at the bottom of the screen, even though the file had neither been opened nor converted.   I tried this a few more times with the same result.  The fact that it keeps asking if I want to convert and open on each successive try confirms that the file isn't being converted.


I then uninstalled Visual C++ 2010 Express and installed Visual C++ 2008 Express from a torrent that I found and everything worked as described above by AmIMeYet.
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: Sirbomber on April 30, 2010, 12:26:25 PM
Did you maybe try opening the 2010 project file instead of the 2008 project file...?
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: elwood_s on April 30, 2010, 10:14:13 PM
Quote
Did you maybe try opening the 2010 project file instead of the 2008 project file...?
Sorry, but I don't understand your question.  I thought there was only one project file (OP2Script.dsp) in the Multiplayer Hooville folder.

I'm brand new to this so please pardon my ignorance.  During the late 80's and early 90's I did a considerable amount of programing in an interpreter (dBase III Plus ADL), so I have a decent grasp of programming fundamentals.  But this is the first time I've touched a true compiler and I'm really out of my depth.
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: Hooman on May 01, 2010, 02:54:08 AM
There should only be the MSVC 6 project files with the stuff from the SVN. There is the "project" file (.dsp), and the "workspace" file (.dsw). Normally, you open the workspace file. A workspace can contain multiple projects. It is the equivalent of a "solution" in VS2008 I believe.

I guess try opening the .dsw file, and see if you have better luck. If that doesn't work, try converting to VS2008 format first, and then from VS2008 to VS2010 and see what happens. I'll maybe try downloading VS2010 this weekend if you still can't get things working. (No promises though).


I don't much understand Sirbomber's question either.
 
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: elwood_s on May 01, 2010, 11:01:14 AM
Quote
I guess try opening the .dsw file, and see if you have better luck. If that doesn't work, try converting to VS2008 format first, and then from VS2008 to VS2010 and see what happens.......
Unfortunately, when I couldn't get it to convert the dsp,  I uninstalled VS2010 prior to installing VS2008 (I was concerned about a possible conflict if I had them both installed at the same time).  :oops:  

Since VS2008 seems to be working as advertised, I think I'll just stick with that for now.  I'm really a neophyte :unsure:  when it comes to this type of programming and don't want to confuse myself anymore than necessary.  :wacko:
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: jcj94 on June 09, 2010, 10:47:35 AM
here is the 2008 version http://www.brothersoft.com/visual-c++-2008...tion-67703.html (http://www.brothersoft.com/visual-c++-2008-express-edition-67703.html)  
The current link up top is the 2010
Title: Tutorial: Visual C++ 2008 Express Edition
Post by: Flashy on May 15, 2011, 06:31:15 AM
Looks like Hooman was right, opening 2008 files works good, like copying the .vcproj (like this one(attached)) into the project folder and opening it. 2010 seems to work good with OP2. Note that I already used this one, so it contains 2010 conversions and the fixes described by AmIMeYet.