compiling server in Bloodshed c++

Posted by Darisan on Sat 19 Apr 2003 02:15 AM — 18 posts, 73,933 views.

#0
Hey, I'm just wondering if you can compile the server in a compiler like Bloodshed Dev c/c++ or something like that? Does it have to be compiled with 'make' and cygwin and such?
Australia Forum Administrator #1
The SMAUG server is basically standard C. Provided your compiler supports that, it should compile, however you may have issues with include files not in the place the compiler expects them to be.
#2
How do I compile it?
Australia Forum Administrator #3
Don't know - I don't have that compiler. I suggest reading the instructions that came with it. Try compiling a small program first to get the hang of it. Basically you probably need to create a project or whatever they call it, and add most or all of the .C files into it, and then compile.
#4
oh... thats not hard lol
#5
I am trying to compile the Windows version of SMAUG in Bloodshed Dev-C++ using gcc and I keep getting a lot of errors. There appear to be five missing .o files (misc.o, save.o, router.o, webclient.o, and webserver.o). Any idea what's wrong or how I could fix it?

Note: I've added every .c and .h file to the project and even tried compiling with a new makefile. I still get those five missing files.
Australia Forum Administrator #6
After doing a compile in Cygwin, I find I have the files misc.o and save.o, but not router.o, webclient.o, and webserver.o.

I presume they are for stand-alone applications.

The files misc.o and save.o are not there presumably because of a compile error. Did they compile OK? Did they seem to attempt to compile?
USA #7
router.o, webclient.o, and webserver.o are all part of the IMC2 code and can be ignored. Just don't add them to your project file. It may be a good idea to use the FUSS package since it has been updated and bugfixed for alot of these kinds of things.
#8
I deleted all of the IMC/ICE things and then fixed two simple errors. Now, I'm getting 0 compiling errors and there aren't any files missing. However, there are still a ton of linking errors that look like this:

