Compile with Visual Studio

Discussion around programming R'n'D, its source code and its tools.

Moderators: Flumminator, Zomis

Post Reply
User avatar
Jannik
Posts: 135
Joined: Fri Jan 27, 2006 2:55 pm
Location: Germany

Compile with Visual Studio

Post by Jannik »

I tried to compile the source of RnD v3.2.0rc8 with Visual Studio, but get many, many errors. :cry:

Here some of the first ones:

- no backslash before newline character in multiline #defines:
conf_chr.c
conf_cus.c
conf_grp.c

- can't find <unistd.h>, seems to be rather Unix-specific? What's defined inside?
main.h

- can't find <sys/time.h>, why is it needed? I can offer <sys/timeb.h> or <sys/utime.h> ...
main.h

- for further compiling I need a definition for Bitmap and Key ... (maybe in unistd.h?)
system.h


When I open the readme text files (like README.TXT, CHANGES.TXT, INSTALL.txt, ...) with Windows Notepad, it doesn't recognize the line breaks correctly. Would it be possible to replace the newline character LF with CR LF (carriage return + line feed)?
User avatar
Holger
Site Admin
Posts: 4073
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Post by Holger »

> I tried to compile the source of RnD v3.2.0rc8 with Visual Studio, but get
> many, many errors.

One comment in advance: Make sure that the compiler symbol "WIN32" is defined. This could already be the source of many errors (if Visual Studio tries to compile the code defined for Unix).

If in doubt, just hard-code it in the Makefile or appropriate header files (src/libgame/platform.h, for example).

> - no backslash before newline character in multiline #defines:
> conf_chr.c
> conf_cus.c
> conf_grp.c

Very strange! As far as I see, these source files do not contain multi-line #defines at all... :-o

> - can't find <unistd.h>, seems to be rather Unix-specific?
> - can't find <sys/time.h>, why is it needed? I can offer <sys/timeb.h> or
> <sys/utime.h> ...

This looks like VS trying to compile the Unix parts of the code...

> - for further compiling I need a definition for Bitmap and Key ...
> (maybe in unistd.h?)

No, these are defined in the code itself, like in src/libgame/sdl.h and/or src/libgame/x11.h

May it be possible that VS tries to compile the MS-DOS code??

> When I open the readme text files (like README.TXT, CHANGES.TXT,
> INSTALL.txt, ...) with Windows Notepad, it doesn't recognize the line
> breaks correctly. Would it be possible to replace the newline character LF
> with CR LF (carriage return + line feed)?

Yes, I could change this for the Windows version. Until then, Wordpad should work (I think).
Daniel H.
Posts: 535
Joined: Sun Apr 02, 2006 7:13 pm
Location: USA

Post by Daniel H. »

WordPad works, but once you save a UNIX file using WordPad, even if you did not change it, it is all converted to CR LF.
The H. World levelset can be downloaded from http://www.bd-fans.com/RnD.html -- search The H. World on that page.
User avatar
Jannik
Posts: 135
Joined: Fri Jan 27, 2006 2:55 pm
Location: Germany

Post by Jannik »

Yes, WordPad works, but I definitely prefer Notepad for .txt files and I think Notepad is the standard windows application for .txt files ...
Anyway, this was just a little cosmetic issue I wanted you to know ...
Very strange! As far as I see, these source files do not contain multi-line #defines at all... :-o
Ah, now I see, these files are "inline" files to extend the image_config[] array ... :idea: My fault, sorry ... :oops:

WIN32 is defined.

Meanwhile I found SDL_image.h, SDL_mixer.h and SDL_net.h ... :roll:

My problem is, that I don't know, what to do with the MAKEFILE, I have no experience with makefiles. :?
I just created a new project with all source files ... :oops:
And I don't just want to compile it in Windows, I'd like to let it run inside Visual Studio, to debug it, set breakpoints, step through the code to understand it ...
Is there a way to compile it without the makefile? I think I need at least a #define for TARGET_SDL ...

Now I added

Code: Select all

#define TARGET_SDL
to main.c.

But I get stuck in hash.h:

Code: Select all

extern inline void *
hashtable_iterator_key(struct hashtable_itr *i)
{
    return i->e->k;
}
error C2054: Nach 'inline' muss '(' folgen
error C2085: 'hashtable_iterator_key': Nicht in der formalen Parameterliste enthalten
error C2143: Syntaxfehler: Es fehlt ';' vor '{'

One stupid question: Am I right that C code should work in Visual C++?

Edit: Google gave me a hint: I renamed main.c to main.cpp and the problems with hash.c are gone. :shock: Weiß der Geier warum ...

Later, there's still the problem with missing files:
In main.c there's a

Code: Select all

#include "main.h"
and in main.h

Code: Select all

#include <sys/time.h>
#include <unistd.h>
which I can't find. I don't see any platform specific conditions around ...
HerzAusGold
Posts: 362
Joined: Sun Sep 25, 2005 4:41 pm
Location: Germany

Post by HerzAusGold »

Just use "rndTest" as base!! Sometime it so easy..
This is compileable with Visual C.
But you have to install SDK2003.
Look for "HAG#VC" for changes. Or make a diff.
Or wait until RnD3.2.0 is released - than I do the changes.

I can provide a workspace file too -
if you play my levels with the mouse (only kidding)
And the answer is ... 42 !
User avatar
Jannik
Posts: 135
Joined: Fri Jan 27, 2006 2:55 pm
Location: Germany

Post by Jannik »

