Menu

Nethack compilation, preprocessor

2009-08-05
2012-09-26
  • Danilo J Bonsignore

    I would expect an already made Dev-C++ project ready to compile Nethack but nobody provided. Finding the right set of #defines does take time and it just refuses to read global.h to make the prerequisite makedefs.c app. So... what about running the C/C++ preprocessor alone from the IDE? I hate the idea of going down to djgpp to make the thing. I would expect also the Nethack Devteam to provide the Dev-C++ project but they seem to be, well, like hibernating. In any case, what are the chances of getting a bootstrapped version of the IDE source code, if it is true it is no longer maintained? All in the interest of minimizing effort time to make some minor changes to some software...

     
    • cpns

      cpns - 2009-08-06

      Just to be clear about GCC, DJPP, and MinGW, and compilers in general:

      1) GCC is the GNU Compiler Collection. It is primarily, though not exclusively used on Linux. Linux is where it is developed before being re-targetted to other environments by separate project groups or sub-groups.

      2) DJPP is an MS-DOS port of GCC. It was an impressive effort in its time. Its time however has probably passed.

      3) MinGW is a Windows port of GCC. It uses Microsoft's C runtime library, so cannot itself be used for directly porting Linux code that relies on Linux and GNU library specific calls.

      4) You may also come across Cygwin which is a Linux emulation layer for Windows that allows GCC to run on Windows with the GNU C library. Its primary purpose is the direct porting of Linux code to Windows. It is horrible; if you don't have to use it; don't!

      5) Dev-C++ is an IDE that can drive GCC based toolchains (MinGW by default).

      6) Other IDEs exist that will do the same, including Eclipse/CDT and Code::Blocks.

      7) There are other free compilers/IDE, including VC++ 2008 Express. Personally I'd recommend that over GNU on WIndows simply for the more powerful debugger.

      8) Although GDB is a capable debugger, it is hard work. Moreover Dev-C++'s graphical integration with GDB sucks big-time, and IMO is virtually unusable even when it deigns to work.

      Clifford

       
    • cpns

      cpns - 2009-08-05

      You seem to be under the odd assumption that we all know what the hell Nethack is! Post a link so we might know what you are talking about.

      Since they are completely separate projects why do you believe that one should directly support the other amongst the the many thousands of open source projects available. What makes either so special in your view?

      Why would you have to go "down to djgpp", Dev-C++ includes a distribution of MinGW/GCC, a native 32bit Windows implementation of GCC; why would you use djgpp in preference, and why would it fare any better?

      I am not sure how you think running the C-preprocessor stand alone will help, but you can do that. c:\dev-cpp\bin\cpp.exe is the C-preprocessor. It is documented at http://gcc.gnu.org/onlinedocs/cpp/ . If you want to run it as part of your project, Dev-C++ supports makefile customisation/extension via include file specification, so you can add a build step. You can also use file specific build commands for individual files. You certainly don't need to hack the Dev-C++ source to achieve what you want; that really is a sledgehammer to crack a nut.

      I have no idea what you mean by a "bootstrapped version of the IDE source code", but it is an open source project, the source code is available. It is however written in Delphi, so that may be a problem for you; it is for most of us!.

      I really believe that you are attacking this problem in entirely the wrong way (or perhaps you are just enjoying your paragraph-free stream-of-conciousness rant?). What you should perhaps do is make it clear what code you are trying to compile (a link to the project or download), and post the complete Compile Log text as requested in the "PLEASE READ BEFORE POSTING A QUESTION" thread, along with the other requested information.

      If the code is intended to be built in a Linux environment with the typical configure/make sequence, then to support that under MinGW you will need the MSYS shell from www.mingw.org. Since Dev-C++'s MinGW installation is a subset, you may want a complete separate installation of MinGW for this build.

      Clifford

       
    • Danilo J Bonsignore

      Perfect, I thought Nethack was world famous! Actually it is The RPG, the mother of all RPGs (even if it is still called Rogue-like), the most complete game of the kind ,and has been around since... indeed it is so old that it was a UNIX with ASCII environment and only recently got graphics. Which several authors contribute to with their own environments. Somehow I suspect you open-source were modelled around those guys s code... You should have no problem finding the official site and downaloads, source, spoilers. It would be only natural to find a *.dev file as it is compilable with djgpp.

      So CPP.EXE is the C preprocessor in the Dev-C++ distribution? What I usually do in these cases is to run the preprocessor on the same set of files I want compiled, then inspect the resultant code. It will be a full outlay of what the laguage compiler proper will see once all #includes, #defines, #ifdefs, etc. are fully executed. Since Nethack is multiplatform, it is the easiest way to find which set of preprocessor macros have to be defined to reach the Windows version. It is much easier than mentally executing a makefile. In some cases it is even better to preprocess if your #includes do not change (much) and if you do not use macros, which is one of the reasons why macros are not a very healthy practice compared to inlining. I cant see yet why the globals.h header is not being included so basic data type typedefs are missing.

      If it is written in Delphi it is not bootstrappable. Bootstrap means the compiler can be used to compile itself in its own compilable language. It means somebody would have to rewrite the code outside Delphi, in C, then compile Dev-Cpp from C using Dev-Cpp. The concept is for compilers, but I do tend to see IDEs as the compiler itself.

      Going down to djgpp would mean to wade in their distributions, their equivalent executables and use makefiles and consoles to use it, compared to the ready made IDE environment. I already did chain tool djgpp in Windows through ActiveX to run as backend process, but the environment was Windows and web, which is just a little bit more complex than writing a *.bat but more relaxed thanks to the windowing.

      I am really surprised, can there exist people who do not know of Nethack? Fact is I ve played Nethack for many more years than chess could interest me.

       
    • cpns

      cpns - 2009-08-06

      > Perfect, I thought Nethack was world famous!
      Amongst the text mode RPG playing geek fraternity perhaps, but I suggest that that is a rather small constituency. Not every programmer is either playing or writing games. My distaste for computer games is legendary around here. That was not really my point, (and of course I Googled it); it was rather the presumptuousness of your approach, and as a general point you should provide precise citations of the code you are discussing.

      > It would be only natural to find a *.dev file as it is compilable with djgpp.
      Like your opinion of Nethack's position in the world, your assumption of Dev-C++'s position is rather high.

      > What I usually do in these cases is to run the preprocessor on the same
      > set of files I want compiled [...]
      You can also use GCC with the -E option, which simply invokes cpp. With the rest of your [...] explanation you do realise that you are teaching grandma to suck eggs!? I know why you might want to do that. I don't however believe it to be the most efficient approach in this instance.

      > If it is written in Delphi it is not bootstrappable. . Bootstrap means [...]
      I know what bootstrapping a compiler is (grandma and eggs again), but that is why I was confused by your use of the term. Dev-C++ is not a compiler, so teh concept of bootstrapping in that context is nonsense. It is merely an IDE. The compiler it uses is GCC (just like djpp which is also a targeted build of GCC). Although Dev-C++ can use any GCC compiler, it is provided with the MinGW version of GCC, which like djpp does not require a Linux environment to run. Unlike djpp it is a native Win32 32bit compiler rather than an MS-DOS 32bit Extended compiler. djpp was useful under 16bit DOS and 16bit Windows when no 32bit subsystem existed, but no longer has any mainstream use. MinGW/GCC can be found at www.mingw.org, where you can get newer and older versions of the compiler, and being GCC it can be bootstrapped; though I cannot think of a single reason why that is relevant in this instance. A complex way of solving a simple problem perhaps!

      This page: http://nethack.wikia.com/wiki/Compiling describes compiling Nethack with MinGW, which is probably precisely what you need. You may not need to download the full MinGW suite since Dev-C++ includes the core part of that, but the PATH will then be c:\dev-cpp\bin rather than c:\mingw\bin

      If you want to build and edit within Dev-C++ you can use the makefile.gcc as a custom makefile and Dev-C++ will use that rather than generating one for itself.

      I think your problem comes from a fundamental misunderstanding of what Dev-C++ is.

      > I am really surprised, can there exist people who do not know of Nethack?
      There's more - would you believe that there are actually people who do not play (or write) computer games at all! You need to get out more! ;-) I am perhaps equally surprised that you you did not know of MinGW!

      As a final point, I reckon that you are aiming your 'complaint' at the wrong target. I would suggest that it is the Nethack developer community that would be responsible for providing project files for Dev-C++, not the Dev-C++ user community. Perhaps they are not intersecting communities?

      Clifford

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.