Jump to content

Compiling D2TM with NetBeans / MinGW


Recommended Posts

Posted

Hi everyone,

Recently I've been trying to compile the D2TM sources with NetBeans using MinGW as compiler. After a few days I almost gave up, but today I made some progress. However I'm not a C/C++ guru, so to everyone who is interested: please help  ;D

Alright, what I've found out so far:

First, check out the sources using SVN. You can use the integrated SVN plugin in NetBeans, but the first time you use it it probably isn't installed. The installation is very straightforward, so I won't describe it here. Once it is installed, check out the source from http://code.google.com/p/dune2themaker/

Put the sources in a folder called Dune2TheMaker or whatever you like, and you want to check the 'Skip "trunk" and checkout only its content' checkbox. Click finish, and wait until SVN finishes downloading. At the time of writing, the latest revision is 114

Next, you want to create a new project. Create a new C/C++ Application project, NOT a C/C++ Project from Existing Code. This is what I did wrong all the time. When you try to make a project from existing code, NetBeans wants you to specify a makefile, but when you try to use the makefile supplied with D2TM it doesn't work. Anyway, just create a new C++ App. Name it the same as you named the directory with the source, so the project will be placed in the same directory.

When you open the project, you'll see it is still empty, so we're going to add the sources. Right click the project, and chose 'Add Existing Items from Folders'. Click add folder, and add the Dune2TheMaker folder. Now the D2TM source has been added to the project  ;D

Now, we still need to add the Allegro sources to the project, take a look at the 'How to get this And Compiling' document in the following thread to see where to get them:

http://forum.dune2k.com/index.php?topic=19313.0

EDIT: These zip files are also in the dependencies folder of the D2TM project.

Make a new folder somewhere, and put the Allegro sources in this folder. I made a folder in the NetBeansProjects folder with the name 'Includes'. Next go to the project properties in NetBeans, and go to the 'C++ Compiler' page. At the 'Include Directories' option, add the folder you just made. Now we've added the Allegro headers, but I'm not sure what to do with the lib files mentioned in the document  :-[

But we can do one more thing: try to build the project. First, you will see the compiler spitting out a lot of warnings, and in the end some errors. The first error, 'cEventManager.cpp:3: error: `cEventManager' has not been declared', is easy to fix: just add #include "cEventManager.h" to d2tmh.h. I'd put it at line 96.

Now let's try to rebuild the project. Still some errors concerning cEventManager.cpp, but I didn't take a look at them yet, as I first made this post :P

Anyone willing to help me out on getting this working, please do so ;). I would really like to get this compiling. I will keep you updated here when I find out something more.

Posted

I will try this with Eclipse and C++, but to be short: the lib files go into the 'lib' directory of minGW. Ie, the same place where you put your include files (ie in the include dir).

Once I have Eclipse with C and get it working, it will probably be the same as with NetBeans.

First, let me up that revision with a big refactor fix.

Edit:

- revision is now 115 :)

I have checked the dependecies; it looks like mingw uses .a files and not like MSVC .lib files. This means new libraries should be compiled in order to get it working in MinGW. MinGW is however more multi-platform than MSVC will ever be. I am now trying to get .a files for all dependencies. RakNet can be removed so that saves a few nasty dependecies already.

Posted

I have added the dependecies for MinGW32 , .a files. Update the SVN. I am now trying to get this compiling using MinGW. I bet the Raknet lib will be doing nasty, but for now Eclipse CDT is not working as I expected.

Once a working makefile is created, I will commit it, or if you have succeeded by then, I'd love to hear about that so I can add it to the project.

Posted

I have removed Raknet from the project. All the other dependencies have .a files now. So theoretically it should compile...

I haven't succeeded in creating a makefile yet. Eclipse CDT is not yet working. Actually my goal is now to make it possible to compile it by running "make".

Once that works, an IDE like Eclipse/NetBeans should be easy to use.

Posted

I could not get makefile's working by hand. So I gave Eclipse CDT another try, and with succes! See attached image! :) (yes I am running Windows 7).

The new revision has some structural changes in the project, so in order to compile it you can either copy the Eclipse project details or MSVC project, and work from there.

For NetBeans; i'd suggest you do:

- update to latest SVN first!

- start a new C++ project, location = dune2themaker directory.

- set up your toolkit (ie, the compile environment) to minGW. In Eclipse CDT you can specify this toolkit and it works out of the box.

- finally, add libraries to the linker, with these names (and in this order!):

fblend

alleg

alfontdll

almp3dll

Now, you should be able to compile the project. You will see a lot of warnings, but eventually it should compile.

The exe file is created in some subdirectory within the dune2themaker project dir. In my case this directory name was "Default", the same name as the "Default" settings for this project within Eclipse CDT.

The "bin" directory within your dune2themaker project dir should be empty at first (or non-existent), run the create_binary.bat file to create a new bin directory. Copy your exe file within the bin directory, and try to run it.

If you are using Eclipse CDT, you can also read the doc/EclipseCDT.doc file to get it working. I hope you can get further with it now :)

post-64-12833239889803_thumb.png

  • 2 weeks later...
Posted

I've been trying to get it working using your explanation and the .a files, and it looks like that part works OK. The problem now is that your code seems to have some errors. The most are easy to fix but that's not the point. I just don't understand how you are able to compile the code, if I am getting errors. Some examples:

- hwprof.cpp uses the old 'for-loop declaration' (The scope of variables declared in the for-loop declaration doesn't stop after the for-loop body)

- cBenegesMentat wasn't included in d2tmh.h

- another scope problem in hwprof.h, I wasn't sure how to fix it, so I did a usage search and saw it wasn't included anywhere, so I removed the bad part to get the rest compiling.

Don't worry, I copied the sources to another folder before altering them so I can't accidentally commit them. Like I said before, I just don't understand how you can possibly compile it. Any idea if I'm doing something wrong?

Posted

There are still some files that should not be included in the project, but that are in the repository.

Could you try this:

- exclude the files that give errors from the build. Start with the cBenegesMentat class and the hwprof (the latter is MSVC specific, so it will never work on MinGW).

If you still  have errors, post them here, and I'll take a quick look. It took a while for me to get it compiling with MinGW as well, but it was mostly because I tried to compile things that where not in the project tree of MSVC either. Meaning, the files should not be compiled at all.

Edit:

I'm not 'afraid' of people committing non-compilable code. I will simply revert those changes when I encounter them ;)

Posted

Finally, it works now :D

The profiler and cBenegesMentat files were the only ones giving problems. The fblend library wasn't included in the dependencies for MingW32, so I downloaded it from the fblend site and took the freedom to put it in the Mingw dependencies zip file. Here is a screenshot showing D2TM compiled in NetBeans:

http://www.xyzw.nl/D2TMNetBeans.PNG

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.