If I just remove

Code: Select all

#include <sys/time.h> 
#include <unistd.h>
it compiles! :)

Unfortunately, linking fails: :evil:
error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""void __cdecl EventLoop(void)" (?EventLoop@@YAXXZ)" in Funktion "_SDL_main".
error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ""void __cdecl OpenAll(void)" (?OpenAll@@YAXXZ)" in Funktion "_SDL_main".
...
I set project properties like this:
C/C++, Codegenerierung, Laufzeitbibliothek: Multithreaded-DLL (/MD)
Linker, Allgemein, Zusätzliche Bibliotheksverzeichnisse: Ordner mit den Dateien SDL.lib SDLmain.lib SDL_image.lib SDL_mixer.lib SDL_net.lib
Linker, Eingabe, Zusätzliche Abhängigkeiten: SDL.lib SDLmain.lib SDL_image.lib SDL_mixer.lib SDL_net.lib


I tried it with RnDTest25:
When I found the curl files (http://curl.haxx.se) and defined
#define VISUAL_CPP
#define TARGET_SDL
it compiles, too. But I get the same linker errors as above. :cry:

Any ideas?
HerzAusGold
Posts: 362
Joined: Sun Sep 25, 2005 4:41 pm
Location: Germany

Post by HerzAusGold »

I think, this have to do with the C linkage / C++ linkage.
Make sure that you have create a C workspace and not CPP workspace.
Add the "sdl_xxx.lib" files to the project" !

I can provide a workspace/project file for rndTest tomorrow
or at least at the weekend, so if you can wait...
And the answer is ... 42 !
HerzAusGold
Posts: 362
Joined: Sun Sep 25, 2005 4:41 pm
Location: Germany

Post by HerzAusGold »

Hi,
I upload a Visual-C-workspace (for RndTest25) with *all* needed Libs/Includes.

http://www.zomis.net/rnd/download.php?id=514

Just extract it to a folder like D:\myRocks or direct to D:\
Then make a subst at the command prompt:

SUBST X: D:\myRocks

Change to X:\rnd\rndTestVC_x86\cpl
and open the ".DSW" file.

Now use Tab "FileView" and click with the right mouse button to
"rocksndiamonds" files.
Choose "Set As Active Project"
Then rebuild the project. (You can ignore the 69 warnings)

Both "Debug" and "Release" is well configured.
Use "Build", "Set Active Configuration" and choose "debug" or "release"

All source files are in "rndTestVC" (and can be replaced with newer) ;)
All Visual-C stuff is in "rndTestVC_x86"
Btw. a "Eclipse-Workspace/Project" is included too but not up to date.
All libs/includes are in "SDL_includeVC".

All provided as is, no warrenty, aso.

btw: Dont make any define's like "SDL_TARGET" in the source, do it in the workspace.
And the answer is ... 42 !
HerzAusGold
Posts: 362
Joined: Sun Sep 25, 2005 4:41 pm
Location: Germany

Post by HerzAusGold »

Please let me know if the project file works for you.
Tell me about the necessary changes please.
And the answer is ... 42 !
User avatar
Jannik
Posts: 135
Joined: Fri Jan 27, 2006 2:55 pm
Location: Germany

Post by Jannik »

Hi!

Thank you very much, HerzAusGold, your workspace file is a big help for me.

About RndTest25:
Besides many warnings I just get one error:
NMAKE : fatal error U1052: Datei "rndTestVC_x86.mak" nicht gefunden
but that's unimportant, because it compiles, the rocksndiamonds.exe is created and works. :)


I tried again to compile the original RnD code, but that's much harder than I expected ...
My problems so far:

hash.h:
- hashtable_iterator_key and hashtable_iterator_value (changed according to RnDTest25)

misc.c:
- fileExists (replaced access with fopen_s)

setup.c:
- posix_umask (mode_t unknown, solved by including RndTest's rndapi.h)
- LoadLevelInfoFromLevelDir (DIR unkown ..., the directory stuff requires a lot of changes to work in VC, I think I'll give up here :cry: )

But thanks a lot for your help!

Jannik
HerzAusGold
Posts: 362
Joined: Sun Sep 25, 2005 4:41 pm
Location: Germany

Post by HerzAusGold »

About the error with the ".mak" File - This is only a dummy "Project" to handle all the others. You have only set the active project to "rocksndiamonds".

For the VC support:

We can only hope that after RnD3.2.0 is released,
Holger give me the order to do the following:
- Visual-C support
- Zip-Support
- Download-Support
and if Holger want - may be the "Mouse-Support".
Or some other things, if he is in good spirit.
And the answer is ... 42 !
User avatar
Holger
Site Admin
Posts: 4073
Joined: Fri Jun 18, 2004 4:13 pm
Location: Germany
Contact:

Post by Holger »

I have Visual Studio installed on a XP box, but never really used it (as I prefer the Unix way). But maybe I could try this some time...

> We can only hope that after RnD3.2.0 is released,
> Holger give me the order to do the following:
> - Visual-C support
> - Zip-Support
> - Download-Support
> and if Holger want - may be the "Mouse-Support".

Well, you don't have to wait for any "orders" from me, really... ;-)

Maybe I'll pick some things from "RndTest" that I like and that fit into the R'n'D roadmap. Some of them maybe even before doing the engine enhancements that form the road for 3.2.0, 3.3.0 and 3.4.0. :-)

> Or some other things, if he is in good spirit.

It does not depend on "good spirit", but on "free time", you know. :-D
Post Reply