Compiling spring (mingw and visual studio 7/8) - Page 13

Compiling spring (mingw and visual studio 7/8)

Discuss the source code and development of Spring Engine in general from a technical point of view. Patches go here too.

Moderator: Moderators

Post Reply
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

Convenience isn't an argument IMHO, you can still compile test versions using MSVC. And MinGW builds are far easier to automate because you can crosscompile... see for example http://www.osrts.info/~tvo/spring

About ABI compatiblilty, AFAIK the last C++ ABI change in GCC was from the 3.3 to the 3.4 series, so there'll actually be better ABI compatibility (MSVC breaks C++ ABI with every version IIRC).

I agree tho that the interface should have been written in C in the first place. I've been spending too much time already debugging marshalling of container objects over DLL boundaries and other related problems that wouldn't exist if the interface was written in pure C.

Anyway, TBH the pros by far outweight the cons... (full cross platform ability vs some inconvenience for some developers)

The .NET issue (plus all the ABI issues) could obviously be taken away totally if someone just adds a C version of the AI interface. I'd happily accept a patch that does that. Heck, the C++ wrapper could even be supplied DLL-side, so the interface looks the same but the actual interface between DLL and EXE is C.
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Post by hughperkins »

Tobi wrote:Anyway, TBH the pros by far outweight the cons... (full cross platform ability vs some inconvenience for some developers)
Fair enough. It's just a bit of a shock that's all.

Just ask AF how he felt about the changes to the GlobalAI for 0.73b1 ;-)

Note that there used to be an unresolved forking issue in both mingw and cygwin which prevented use of configure for large projects:

http://sourceforge.net/tracker/index.ph ... tid=102435
http://sourceforge.net/mailarchive/mess ... d=17996398

This issue has not been marked as resolved, and it makes me afraid that I wont be able to compile a mingw-based Spring.
Heck, the C++ wrapper could even be supplied DLL-side, so the interface looks the same but the actual interface between DLL and EXE is C.
Yeah, that sounds like a good solution.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

hughperkins wrote: Note that there used to be an unresolved forking issue in both mingw and cygwin which prevented use of configure for large projects:

http://sourceforge.net/tracker/index.ph ... tid=102435
http://sourceforge.net/mailarchive/mess ... d=17996398

This issue has not been marked as resolved, and it makes me afraid that I wont be able to compile a mingw-based Spring.
The buildsystem doesn't use the standard ./configure && make. It's one big hack based on scons :-) (so you need python, scons, some win32 python extension thingie, and the mingwlibs package). Look in the first post of this thread for more details.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Post by Tobi »

Updated mingwlibs URL in first post; added quick instructions for how to crosscompile using mingw32 on a linux box.
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Post by Kloot »

Most of the AI interface headers look like they'd be pretty straightforward to translate to pure C (except in those places where C++ std::structures are used that is :P), implementing them might however get a bit hairy as the I[Global]AICallback*'s would have to be dealt with in a sensible manner (by making them pointers to structs with function-pointer members maybe?)... and the non-interface parts of /ExternalAI that depend on those interfaces would have to be appropriately hacked as well. I could take a crack at it if you want, but don't expect a clean conversion. :)
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Post by hughperkins »

Kloot wrote:Most of the AI interface headers look like they'd be pretty straightforward to translate to pure C (except in those places where C++ std::structures are used that is :P), implementing them might however get a bit hairy as the I[Global]AICallback*'s would have to be dealt with in a sensible manner (by making them pointers to structs with function-pointer members maybe?)... and the non-interface parts of /ExternalAI that depend on those interfaces would have to be appropriately hacked as well. I could take a crack at it if you want, but don't expect a clean conversion. :)
Agreed. Started a thread and prototype here:

http://taspring.clan-sy.com/phpbb/viewt ... 615#142615

If you want to take the driving seat, that suits me very well.

Edit: details removed, please see linked thread
Last edited by hughperkins on 12 Nov 2006, 10:30, edited 1 time in total.
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

aaarrggggghhhhhhhhhhhh

What you're all suggesting would require MASSES of tedious menial work to the existing C++ AIs

Everybody keeps writting thigns then wondering why the AI devs dont use them, and why krogothe is the only guy to succesfully do it, its because krogothes stuff only required you to change #define MYCLASS ai to whatever global class your AI used to contain the IAICallback pointer.

Right now I think it would be easier to move to codeblocks than carry on using VS2003 and this ABI prototype, especially if I have to edit my code to do so.

And I'll eb damned if I have to switch from build menu->compile in VS to some wierd scons thing involving command prompts and extra programs to install in order to compile spring, chances are I just wont bother compiling spring again.

So please hugh dont just hand us a piece of code like that and expect everyone to start using it defacto standard. Changing the interface in this ABI dll on the AI side is going to be pure hell, days of tedious rewritting of algorithms using AI callbacks which I am not going to do. Implement an identical version of the original AI interface on the other side of the ABI layer or you'll fast find your the only person willing to use it.

