Compiling spring (mingw and visual studio 7/8)
Moderator: Moderators
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.
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.
- hughperkins
- AI Developer
- Posts: 836
- Joined: 17 Oct 2006, 04:14
Fair enough. It's just a bit of a shock that's all.Tobi wrote:Anyway, TBH the pros by far outweight the cons... (full cross platform ability vs some inconvenience for some developers)
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.
Yeah, that sounds like a good solution.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.
The buildsystem doesn't use the standard ./configure && make. It's one big hack based on sconshughperkins 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.

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
), 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. :)

- hughperkins
- AI Developer
- Posts: 836
- Joined: 17 Oct 2006, 04:14
Agreed. Started a thread and prototype here: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), 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. :)
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.
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....
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....
- hughperkins
- AI Developer
- Posts: 836
- Joined: 17 Oct 2006, 04:14
Getting error "Checking for C header file zlib.h... no"Tobi wrote:Updated mingwlibs URL in first post; added quick instructions for how to crosscompile using mingw32 on a linux box.
Running scons configure from the parent directory of rts. The mingwlibs are in sub-directory mingwlibs. zlib.h does exist in the mingwlibs directory.
- hughperkins
- AI Developer
- Posts: 836
- Joined: 17 Oct 2006, 04:14
Edit: reply moved to http://taspring.clan-sy.com/phpbb/viewt ... 793#142793Kloot wrote:Well, in case anyone wants to run with the idea anyway, here are the interface headers ported to C.
- hughperkins
- AI Developer
- Posts: 836
- Joined: 17 Oct 2006, 04:14
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.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...
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.
- hughperkins
- AI Developer
- Posts: 836
- Joined: 17 Oct 2006, 04:14
- hughperkins
- AI Developer
- Posts: 836
- Joined: 17 Oct 2006, 04:14
Error message:
GL/gl.h does exist in the mingw directory pointed to by MINGDIR
Edit: Additional information from config.log:
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
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
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.Having a C-interface may make embedding Mono easier.
- hughperkins
- AI Developer
- Posts: 836
- Joined: 17 Oct 2006, 04:14
The C interface is now feature complete with AI .Net interface http://taspring.clan-sy.com/phpbb/viewt ... 615#142615jcnossen 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.
- hughperkins
- AI Developer
- Posts: 836
- Joined: 17 Oct 2006, 04:14
- hughperkins
- AI Developer
- Posts: 836
- Joined: 17 Oct 2006, 04:14