c:\documents and settings\beth.bethscomputer\my documents\my downloads\code\comm.o: In function `mainthread':
//c/smaug2/smaug/comm.c:260: undefined reference to `WSAStartup@8'
//c/smaug2/smaug/comm.c:296: undefined reference to `gethostname@8'
//c/smaug2/smaug/comm.c:315: undefined reference to `closesocket@4'
//c/smaug2/smaug/comm.c:316: undefined reference to `closesocket@4'
//c/smaug2/smaug/comm.c:317: undefined reference to `closesocket@4'
//c/smaug2/smaug/comm.c:318: undefined reference to `closesocket@4'
//c/smaug2/smaug/comm.c:335: undefined reference to `WSACleanup@0'
c:\documents and settings\beth.bethscomputer\my documents\my downloads\code\comm.o: In function `init_socket':
//c/smaug2/smaug/comm.c:356: undefined reference to `gethostname@8'
//c/smaug2/smaug/comm.c:359: undefined reference to `socket@12'
//c/smaug2/smaug/comm.c:365: undefined reference to `setsockopt@20'
//c/smaug2/smaug/comm.c:369: undefined reference to `closesocket@4'
//c/smaug2/smaug/comm.c:380: undefined reference to `setsockopt@20'
//c/smaug2/smaug/comm.c:384: undefined reference to `closesocket@4'
//c/smaug2/smaug/comm.c:392: undefined reference to `htons@4'
//c/smaug2/smaug/comm.c:394: undefined reference to `bind@12'
//c/smaug2/smaug/comm.c:397: undefined reference to `closesocket@4'
//c/smaug2/smaug/comm.c:401: undefined reference to `listen@8'
//c/smaug2/smaug/comm.c:404: undefined reference to `closesocket@4'
c:\documents and settings\beth.bethscomputer\my documents\my downloads\code\comm.o: In function `check_bad_desc':
//c/smaug2/smaug/comm.c:451: undefined reference to `__WSAFDIsSet@8'
c:\documents and settings\beth.bethscomputer\my documents\my downloads\code\comm.o: In function `accept_new':
//c/smaug2/smaug/comm.c:530: undefined reference to `select@20'
//c/smaug2/smaug/comm.c:536: undefined reference to `__WSAFDIsSet@8'
//c/smaug2/smaug/comm.c:543: undefined reference to `__WSAFDIsSet@8'
c:\documents and settings\beth.bethscomputer\my documents\my downloads\code\comm.o: In function `game_loop':
//c/smaug2/smaug/comm.c:590: undefined reference to `__WSAFDIsSet@8'
//c/smaug2/smaug/comm.c:617: undefined reference to `__WSAFDIsSet@8'
//c/smaug2/smaug/comm.c:696: undefined reference to `__WSAFDIsSet@8'
c:\documents and settings\beth.bethscomputer\my documents\my downloads\code\comm.o: In function `new_descriptor':
//c/smaug2/smaug/comm.c:811: undefined reference to `accept@12'
//c/smaug2/smaug/comm.c:832: undefined reference to `ioctlsocket@12'
//c/smaug2/smaug/comm.c:852: undefined reference to `ntohs@4'
//c/smaug2/smaug/comm.c:859: undefined reference to `inet_ntoa@4'
//c/smaug2/smaug/comm.c:867: undefined reference to `gethostbyaddr@12'
c:\documents and settings\beth.bethscomputer\my documents\my downloads\code\comm.o: In function `free_desc':
//c/smaug2/smaug/comm.c:933: undefined reference to `closesocket@4'
c:\documents and settings\beth.bethscomputer\my documents\my downloads\code\comm.o: In function `read_from_descriptor':
//c/smaug2/smaug/comm.c:1095: undefined reference to `recv@16'
//c/smaug2/smaug/comm.c:1098: undefined reference to `WSAGetLastError@0'
c:\documents and settings\beth.bethscomputer\my documents\my downloads\code\comm.o: In function `write_to_descriptor':
//c/smaug2/smaug/comm.c:1416: undefined reference to `send@16'
c:\documents and settings\beth.bethscomputer\my documents\my downloads\code\ident.o: In function `auth_check':
//c/smaug2/smaug/ident.c:86: undefined reference to `__WSAFDIsSet@8'
//c/smaug2/smaug/ident.c:96: undefined reference to `__WSAFDIsSet@8'
//c/smaug2/smaug/ident.c:104: undefined reference to `__WSAFDIsSet@8'
//c/smaug2/smaug/ident.c:112: undefined reference to `closesocket@4'
c:\documents and settings\beth.bethscomputer\my documents\my downloads\code\ident.o: In function `auth_read':
//c/smaug2/smaug/ident.c:155: undefined reference to `recv@16'
c:\documents and settings\beth.bethscomputer\my documents\my downloads\code\ident.o: In function `auth_write':
//c/smaug2/smaug/ident.c:194: undefined reference to `ntohs@4'
//c/smaug2/smaug/ident.c:194: undefined reference to `ntohs@4'
//c/smaug2/smaug/ident.c:196: undefined reference to `send@16'
//c/smaug2/smaug/ident.c:210: undefined reference to `closesocket@4'
c:\documents and settings\beth.bethscomputer\my documents\my downloads\code\ident.o: In function `auth_open':
//c/smaug2/smaug/ident.c:234: undefined reference to `socket@12'
//c/smaug2/smaug/ident.c:252: undefined reference to `ioctlsocket@12'
//c/smaug2/smaug/ident.c:264: undefined reference to `getservbyname@8'
//c/smaug2/smaug/ident.c:267: undefined reference to `htons@4'
//c/smaug2/smaug/ident.c:274: undefined reference to `connect@12'
c:\documents and settings\beth.bethscomputer\my documents\my downloads\code\ident.o: In function `set_auth':
//c/smaug2/smaug/ident.c:319: undefined reference to `getsockname@12'
//c/smaug2/smaug/ident.c:324: undefined reference to `getpeername@12'
c:\documents and settings\beth.bethscomputer\my documents\my downloads\code\ident.o: In function `kill_auth':
//c/smaug2/smaug/ident.c:349: undefined reference to `closesocket@4'
c:\documents and settings\beth.bethscomputer\my documents\my downloads\code\save.o: In function `kill_timer':
//c/smaug2/smaug/save.c:78: undefined reference to `timeKillEvent'
c:\documents and settings\beth.bethscomputer\my documents\my downloads\code\save.o: In function `set_alarm':
//c/smaug2/smaug/save.c:2129: undefined reference to `timeSetEvent'

