Notes about compiling MUSHclient source under MVC++ .NET 2003

Posted by Zeno on Mon 02 Apr 2007 02:14 AM — 28 posts, 86,982 views.

USA #0
Setting up the workspace was a lot less painful than I thought, all I had to do was open the Project and VS updated it to work in 2003 (I thought I would have to import each file).

I'm gotten past a few things so far (location of Lua and zLib etc), but I'm not sure about this:
MUSHclient\source\mushclient\mcdatetime.h(141) : error C2065: 'AFX_OLE_DATETIME_HALFSECOND' : undeclared identifier

MUSHclient\source\mushclient\mcdatetime.h(147) : error C3861: 'AFX_OLE_DATETIME_HALFSECOND': identifier not found, even with argument-dependent lookup


stdafx.cpp
 WINVER not defined. Defaulting to 0x0501 (Windows XP and Windows .NET Server)

[EDIT] Info about WINVER here: http://www.delphifaq.com/faq/f931.shtml

From what I've Googled, it's part of Microsoft's lib or the sort. I'm not sure what I'm missing, but I'm still looking into it.
[EDIT] Seems to be in AFXDISP.H?
Amended on Mon 02 Apr 2007 03:59 AM by Zeno
Australia Forum Administrator #1


#define AFX_OLE_DATETIME_HALFSECOND (1.0 / (2.0 * (60.0 * 60.0 * 24.0)))


I don't know about WINVER, I can't see where it is used, but I found this define:


#ifndef WINVER
#define WINVER 0x0400 // default to Windows Version 4.0
#endif

USA #2
Ah okay, I wasn't sure if I was missing an entire lib or just that define. I don't think WINVER will be a problem? I'll wait and see if it causes any problems at the end.

Getting some more errors here (thanks for helping):
MUSHclient\source\mushclient\OtherTypes.h(342) : error C2377: 'INPUT' : redefinition; typedef cannot be overloaded with any other symbol

        c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\Include\WinUser.h(5023) : see declaration of 'INPUT'



Not sure about his one, perhaps WinUser did not have this definition in your version of VS?

What version of zLib is being used? I'm using the latest, but seen to be missing files:
infutil.c
c1 : fatal error C1083: Cannot open source file: 'MUSHclient\source\zlib\infutil.c': No such file or directory
infcodes.c
c1 : fatal error C1083: Cannot open source file: 'MUSHclient\source\zlib\infcodes.c': No such file or directory
infblock.c
c1 : fatal error C1083: Cannot open source file: 'MUSHclient\source\zlib\infblock.c': No such file or directory

Or wait... Importing the Project included these listed files but they do not exist. Hmm.
Amended on Mon 02 Apr 2007 02:54 AM by Zeno
Australia Forum Administrator #3
They were in another directory, to save you the trouble of finding the files they are available from here:

http://www.gammon.com.au/files/mushclient/src/zlib.zip

The md5sum is 22cdecbe6b8d41994202b710e601101f.
Australia Forum Administrator #4
Quote:

error C2377: 'INPUT' : redefinition;


They have evidently taken that word now.

I suggest doing a find-and-replace, case sensitive, and matching the exact word, to change INPUT to something like USER_INPUT (in my source).

Hmmm - USER_INPUT is already used, perhaps NOT_OUTPUT would be better.


// bit settings for "flags" below

const int COMMENT = 0x01;        // this is a comment from a script
const int USER_INPUT = 0x02;     // this is echoed user input
const int LOG_LINE = 0x04;       // this line is to be logged
const int BOOKMARK = 0x08;       // line is bookmarked
const int HORIZ_RULE = 0x10;     // line is a horizontal rule

const int INPUT = 0x03;         // for testing if line is an output line or not


Change last line, and all references to NOT_OUTPUT:


const int NOT_OUTPUT = 0x03;         // for testing if line is an output line or not


However usually I used INPUT in the "not" sense, so "not NOT_OUTPUT" looks a bit strange.

Maybe a better word is NOTE_OR_INPUT.
Amended on Mon 02 Apr 2007 03:33 AM by Nick Gammon
USA #5
USER_INPUT is already used it seems, so I used USR_INPUT.

With those zLib files, I'm getting this on each of the 3 files:
MUSHclient\source\zlib\infutil.c(89) : fatal error C1010: unexpected end of file while looking for precompiled header directive

I have a feeling I did something wrong.

Other than that, looks like I'm down to only 5 errors.
Amended on Mon 02 Apr 2007 03:38 AM by Zeno
Australia Forum Administrator #6
Quote:

unexpected end of file while looking for precompiled header directive


For those files edit them in the project view and change properties under C/C++ -> Precompiled Headers to "Not using precompiled headers".
Australia Forum Administrator #7
Quote:

USER_INPUT is already used it seems, so I used USR_INPUT


I amended the post, maybe NOTE_OR_INPUT is better, considering that USER_INPUT is very close by.
USA #8
Ah okay, thanks. I'm not used to VS, I only use it for classes. Other than that, I use gcc/g++.

Here are the remaining errors:
MUSHclient\source\mushclient\methods.cpp(2590): error C2593: 'operator +=' is ambiguous


