Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Development

Reply
 
Thread Tools Display Modes
Old June 13, 2011, 05:03   #1
Chud
Swordsman
 
Join Date: Jun 2010
Posts: 299
Chud is on a distinguished road
Visual Studio 2010 Express, help for the newbie?

Hi,

Anyone reasonably (or probably only a little) experienced with MS Visual Studio? I'm new to it and having a hard time getting it to behave reasonably. The answer to some of my problems is probably "RTFM" but I have made some attempts to do that ahead of time. :-)

I created a new project using "Create project from existing source code" using the current angband tree. I can't seem to get the "Solution Explorer" to show the underlying file tree though; it shows all the source files together, and all the header files together, and so when you have files with the same name in different directories they all appear together - and it's not clear how to tell which is which even if this was a good idea:



Relatedly, probably, I'm having trouble building it in part because it can't find header files it needs. I can solve many of these by manually adding each directory in src/*/ to its include path, but this is hardly portable in addition to being very much a pain. There must be a more general way to do this...

Any pointers and tip and tricks would be welcome!

Thanks,
-C
Chud is offline   Reply With Quote
Old June 13, 2011, 06:30   #2
Antoine
Ironband/Quickband Maintainer
 
Join Date: Nov 2007
Posts: 1,009
Antoine is on a distinguished road
I can't help you on this because the NPP files are not split between directories in the way that the Vanilla ones are, so I've not had to deal with the problem. (And am far from an expert anyway)

A.
__________________
Ironband - http://angband.oook.cz/ironband/
Antoine is offline   Reply With Quote
Old June 13, 2011, 16:30   #3
konijn_
Hellband maintainer
 
konijn_'s Avatar
 
Join Date: Jul 2007
Location: New York, the Big Apple
Age: 43
Posts: 367
Donated: $120
konijn_ is on a distinguished road
Quote:
Originally Posted by Chud View Post
Hi,

Anyone reasonably (or probably only a little) experienced with MS Visual Studio? I'm new to it and having a hard time getting it to behave reasonably. The answer to some of my problems is probably "RTFM" but I have made some attempts to do that ahead of time. :-)

I created a new project using "Create project from existing source code" using the current angband tree. I can't seem to get the "Solution Explorer" to show the underlying file tree though; it shows all the source files together, and all the header files together, and so when you have files with the same name in different directories they all appear together - and it's not clear how to tell which is which even if this was a good idea:



Relatedly, probably, I'm having trouble building it in part because it can't find header files it needs. I can solve many of these by manually adding each directory in src/*/ to its include path, but this is hardly portable in addition to being very much a pain. There must be a more general way to do this...

Any pointers and tip and tricks would be welcome!

Thanks,
-C
I have mentioned that MVSC2010 is pretty much broken right now.

* Things to do that I know off
* right click on the project, click config properties, c/c++, general, additional include directories, add the src folder since header files are located there for code files in subdirectories
* Still under c/c++, click on Command Line, make sure the following switch is in there : /D "_WINDOWS"
* At some point there will be confusion with include dirent/direct.. I think I just used the POSIX direct ( I posted about this ) and did the same as OSX, this compiled better ( as in I got stuck somewhere else )
* I Got rid of the test code folder when I imported files since it failed miserably, myshkin has added some more files on April 27, so your mileage may vary

In the end this all didnt work for me still, somehow the externs in externs.h didnt jive with the linker and all references to functions with char or char* died... There is a stackoverflow post on this, but at that point I was ready to kill somebody and with my latent heart condition I decided to just give up and play some more EVE.

T.
__________________
* Are you ready for something else ? Hellband 0.8.8 is out! *
konijn_ is offline   Reply With Quote
Old June 14, 2011, 02:28   #4
Blue Baron
Adept
 
Join Date: Apr 2011
Posts: 103
Blue Baron is on a distinguished road
I use VC++ 6.0, so some of the terminology will be different, but what I do is start with a new, blank win32 project. Next rename src/player/util.c to putil.c. Then I add all of the .c and .h files in the src directory to the project except those that have main in their name and snd-sdl.c. Then I add all of the .c and .h files in the player, object, monster, and win directories. Then I add src/main-win.c to the project. Next I add the additional include directories: src, src\player, src\object, src\monster, src\win, src\win\include. Then you need to add the library modules src\win\lib\libpng.lib and src\win\lib\zlib.lib. Finally I save the project and can start compiling.

Here things will probably get very different. Because I use VC++6.0 I am using an older Win32 SDK and compiler. So I also have to remove the extra const on line 74 of externs.h.

In z-queue.h I have to remove the line: #include <stdint.h>and replace it with: typedef unsigned int * uintptr_t;