I did add:

#pragma comment(lib, "winmm.lib")
#pragma comment(lib, "wsock32.lib")
#pragma comment(lib, "advapi32.lib")

to comm.c as suggested, but still no go. Anything else I can try?
Australia Forum Administrator #9
Those particular pragma directives are specific to the Microsoft compiler. I suggest you find how to link in those libraries to your Bloodshed compiler.
#10
Almost there! I managed to include those three libraries in Bloodshed and it solved just about every problem except for this:

c:\documents and settings\beth.bethscomputer\my documents\my downloads\code\save.o: In function `kill_timer':
//c/smaug2/smaug/save.c:78: undefined reference to `timeKillEvent'
c:\documents and settings\beth.bethscomputer\my documents\my downloads\code\save.o: In function `set_alarm':
//c/smaug2/smaug/save.c:2129: undefined reference to `timeSetEvent'

Any idea which library I would need for those?
Australia Forum Administrator #11
From the MSDN documentation:


timeKillEvent

The timeKillEvent function cancels a specified timer event.

MMRESULT timeKillEvent(
  UINT uTimerID  
);
 
Parameters
uTimerID 
Identifier of the timer event to cancel. This identifier was returned by the timeSetEvent function when the timer event was set up. 
Return Values
Returns TIMERR_NOERROR if successful or MMSYSERR_INVALPARAM if the specified timer event does not exist.

QuickInfo
  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Unsupported.
  Header: Declared in mmsystem.h.
  Import Library: Use winmm.lib.



The short answer is winmm.lib.
#12
I definitely have that library linked... Still, I get those two linking errors. I tried to include the header they were defined in, mmsystem.h, but that had like... 37 errors, so I took it out. I then found the two functions and copied those into save.c - It still won't work. It says that there is a parse error before 'LPTIMECALLBACK' I put these lines under #define SAVEVERSION 3

timeSetEvent(UINT,UINT,LPTIMECALLBACK,DWORD,UINT);
timeKillEvent(UINT);

What's the parse error? And, still, I'm getting those two link errors. What's up?
#13
Okay, I took out those two lines and added these:

timeKillEvent(
UINT uTimerID
);

timeSetEvent(
UINT uDelay,
UINT uResolution,
LPTIMECALLBACK lpTimeProc,
DWORD_PTR dwUser,
UINT fuEvent
);


Now, I still get the parse error before LPTIMECALLBACK. I also get 'TIME_PERIODIC undeclared' when I try to compile. And, of course, those two fun link errors. Do you have any other ideas?

As a note, I include "windows.h" because the MSDN for timeSetEvent said to do so.
USA #14
Are you sure you're actually linking the libraries? I don't think "#pragma comment" actually links anything - if it does, the name comment is very poorly chosen!

I'm also surprised you're making it to the link phase, if you have parse errors.

Could you post exactly what the parse error is?

You may have to define WIN32 before including windows.h for everything to work properly.
#15
In the compiler output, it says " parse errors before 'LPTIMECALLBACK' ". It also says " 'TIME_PERIODIC' undeclared (first use in this function) ".

I didn't use the pragma comments because they don't work in Bloodshed's compiler. Rather, I went to Project->Project Options and then loaded the object files. The other two included libraries seem to be working fine, as I no longer have those other errors, so I can't imagine why this one isn't. WIN32 seems to be defined all over SMAUG, but if I do have to define it again, how do I do it? I'm definitely not a C programmer. :-(

Note: The linker errors remain the same. undeclared references to timeSetEvent and timeKillEvent.

Thanks for the help so far!
Australia Forum Administrator #16
OK, here's a tip.

Because you are not using the Microsoft compiler, don't use the Windows version of SMAUG. When I compile SMAUG with Cygwin for instance, I use the Unix version.

I added those mmXXX calls myself for timing purposes, partly because they did something I needed (I can't remember what) and because they worked.

I suggest ditching the Windows source, and concentrate on getting the Unix one going. There is a version here on this site (with MXP added).

However if you are persisting, I think the parse error is simply because of LPTIMECALLBACK not being declared.
#17
I'll try to get it to compile in Dev-C++ (the Unix source). I'd rather not download anything as large as Cygwin. Thanks.