MUSHclient\source\mushclient\sendvw.cpp(231): 
error C2440: 'static_cast' : cannot convert from 'void (__thiscall CSendView::* )(CMenu *)' to 'void (__thiscall CWnd::* )(CMenu *,UINT,BOOL)'


MUSHclient\source\mushclient\CHATSOCK.CPP(859): error C2593: 'operator =' is ambiguous


MUSHclient\source\mushclient\CHATSOCK.CPP(872): error C2593: 'operator =' is ambiguous


MUSHclient\source\mushclient\CHATSOCK.CPP(896): error C2593: 'operator +=' is ambiguous
Amended on Mon 02 Apr 2007 03:46 AM by Zeno
Australia Forum Administrator #9
To explain about those bits, the lower-order bits of the line flags are:


const int COMMENT = 0x01;        // this is a comment from a script
const int USER_INPUT = 0x02;     // this is echoed user input


Thus, an output line is really 0x00.

To put it another way, if you take the flags from a line in the output buffer, and "and" it with 0x03, you would get one of 4 values (3 of which are used):

  • 0x00 - an output line
  • 0x01 - a note line (ie. world.Note etc.)
  • 0x02 - something the player typed (ie. a command)
  • 0x03 - not used


Thus there are various tests in the code along these lines:


if (!(flags & INPUT))  // input from MUD


What this is saying is that if "flags & 0x03" is zero, then it is an output line (input from the MUD - things are getting confusing here).

So, to test if "flags & 0x03" is an output line, we need to reverse the logic, to get a "true" out of it, hence:


if (!(flags & 0x03)) // this arrived from the MUD


Australia Forum Administrator #10
Quote:

methods.cpp(2590): error C2593: 'operator +=' is ambiguous


Try casting to char:


for (p++ ; *p && *p != ')'; )
  str += (char) tolower (*p++);   // add to string


Quote:

error C2440: 'static_cast' : cannot convert from ...


Not sure about this, they appear to have changed the way the macro works. Try commenting it out for now and taking the hit of that part not working while we sort it out.


Quote:

CHATSOCK.CPP(859): error C2593: 'operator =' is ambiguous


This seems to be this line:


      strData = (unsigned char) iMessage;


Try casting it a second time:


      strData = (char) (unsigned char) iMessage;


Ditto for the other ones.
USA #11
Casting it a second time didn't work for these lines:
strData =  (char) (unsigned char) iMessage & 0xFF;


strData += (char) (unsigned char) iLength & 0xFF;


Thanks though, those are the only errors left.
Amended on Mon 02 Apr 2007 04:13 AM by Zeno
Australia Forum Administrator #12
Quote:

MUSHclient\source\mushclient\sendvw.cpp(231):
error C2440: 'static_cast' : cannot convert ...


What might work is to change (in sendvw.cpp):


void CSendView::OnInitMenuPopup(CMenu* pMenu)
  {
  int i = 1;
  }


to:


void CSendView::OnInitMenuPopup(CMenu* pMenu, UINT nIndex, BOOL bSysMenu)
  {
  int i = 1;
  }


Also change (in sendvw.h):


	afx_msg void OnInitMenuPopup(CMenu* pMenu);


to:


	afx_msg void OnInitMenuPopup(CMenu* pMenu, UINT nIndex, BOOL bSysMenu);
Australia Forum Administrator #13
Quote:

strData = (char) (unsigned char) iMessage & 0xFF;


Try:


strData =  CString ( (unsigned char) iMessage & 0xFF);


Or maybe:


strData = (char) ((unsigned char) iMessage & 0xFF);


Or:


strData = (char) ((unsigned char) (iMessage & 0xFF));

Amended on Mon 02 Apr 2007 04:18 AM by Nick Gammon
USA #14
Yep, 3rd one worked. I appear to be missing icons now.
.\MUSHclient.rc(5102) : error RC2135 : file not found: icons\Cdrom01.ico
.\MUSHclient.rc(5103) : error RC2135 : file not found: icons\Wrench.ico
.\MUSHclient.rc(5104) : error RC2135 : file not found: icons\Clock05.ico
.\MUSHclient.rc(5105) : error RC2135 : file not found: icons\Earth.ico
.\MUSHclient.rc(5106) : error RC2135 : file not found: icons\Graph08.ico
.\MUSHclient.rc(5107) : error RC2135 : file not found: icons\Handshak.ico
.\MUSHclient.rc(5108) : error RC2135 : file not found: icons\Mail16b.ico
.\MUSHclient.rc(5109) : error RC2135 : file not found: icons\Net01.ico
.\MUSHclient.rc(5110) : error RC2135 : file not found: icons\Point11.ico
.\MUSHclient.rc(5111) : error RC2135 : file not found: icons\Clip07.ico
.\MUSHclient.rc(5119) : error RC2135 : file not found: graphics\Colour logo copy.BMP


I have no icons or graphics folder.
Amended on Mon 02 Apr 2007 04:23 AM by Zeno
Australia Forum Administrator #15
Icons are now at:

http://www.gammon.com.au/files/mushclient/src/icons.zip