In generate.c I have to comment out the defines of ROOM_DEBUG and ROOM_LOG, and replace where they are used with the code of the macro. (I have to replace "ROOM_LOG(" with "if (OPT(cheat_room)) msg(".)

In cmd4.c I need to replace snprintf with strnfmt.

Lastly, in main-win.c I have to replace GetWindowLongPtr with GetWindowLong, replace SetWindowLongPtr with SetWindowLong and GWLP_USERDATA with GWL_USERDATA.

If the projects in the other thread don't help, I hope this does.

Edit: changed the png include directory and libs above to match angband.

Another Edit: As APWhite says below, the library module winmm.lib also needs to be added. Also, the resource file (src/win/angband.rc) needs to be added to the project.

Last edited by Blue Baron; June 14, 2011 at 20:05.
Blue Baron is offline   Reply With Quote
Old June 14, 2011, 02:31   #5
d_m
Angband Devteam member
 
d_m's Avatar
 
Join Date: Aug 2008
Location: Philadelphia, PA, USA
Age: 40
Posts: 1,516
d_m is on a distinguished road
Quote:
Originally Posted by Blue Baron View Post
I use VC++ 6.0, so some of the terminology will be different, but what I do is start with a new, blank win32 project. Next rename src/player/util.c to putil.c. Then I add all of the .c and .h files in the src directory to the project except those that have main in their name and snd-sdl.c. Then I add all of the .c and .h files in the player, object, monster, and win directories. Then I add src/main-win.c to the project. Next I add the additional include directories: src, src\player, src\object, src\monster, src\win, src\win\libpng. Then I add the library module src\win\libpng\libpng_d.lib. Finally I save the project and can start compiling.

Here things will probably get very different. Because I use VC++6.0 I am using an older Win32 SDK and compiler. So I also have to remove the extra const on line 74 of externs.h.

In z-queue.h I have to remove the line: #include <stdint.h>and replace it with: typedef unsigned int * uintptr_t;

In generate.c I have to comment out the defines of ROOM_DEBUG and ROOM_LOG, and replace where they are used with the code of the macro. (I have to replace "ROOM_LOG(" with "if (OPT(cheat_room)) msg(".)

In cmd4.c I need to replace snprintf with strnfmt.

Lastly, in main-win.c I have to replace GetWindowLongPtr with GetWindowLong, replace SetWindowLongPtr with SetWindowLong and GWLP_USERDATA with GWL_USERDATA.

If the projects in the other thread don't help, I hope this does.

Edit: my png headers/libraries are in a different strucrure. you would want to use src\win\include and src\win\lib, and copy the dlls to the angband directory.
Is there a good #define that we could use to do some of these things for you via macros? I feel bad that you have to make so many source modifications to get things going...
__________________
linux->xterm->screen->pmacs
d_m is offline   Reply With Quote
Old June 14, 2011, 03:00   #6
Blue Baron
Adept
 
Join Date: Apr 2011
Posts: 103
Blue Baron is on a distinguished road
Quote:
Originally Posted by d_m View Post
Is there a good #define that we could use to do some of these things for you via macros? I feel bad that you have to make so many source modifications to get things going...
That macro is only used in 3 spots, so it is a minor change for me. Overall I think I only changed 20-25 lines of code. I do not think it would be worth supporting a flag for that. Also, I consider it a price of my preference for VC++6.0 rather than one of the later Visual Studios. (well not wanting to buy the professional version of them.)

Edit: I guess the only changes that I would ask for are to remove the extra? const from line 74 of externs.h and change the snprintf's in cmd4.c to strnfmt's. snprintf is only used 3 times in cmd4.c and once in main-crb.c. strnfmt is used around 330 times?

Also, I think the following lines should be removed from hook_quit() in main-win.c since they are also in cleanup_angband():
string_free(ANGBAND_DIR_XTRA_FONT);
string_free(ANGBAND_DIR_XTRA_GRAF);
string_free(ANGBAND_DIR_XTRA_SOUND);
string_free(ANGBAND_DIR_XTRA_HELP);

The memory is freed, but is not set to NULL, so it gives an exception for me the second time in cleanup_angband.

Actually these strings are initialized in two places as well in init_stuff() in main-win.c and init_file_paths() in init2.c. Is this a memory leak? maybe only initialize them in main-win.c if they are NULL?

Last edited by Blue Baron; June 14, 2011 at 05:22.
Blue Baron is offline   Reply With Quote
Old June 14, 2011, 03:37   #7
Chud
Swordsman
 