pfft 11 thousand lines of code....
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Post by Kloot »

e: outdated
Last edited by Kloot on 15 Dec 2007, 16:06, edited 1 time in total.
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Post by hughperkins »

Tobi wrote:Updated mingwlibs URL in first post; added quick instructions for how to crosscompile using mingw32 on a linux box.
Getting error "Checking for C header file zlib.h... no"

Running scons configure from the parent directory of rts. The mingwlibs are in sub-directory mingwlibs. zlib.h does exist in the mingwlibs directory.
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

I think it's a very good idea... and for AF: someone could write some wrapper class to wrap the C interface back into C++ class, for backwards compatibility.
However, the interface would have to be huge: you need to be able to parse UnitDef, WeaponDef and all the STL containers that they use...
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Post by AF »

I doubt anybody cba doing that either.
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Post by Kloot »

Well, in case anyone wants to run with the idea anyway, here are the interface headers ported to C.
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Post by hughperkins »

Kloot wrote:Well, in case anyone wants to run with the idea anyway, here are the interface headers ported to C.
Edit: reply moved to http://taspring.clan-sy.com/phpbb/viewt ... 793#142793
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Post by hughperkins »

jcnossen wrote:However, the interface would have to be huge: you need to be able to parse UnitDef, WeaponDef and all the STL containers that they use...
Well, this type of wrapping has already been done once, to create the .Net interface; it didnt take very long, and there are generators left over from last time.

Having a C-interface may make embedding Mono easier.

By the way, successfully ran a mingw-compiled helloworld AI just now using the out-of-the-box spring. No name mangling issues, just worked.
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Post by hughperkins »

Still unable to build spring with scons/mingw. It looks like gcc is not in Python's path for some reason.

Edit: solved this by adding MINGDIR and PATH to global environment variables via control panel. It does state this in the instructions.
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Post by hughperkins »

Error message:

Code: Select all

Checking libraries
Checking for main() in C library GL... no
Checking for main() in C library opengl32... no
You need an OpenGL development library for this program
GL/gl.h does exist in the mingw directory pointed to by MINGDIR

Edit: Additional information from config.log:

Code: Select all

Checking for main() in C library GL... build\sconf_temp\conftest_12.c <- 
  |
  |            
  |             
  |            int
  |            main() {
  |            main();
  |            return 0;
  |            }
  |            
  |
  |
gcc -fsingle-precision-constant -frounding-math -fsignaling-nans -mieee-fp -O2 -pipe -fno-strict-aliasing -mfpmath=387 -mthreads -D_REENTRANT -D_SZ_ONE_DIRECTORY -Irts -Irts\System -Ilua\luabind -Ilua\lua\include -Imingwlibs\include -IG:\bin\mingw\include -Imingwlibs\include\freetype2 -IG:\bin\mingw\include\freetype2 -Imingwlibs\include\SDL -IG:\bin\mingw\include\SDL -Imingwlibs\include\AL -IG:\bin\mingw\include\AL -Imingwlibs\include\python2.4 -IG:\bin\mingw\include\python2.4 -c -o build\sconf_temp\conftest_12.o build\sconf_temp\conftest_12.c
g++ -mwindows -o build\sconf_temp\conftest_12.exe build\sconf_temp\conftest_12.o -Lrts\lib\streflop -Lmingwlibs\lib -LG:\bin\mingw\lib -lGL

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
g++: Internal error: Aborted (program collect2)
Please submit a full bug report.
See <URL:http://www.mingw.org/bugs.shtml> for instructions.
scons: *** [build\sconf_temp\conftest_12.exe] Error 1
no
Failed program was:
1: 
2:             
3:              
4:             int
5:             main() {
6:             main();
7:             return 0;
8:             }
9:             
10: 
Error message: failed to build test program
User avatar
jcnossen
Former Engine Dev
Posts: 2440
Joined: 05 Jun 2005, 19:13

Post by jcnossen »

Having a C-interface may make embedding Mono easier.
Wow quite true, then all the type problems have been fixed already and all that has to be done is generate the static class that binds to all the C functions. Should be a piece of cake. I probably don't mind doing that once the C interface is done.
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Post by hughperkins »

jcnossen wrote: Wow quite true, then all the type problems have been fixed already and all that has to be done is generate the static class that binds to all the C functions. Should be a piece of cake. I probably don't mind doing that once the C interface is done.
The C interface is now feature complete with AI .Net interface http://taspring.clan-sy.com/phpbb/viewt ... 615#142615
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Post by hughperkins »

Edit: whoops, posted to wrong thread.
User avatar
hughperkins
AI Developer
Posts: 836
Joined: 17 Oct 2006, 04:14

Post by hughperkins »

There's a post at the top of this thread with instructions and also a page in the wiki. The page in the wiki allows anyone to add clarifications and updates (eg remove link to 0.72). Maybe remove replace the post at head with a link to the wiki page?
Post Reply

Return to “Engine”