I don't think the logo is used, just delete it from the resource list.
USA #16
Ah okay.

These are linker errors I'm getting. I'm a bit confused about the lua one, as it was looking for Lua in ../../ before and now it's ../
LINK : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification
MUSHclient.obj : warning LNK4229: invalid directive '/DelayLoad:lua5.1.dll' encountered; ignored
LINK : fatal error LNK1104: cannot open file '..\lua51_dll\Release\lua5.1.lib'
Australia Forum Administrator #17
The library path is here:


  // Lua 5.1
  #pragma comment( lib, "..\\lua51_dll\\Release\\lua5.1.lib" )
  // however we will allowed delayed load
  #pragma comment(linker, "/DelayLoad:lua5.1.dll")


You could take out the path, and bang the lua5.1.lib into the same directory as the source, eg.


#pragma comment( lib, "lua5.1.lib" )


I don't know about the delayload warning, perhaps they have changed how that works?
Australia Forum Administrator #18
Quote:

it was looking for Lua in ../../ before ...


That was the .h include files, as required here:


  #include "../../lua-5.1.1/src/lua.h"
  #include "../../lua-5.1.1/src/lauxlib.h"


The other one was the .lib file, which was the pragma directive.
USA #19
Ah okay. Anyway, it compiled and is running. Your change for OnInitMenuPopup worked as well.

There were quite a few warnings (200 to be exact). I don't know if your copy compiled without warnings because of your version. Are you interested in the warnings that I'm getting?
Australia Forum Administrator #20
I probably have a different warning level than you do.

I cranked the warning level up from 3 to 4 and got 493 warnings.

It will be a bit tedious getting rid of all of them, but some may well warn of things that will go wrong under obscure circumstances.

Here is an interesting case:


  if (App.m_iCounterFrequency)
    QueryPerformanceCounter (&start);

  pcre_callout = NULL;
  count = pcre_exec(prog->m_program, prog->m_extra, string, strlen (string),
                    start_offset, options, offsets, NUMITEMS (offsets));

  if (App.m_iCounterFrequency)
    {
    QueryPerformanceCounter (&finish);
    prog->iTimeTaken += finish.QuadPart - start.QuadPart;  // <--- warning here
    }


The warning was "warning C4701: local variable 'start' may be used without having been initialized".

Now "start" is conditionally initialized, it is true, in the first couple of lines. However the *same* condition is used in the code that *uses* "start". Thus in this case the problem will never arise.
Amended on Mon 02 Apr 2007 05:00 AM by Nick Gammon
Australia Forum Administrator #21
Quote:

Anyway, it compiled and is running.


Cool! So it compiles under .NET 2003. That is something, anyway.
USA #22
*nod* I wasn't sure if the new version was a bit more strict or the like.

I'm actually planning on upgrading to 2005 (I think), so I may end up getting more errors again. Thanks for the help. :)

I'll probably be spending this week looking through the code and the like. I doubt I'll tackle the client mod I'll be making for my MUD any time soon.

[EDIT] First successful test edit:
http://img.photobucket.com/albums/v123/rebirthseph/mc_zeno.jpg
;)
Amended on Mon 02 Apr 2007 05:09 AM by Zeno
Australia Forum Administrator #23
Good to see I didn't leave too many important files out. :)
USA #24
Strangely enough, I kept getting errors about graphics\Colour logo copy.BMP even though I had removed it from the Resources.

I also get this on startup of the program:
cannot open MUSHclient\source\mushclient\WinDebug\spellchecker.lua: No such file or directory
Amended on Mon 02 Apr 2007 05:38 AM by Zeno
Australia Forum Administrator #25
Are you sure you removed it from the resource list? You need to be in the resource editor, I removed it with no problems.

As for the spellchecker, it looks for that file in the same directory as the executable. I put a "stub" spellchecker.lua in my WinDebug directory, like this:


dofile (utils.info ().app_directory .. "..\\spellchecker.lua")


That effectively finds the app directory, goes up one level, and then uses the "real" spellchecker.lua there.
USA #26
I'm getting what seems to be a new error.
mushclient\StatLink.cpp(27): error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall CStaticLink::* )(CPoint)' to 'UINT (__thiscall CWnd::* )(CPoint)'


Strange. The change made to fix a 2005 error seems to have caused this error.

[EDIT] I can't run MC either.
Quote:
---------------------------
Microsoft Development Environment
---------------------------
Unable to start debugging.



The debugger is not properly installed. Run setup to install or repair the debugger.
---------------------------
OK
---------------------------


[EDIT 2] Great, now I get an error while repairing VSC++. I really want to debug this. *continues to fiddle around*
Amended on Tue 31 Jul 2007 03:41 AM by Zeno
Australia Forum Administrator #27
In statlink.cpp, try changing:


LRESULT CStaticLink::OnNcHitTest(CPoint point)


to:


UINT CStaticLink::OnNcHitTest(CPoint point)


And in statlink.h, change:


afx_msg LRESULT OnNcHitTest(CPoint point);


to:


afx_msg UINT OnNcHitTest(CPoint point);