Join Date: Jun 2010
Posts: 299
Chud is on a distinguished road
Thanks - I will continue to experiment with MSVC, but so far it has been both frustrating and unproductive. I was able to get a clean, running compile in about 30 minutes with Eclipse and MinGW (all 30 minutes getting the eclipse settings correct; no code adjustments needed).

I'm disinclined to change the organizational structure of the directory tree if I can avoid it, in the interest of making it as simple as possible to keep repositories in sync, but it remains to be seen whether I get get MSVC to agree with me on that point.
Chud is offline   Reply With Quote
Old June 14, 2011, 04:23   #8
APWhite
Adept
 
APWhite's Avatar
 
Join Date: Jul 2007
Location: St George Utah, USA
Posts: 244
APWhite is on a distinguished road
Quote:
Originally Posted by Chud View Post
Thanks - I will continue to experiment with MSVC, but so far it has been both frustrating and unproductive. I was able to get a clean, running compile in about 30 minutes with Eclipse and MinGW (all 30 minutes getting the eclipse settings correct; no code adjustments needed).

I'm disinclined to change the organizational structure of the directory tree if I can avoid it, in the interest of making it as simple as possible to keep repositories in sync, but it remains to be seen whether I get get MSVC to agree with me on that point.

I use MSVC for all my angand stuff. I use VS2008.
I wrote up a step by step a few months back.

Creating a VS2008 Project using the borg and the official release.
1. Download the game source code
2. Download the borg source then unzip it into the \src directory.
3. Create a new project using VS2008
4. Exclude from the project the directories gtk, nds, osx. And the "main-???" files except main-win.c
5. Project -> Angband Properties -> Configuration Properties -> C/C++ -> Code Generation -> Run Time Library -> /MT
6. Project -> Angband Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies -> winmm.lib
7. Project -> Angband Properties -> Configuration Properties -> General -> Common Language Runtime Support -> No CLR
8. Edit config.h line 100. Remove the comments to #define ALLOW_BORG
9. Rename player\util.c to player\p-util.c
10. Remove the "main" entry point from Project -> Angband Properties -> Configuration Properties -> Linker -> Advanced -> Entry Point

Try these steps and let me know how you do. I should be able to walk you through the process.
APWhite is offline   Reply With Quote
Old June 14, 2011, 04:47   #9
Blue Baron
Adept
 
Join Date: Apr 2011
Posts: 103
Blue Baron is on a distinguished road
Quote:
Originally Posted by Chud View Post
Thanks - I will continue to experiment with MSVC, but so far it has been both frustrating and unproductive. I was able to get a clean, running compile in about 30 minutes with Eclipse and MinGW (all 30 minutes getting the eclipse settings correct; no code adjustments needed).

I'm disinclined to change the organizational structure of the directory tree if I can avoid it, in the interest of making it as simple as possible to keep repositories in sync, but it remains to be seen whether I get get MSVC to agree with me on that point.
You should not have to make code changes? I had to make them because I use an older win32 sdk and compiler.

The directory structure does not need to be changed, except to rename src/player/util.c to src/player/putil.c or something. Its just that I have static png libraries that I built myself, and use, and forgot to change the paths in my post.

I think a recent Visual Studio user only needs to be careful about which files are added to the project, the include directories, and the png libraries.

Also, the "Solution Explorer" only shows files that have been added to the project, rather than the actual directories.

Anyways, all this is for whatever development environment you want to use, so use whatever you are comfortable with and works for you.
Blue Baron is offline   Reply With Quote
Old June 14, 2011, 08:35   #10
jens
Swordsman
 
Join Date: Apr 2011
Location: Göteborg, Sweden
Posts: 348
jens is on a distinguished road
Quote:
Originally Posted by Chud View Post
I was able to get a clean, running compile in about 30 minutes with Eclipse and MinGW (all 30 minutes getting the eclipse settings correct; no code adjustments needed).
This is exactly what I want as well :-) Chud, could you write up a step by step procedure for me? Did you use the project files Magnate posted?
jens is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Issue with compile on Windows 7 64-bit using Visual C++ Express command line -K- Development 1 January 15, 2011 20:28
Request for votes: Ascii Dreams Roguelike of the Year 2010 andrewdoull Idle chatter 2 January 2, 2011 13:39
angband elites 2010 dos350 Vanilla 2 September 26, 2010 17:30
Visual Studio 2008 - building 32 & 64 bit now! LanceDiamond Development 5 April 25, 2009 13:59
Getting Visual C++ 2008 Express Edition to compile Angband 3.0.9 Orillian Vanilla 5 February 10, 2008 09:23


All times are GMT +1. The time now is 08:39.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.