Compling with Dev-C++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PaulBlay
    Knight
    • Jan 2009
    • 657

    Compling with Dev-C++

    Instructions from rephail, comments in italic.

    "invalid conversion from 'void*' to 'char*' (line 132 in *string_make in z-virt.c)
    Code:
    124:	char *res;
    /*... skip some lines ...*/
    130:	/* Allocate space for the string (including terminator) */
    131:	siz = strlen(str) + 1;
    132:	res = mem_alloc(siz);
    mem_alloc is defined in the same z-virt.c as
    Code:
    void *mem_alloc(size_t len)
    If I add a (char *) it compiles (hopefully that's correct).
    Code:
    	res = (char *)mem_alloc(siz);
    Same on line 148 same file.

    birth.c (and I guess other files) have a lot of these as well.

    I think they were reported as warnings by VC++ rather than errors (Dev-C++).

    [EDIT]The birth.c 'errors' are trickier and I can't change the file to get Dev-C++ to accept it.
    Last edited by PaulBlay; February 21, 2009, 20:59.
    Currently turning (Angband) Japanese.
  • takkaria
    Veteran
    • Apr 2007
    • 1951

    #2
    Originally posted by PaulBlay
    Instructions from rephail, comments in italic.

    "invalid conversion from 'void*' to 'char*' (line 132 in *string_make in z-virt.c)
    Code:
    124:	char *res;
    /*... skip some lines ...*/
    130:	/* Allocate space for the string (including terminator) */
    131:	siz = strlen(str) + 1;
    132:	res = mem_alloc(siz);
    mem_alloc is defined in the same z-virt.c as
    Code:
    void *mem_alloc(size_t len)
    If I add a (char *) it compiles (hopefully that's correct).
    Code:
    	res = (char *)mem_alloc(siz);
    Same on line 148 same file.

    birth.c (and I guess other files) have a lot of these as well.

    I think they were reported as warnings by VC++ rather than errors (Dev-C++).

    [EDIT]The birth.c 'errors' are trickier and I can't change the file to get Dev-C++ to accept it.
    I think you're trying to compile Angband as a C++ application, since all of this is perfectly valid C.
    takkaria whispers something about options. -more-

    Comment

    • AnonymousHero
      Veteran
      • Jun 2007
      • 1393

      #3
      Yeah, in C the general consensus seems to be to to not cast from malloc (or equivalent).

      Comment

      • PaulBlay
        Knight
        • Jan 2009
        • 657

        #4
        Windows + Dev-C++ (4.9.9.2)

        1. Get and install DevC++.

        2. Create a new project. Select "Empty Project" and "C project" from the dialog and put it in the source directory (you can place it elsewhere but you may need to fiddle about a bit more if you do).

        3. Add every C file in src\, except for the main*.c files. Then add main-win.c.

        4. Add all C files from the sub folders 'monster', 'object', 'player' and 'win' (could be placed in project subfolders to look neater but work if all added to the main list anyway).

        5. Add 'angband.rc' to the project from 'win'.

        6. Go to Project -> Project Options, and:
        1) In the "General" tab, ensure "Win32 console" is selected as type.
        2) Click on "Browse" under "Icon" and select angband.ico.
        3) In the "Build Options" tab, change the executable output directory to "..\".
        4) In the "Compiler" tab ensure "Support all ANSI standard C Programs" and "Attempt to support some aspects of traditional C programs" are set to 'No'.

        7. In the "parameters" tab, add:
        1) -mwindows -DWINDOWS -I. to the compiler options.
        2) -lmingw32 -lwinmm -mwindows to the linker options.

        8. Compile.

        [EDIT] Instructions at official site have now been updated.
        Last edited by PaulBlay; February 23, 2009, 11:16. Reason: main.c not required, right?
        Currently turning (Angband) Japanese.

        Comment

        • PaulBlay
          Knight
          • Jan 2009
          • 657

          #5
          Alternative version.

          This requires the Dev-C++ project file (Angband.dev), but saves a lot of steps.

          Windows + Dev-C++ (4.9.9.2)

          1. Get, install and run DevC++.

          2. Open 'Angband.dev' in the src\ directory.

          3. Compile.

          I think it should just work like that - if anyone wants the 'angband.dev' file to check, PM me.
          Last edited by PaulBlay; February 22, 2009, 15:40.
          Currently turning (Angband) Japanese.

          Comment

          • will_asher
            DaJAngband Maintainer
            • Apr 2007
            • 1124

            #6
            I tried compiling Angband with DevC++ , first I tried the instructions on the website http://rephial.org/wiki/Compiling#s2_4 then I tried PaulBlay's instructions in this thread (which are slightly different) and both times I got
            [build error] [attack.o] Error 1
            (This is the source of v3.1.1.1626 downloaded from http://rephial.org/)

            (Not that important to me since I downloaded the code mainly to look at it, not to compile it, but you might want to keep the instructions on the website accurate)
            Will_Asher
            aka LibraryAdventurer

            My old variant DaJAngband:
            http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...)

            Comment

            • will_asher
              DaJAngband Maintainer
              • Apr 2007
              • 1124

              #7
              Just got exactly the same result trying to compile FAangband. I used the windows port options (because I'm using windows) but not the SDL options. (I dont' know what SDL is, so I don't think I need it..?)
              Will_Asher
              aka LibraryAdventurer

              My old variant DaJAngband:
              http://sites.google.com/site/dajangbandwebsite/home (defunct and so old it's forked from Angband 3.1.0 -I think- but it's probably playable...)

              Comment

              Working...
              😀
              😂
              🥰
              😘
              🤢
              😎
              😞
              😡
              👍
              👎