View previous topic :: View next topic |
Author |
Message |
Mithreas
Joined: 09 May 2008 Posts: 24
|
Posted: Sat Sep 19, 2009 13:02 Post subject: Howto: Building in Visual Studio Express 2008/WinXP |
|
|
I occasionally need to make minor tweaks to NWNX plugins, and to rebuild them I use VSE 2008. This isn't trivial, so to save other people several hours when they try it, here's a quick Howto.
Install VSE 2008, and check that it's installed the Windows SDK for you. On my install, this went to C:\Program Files\Microsoft SDKs\Windows\v6.0A.
Create a project for each plugin you want to use. There's a handy link from the startup screen - all you have to do is enter a project name.
Remove all the files automatically generated in the project (selecting the 'delete' option rather than just 'remove').
Using your subversion client, check out the code for the plugin you're interested in to your project directory. If you don't have a subversion client, I use SilkSVN, or you can use TortoiseSVN if you prefer GUI clients.
Back in the VSE GUI, right click on the project and Add > Add Existing Files, selecting all the files you just checked out. You will get asked whether you want to create custom build rules for a couple of files, just say No.
Now, in this environment the projects don't 'just build'. Here are the changes you need to make.
Right click on the project name in the VSE left toolbar and select properties.
Under "Configuration Properties", "General" change the Character Set from Unicode to Muli-Byte and Common Language Runtime support to no support.
Under "Configuration Properties", "C/C++", "Precompiled Headers" set Create/Use Precompiled Headers to Not Using Precompiled Headers.
Open up stdafx.h from among your project header files. Look for a line that says '#include <afxwin.h>" or similar. If it exists, replace it with '#include "windows.h" '. VSE doesn't come with the MFC libraries that include the afx* stuff - only the paid-for versions of VS have this. Thankfully, windows.h deputises nicely (in most cases, see below).
Individual plugins seem to need other things too. The list I've got so far is as follows.
The main NWNX project you can't build, as you need the MFC libraries that don't come with the free VSE.
NWNXdll will compile fine but will fail at the linking step with link errors for the SQL* methods. Go to your Windows SDK location and pull odbc32.lib out of the lib directory there. Copy it to your project and add it using the GUI (don't create a custom build rule when prompted). Now if you build, everything will link OK.
NWNX_fixes gives similar linking errors for NWNXBase* methods. Since you can't build the main NWNX project to get a lib file, you can work around this by adding the following 4 files from your NWNXdll project to your NWNX_fixes project: IniFile.h, NWNXBase.h, IniFile.cpp, NWNXBase.cpp.
FINALLY... if you need to copy the DLLs onto other PCs, you will probably need to distribute a few Visual Studio DLLs with it. Copy the contents of C:\Program Files\Microsoft Visual Studio 9.0\VC\redist\x86\Microsoft.VC90.CRT and put them in your NWN folder alongside your custom DLL.
Good luck...! I can most easily be contacted on the www.arelith.com forums if you need help, but be warned, I mainly worked this out by Googling and experimentation, I'm not an expert.
Note to virusman and team - you could make the last two bullets unnecessary by including the relevant files in the Subversion directories. I don't know if this would cause problems for other environments though! Thanks for your continued work on this project.
Cheers,
-Mith
Last edited by Mithreas on Sat Sep 19, 2009 23:39; edited 2 times in total |
|
Back to top |
|
|
Zebranky
Joined: 04 Jun 2006 Posts: 415
|
Posted: Sat Sep 19, 2009 20:19 Post subject: |
|
|
Have you tried the vs2008_update branch in SVN? Everything there but NWNX2.exe builds out of the box in VC++ 2008 Express Edition (for me, anyway). I'd like to know if it works for you too.
Also, what minor tweaks? If they'd be of public interest, I'd be happy to commit them _________________ Win32 SVN builds: http://www.mercuric.net/nwn/nwnx/
<Fluffy-Kooshy> NWNx plugin is to this as nuclear warheads are to getting rid of fire ants.
<ThriWork> whenever I hear nwn extender, I think what does NWN need a penis extender for? |
|
Back to top |
|
|
Mithreas
Joined: 09 May 2008 Posts: 24
|
Posted: Sat Sep 19, 2009 20:22 Post subject: |
|
|
haha I didn't even know that branch existed. Perhaps I should try that instead, but now I've got my local copy working!!
The tweaks are the ones above, specifically:
Open up stdafx.h from among your project header files. Look for a line that says '#include <afxwin.h>" or similar. If it exists, replace it with '#include "windows.h" '.
NWNXdll will compile fine but will fail at the linking step with link errors for the SQL* methods. Go to your Windows SDK location and pull odbc32.lib out of the lib directory there. Copy it to your project and add it using the GUI (don't create a custom build rule when prompted). Now if you build, everything will link OK.
NWNX_fixes gives similar linking errors for NWNXBase* methods. Since you can't build the main NWNX project to get a lib file, you can work around this by adding the following 4 files from your NWNXdll project to your NWNX_fixes project: IniFile.h, NWNXBase.h, IniFile.cpp, NWNXBase.cpp.
But if your branch works already, then you've either done these or found something else that works just as well. |
|
Back to top |
|
|
Zebranky
Joined: 04 Jun 2006 Posts: 415
|
Posted: Sun Sep 20, 2009 0:14 Post subject: |
|
|
I had to do the afxwin.h/windows.h swap and some project properties changes, but didn't have the linking issues you mentioned. If those are because of something different on your end, it would be good to figure out.
But by tweaks, I meant "I occasionally need to make minor tweaks to NWNX plugins...". Are they anything good? _________________ Win32 SVN builds: http://www.mercuric.net/nwn/nwnx/
<Fluffy-Kooshy> NWNx plugin is to this as nuclear warheads are to getting rid of fire ants.
<ThriWork> whenever I hear nwn extender, I think what does NWN need a penis extender for? |
|
Back to top |
|
|
Mithreas
Joined: 09 May 2008 Posts: 24
|
Posted: Sun Sep 20, 2009 0:59 Post subject: |
|
|
Here you go - very simple changes.
Code: |
In NWNXVaultster.cpp lines 153+ (on my version, which may be a bit old)
// Edit by Mithreas - cap the pattern length to 12 (not 14). This is because
// if a player makes several chars with the same name, and their name is 14
// chars long, their filenames are (e.g.)
// daedinangthalion.bic
// daedinangthalio1.bic
// i.e. the last character(s) may be replaced by numbers.
int characterLen = strlen (character);
int patternLen = (characterLen >= 12) ? 12 : characterLen;
In FixesHooks.cpp lines 45+
// Edit by Mithreas: Only check variables that start with an underscore.
// This lets us control whether or not a variable should block stacking.
if (pVar1->sVarName.Text[0] != '_') {
continue;
} |
_________________ Admin team, Arelith PW
Hakless world that relies heavily on the great work done by the NWNX team. |
|
Back to top |
|
|
Zebranky
Joined: 04 Jun 2006 Posts: 415
|
Posted: Sun Sep 20, 2009 5:02 Post subject: |
|
|
ACK! NO! BAD MITHREAS!
That Vaultster change is unnecessary and may even by counterproductive, assuming you're using a somewhat recent SVN version. It now finds the last modified file matching the character's name (or maybe even the last modified file period, I forget which) and uses that.
I do like the change to Fixes, though -- might have to steal that one _________________ Win32 SVN builds: http://www.mercuric.net/nwn/nwnx/
<Fluffy-Kooshy> NWNx plugin is to this as nuclear warheads are to getting rid of fire ants.
<ThriWork> whenever I hear nwn extender, I think what does NWN need a penis extender for? |
|
Back to top |
|
|
Fireboar
Joined: 17 Feb 2008 Posts: 323
|
Posted: Mon Sep 21, 2009 23:33 Post subject: |
|
|
This is a pretty old version of vaultster, I believe. The change was entirely necessary at the time... and the plugin hasn't been updated since it was implemented.
The fixes change was me actually - I devised it because we store a whole ton of variables on items, including a "muling check", so simply having different owners in the past would cause an item to not stack. Which isn't so fun. We needed to stop an item coming out of a container from stacking so the options available to us were: 1) Change the tag and preserve the variables (yuck); 2) Make a custom overridden itemproperty; 3) nwnx_fixes. 2) turned out to be impossible. 3) wasn't ideal because it would stop loads of things from stacking. 1) seemed like the only option, but for the code for nwnx_fixes being nice and simple to edit.
It would be quite cool if that made it in as an option for fixes. Feel free to steal it, by all means! |
|
Back to top |
|
|
Mithreas
Joined: 09 May 2008 Posts: 24
|
Posted: Tue Sep 22, 2009 23:28 Post subject: |
|
|
Yep, FB covered it - we're not using a recent version! Maybe we should upgrade but I'm loath to touch a system that currently seems to be working perfectly *touches wood*
And yes, FB and Gulni were responsible for designing and debugging the fixes change, I just worked out how to build the darn thing on VSE8. _________________ Admin team, Arelith PW
Hakless world that relies heavily on the great work done by the NWNX team. |
|
Back to top |
|
|
Fireboar
Joined: 17 Feb 2008 Posts: 323
|
Posted: Mon Sep 28, 2009 15:45 Post subject: |
|
|
Mithreas wrote: | And yes, FB and Gulni were responsible for designing and debugging the fixes change, I just worked out how to build the darn thing on VSE8. |
So in other words, Mith did all the work. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|