project-navigation
Personal tools

Author Topic: Compile and debug with Eclipse in Windows  (Read 11263 times)

Offline Cel123

  • Cannon Fodder
  • **
  • Posts: 6
    • View Profile
Compile and debug with Eclipse in Windows
« on: July 28, 2012, 11:51:44 pm »
Im not only new to UFOAI, but also to C, so lacking even the most basic sense. What i would like to do is to run the game from Eclipse on my Windows 7 machine and then play the full campaign - I want to play the newest version, but it crashes a lot, and I thought i could maybe work out why if i ran the game in debug..

So, what i have done thus far:

1) Installed TortoiseGit from http://tortoisegit.googlecode.com/files/TortoiseGit-1.7.11.3-32bit.msi
2) With depth specified as 1, cloned git://ufoai.git.sourceforge.net/gitroot/ufoai/ufoai
3) Installed MinGW with the options of C compiler and MSYS from https://sourceforge.net/projects/mingw/files/latest/download?source=files
4) Edited PATH Environment Variable C:\MinGW\msys\1.0\bin;C:\MinGW\bin;
5) Got Eclipse CDT (Juno) from http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/juno/R/eclipse-cpp-juno-win32.zip

Next steps?:
Now i dont know how to compile C code at all, so i have no idea how i should import the ufoai source code into Eclipse workspace as a project that could then be compiled by Eclipse and run in debug mode?

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: Compile and debug with Eclipse in Windows
« Reply #1 on: July 29, 2012, 08:13:13 am »
Start eclipse and go to File->New->C++ Project (maybe hidden under Other->C++)
Select the ufoai checkout dir and click import.
Right click the ufoai project and select Properties
Go to the C/C++ Build options and make sure that Generate Makefiles automatically is disabled and the default build command is make. Save the options, and hit CTRL+B (or go to Project->Build)

Offline Cel123

  • Cannon Fodder
  • **
  • Posts: 6
    • View Profile
Re: Compile and debug with Eclipse in Windows
« Reply #2 on: July 29, 2012, 11:42:46 am »
Thanks Mattn!

When i go to File->New-> C++ project i come across two issues:
6a) after choosing the checkout dir it says "I:\ufoai\ufoai overlaps the location of another project 'ufoai'" and therefore does not allow me to click next
7a) there are a number of suboptions to choose from, which one should it be anyway- screenshot attached?

So i tried the following instead and may have gotten further
6b) File->Import Project->C/C++->Existing Code as Makefile Project
7b) Hit Next, and left the default options of Languages both C and C++ ticked, and Toolchain for Indexer Settings as <none> (other options were Cross GCC, GNU Autotools Toolchain, Microsoft Visual C++, MinGW GCC)

8) After checking the project properties you mentioned, which were like you said already, i tried building but got the following two errors:

Error 1:
make: *** [debug-mingw32-i386/cgame-campaign/client/cgame/campaign/cl_game_campaign.cpp.o] Error 127   ufoai          C/C++
Error 2:
/bin/sh: git: command not found   ufoai          C/C++ Problem

What are they / how can i build successfully?

p.s. in the checkout folder i see a new dir called debug-mingw32-i386 but there is not much in there, mainly empty subdirectories
p.p.s. additional new creations in the checkout folder are the following files: .project .cproject config.h Makefile.local

Offline Cel123

  • Cannon Fodder
  • **
  • Posts: 6
    • View Profile
Re: Compile and debug with Eclipse in Windows
« Reply #3 on: July 29, 2012, 12:00:23 pm »
i went back to my mingw installer and added the C++ compiler option (on top of C compiler and MSYS).
now, when i try to build in eclipse, the errors are the following:

Error 1:
/bin/sh: git: command not found   ufoai          C/C++ Problem
Error 2:
fatal error: SDL/SDL_endian.h: No such file or directory   byte.h   /ufoai/src/shared   line 31   C/C++ Problem
Error 3:
make: *** [debug-mingw32-i386/game/game/g_actor.cpp.o] Error 1   ufoai          C/C++ Problem

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: Compile and debug with Eclipse in Windows
« Reply #4 on: July 29, 2012, 01:34:41 pm »
you don't have the needed libs installed - SDL is a requirement e.g. - see here for a full list.

Offline Cel123

  • Cannon Fodder
  • **
  • Posts: 6
    • View Profile
Re: Compile and debug with Eclipse in Windows
« Reply #5 on: July 29, 2012, 05:11:07 pm »
tried to get the prerequisites to work with Eclipse for hours with no luck, so moved onto mingw-enabled command-line as a way to get more information where compilation goes wrong:

when i do:
cd I:\ufoai\ufoai
make

then the first lines that start to appear are:
curl-config: Command not found

Now i thought i have installed the libcurl library, but i may have done something wrong:
A) downloaded the source here http://curl.haxx.se/download.html
B) copied [LIBCURLHOME]\include to [MINGWHOME]\include
C) produced libcurldll.a and libcurl.a and copied them to [MINGWHOME]\lib (instructions from http://lenkite.blogspot.co.uk/2007/11/quickstart-libcurl-and-mingw-plain-http.html)

But i still get those lines:
curl-config: Command not found

1) Am i meant to run .\configure before i run make ? I dont even know what  .\configure does and i dont know whether i should pass any arguments to it, but in any case Windows command line does not recognize this command? (While make does work)

2) is curl-config not meant to be a variable with a value other than "curl-config" ? basically, is make meant to take care of all teh compilation automagically, or am i meant to edit some configuration file first or pass in some arguments etc?

i hope i have enough energy to not give up on this :)

thanks!

Offline Mattn

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 4831
  • https://github.com/mgerhardy/vengi
    • View Profile
    • Vengi Voxel Tools
Re: Compile and debug with Eclipse in Windows
« Reply #6 on: July 29, 2012, 05:17:28 pm »
not only headers, static libs and dlls are needed, also some pkg-config files (*.pc) and in the case of libcurl, curl-config is needed, too. curl-config should have been created by the compilation of libcurl. you have to copy this into your mingw /usr/bin directory.

the easiest would be to use the codeblocks package that is linked in the wiki.

Offline Cel123

  • Cannon Fodder
  • **
  • Posts: 6
    • View Profile
Re: Compile and debug with Eclipse in Windows
« Reply #7 on: July 29, 2012, 11:29:25 pm »
thanks! the link you referred to solved it - http://ufoai.org/wiki/index.php/Code::Blocks
i.e. i was able to compile very easily with the pre-packaged codeblocks (although compiling the maps took more than 3 hours :) )

in terms of debugging, even though i changed the target within codeblocks to windows_debug, im not sure i am able to debug properly e.g. if i open Debug-> Debugging Windows -> Running Threads then it is empty? or is this me not knowing how to use codeblocks?

 ta.

Offline Cel123

  • Cannon Fodder
  • **
  • Posts: 6
    • View Profile
Re: Compile and debug with Eclipse in Windows
« Reply #8 on: July 29, 2012, 11:31:22 pm »
here's the debugging output which seems to be ok:

Building to ensure sources are up-to-date
Build succeeded
Selecting target:
windows_debug
Adding source dir: I:\ufoai\ufoai\build\projects\
Adding source dir: I:\ufoai\ufoai\
Changing directory to: ../../
Adding file: ..\..\ufo.exe
Starting debugger:
done
Registered new type: wxString
Registered new type: STL String
Registered new type: STL Vector
Setting breakpoints
Debugger name and version: GNU gdb (GDB) 7.0
Child process PID: 10640
Program exited normally.
Debugger finished with status 0