Problems compiling Test AI
Moderators: hoijui, Moderators
Problems compiling Test AI
I just tried to compile the global test ai from the taspring0.62b1 source code using c::b (i don´t want to spend hundreds of megabytes for visual studio)
compiling has been succesfull (although my dll is about 125kb compared to 64kb of the original test.dll), so i tried to set up a game; but everytime i want to run global ai script, there´s just the "wrong ai dll"-message that is displayed when using the old jcai version with spring 0.62b1.
does anybody have any ideas which mistakes i made?
compiling has been succesfull (although my dll is about 125kb compared to 64kb of the original test.dll), so i tried to set up a game; but everytime i want to run global ai script, there´s just the "wrong ai dll"-message that is displayed when using the old jcai version with spring 0.62b1.
does anybody have any ideas which mistakes i made?
See if the function names are exported correctly. They should be exported in the DLL like this:
The problem is that the used calling convention here (which is __stdcall) will export the function names differently, with argument sizes attached to it.
So you need to use the .def file that is included with the source, but maybe you didn't use that which would cause "Wrong ai dll" i guess.
If this is not the cause then you have either a wrong spring version or a wrong spring source...
Code: Select all
GetGlobalAiVersion
GetAiName
GetNewAI
ReleaseAI
So you need to use the .def file that is included with the source, but maybe you didn't use that which would cause "Wrong ai dll" i guess.
If this is not the cause then you have either a wrong spring version or a wrong spring source...
well i should now export the needed functions, at least the autocreated .def-file says
but now spring always terminates when loading the ai. i only made some changes in the testai.cpp in order to be able to compile it with code::blocks, but the functions themselves have not been changed.
testai.h, globalai.cpp and globalai.h are just the same as in the 0.62b1 source
Code: Select all
EXPORTS
GetAiName @1
GetGlobalAiVersion @2
GetNewAI @3
ReleaseAI @4
testai.h, globalai.cpp and globalai.h are just the same as in the 0.62b1 source
Code: Select all
//testai.cpp
#include <windows.h>
#include "TestAI.h"
#include "globalai.h"
#include <set>
#define EXPORT __declspec(dllexport)
#ifdef __cplusplus
extern "C" {
#endif
std::set<IGlobalAI*> ais;
EXPORT int GetGlobalAiVersion()
{
return GLOBAL_AI_INTERFACE_VERSION;
}
EXPORT void GetAiName(char* name)
{
strcpy(name,AI_NAME);
}
EXPORT IGlobalAI* GetNewAI()
{
CGlobalAI* ai=new CGlobalAI();
ais.insert(ai);
return ai;
}
EXPORT void ReleaseAI(IGlobalAI* i)
{
delete (CGlobalAI*)i;
ais.erase(i);
}
#ifdef __cplusplus
}
#endif
well i´m not quite shure; afaik you use
to tell a gnu gcc compiler to use stdcalling convention; but this didnt work as well and always results in a crash at the beginning of the game.
so far i´ve given up, i´ll try it with another compiler; microsoft c++ compiler would be the best, but there aren´t even basic headers like windows.h included in the microsoft c++ toolkit
Code: Select all
void foo() __attribute__((stdcall));
so far i´ve given up, i´ll try it with another compiler; microsoft c++ compiler would be the best, but there aren´t even basic headers like windows.h included in the microsoft c++ toolkit

i don´t think a wrong calling convention is the problem because it says
so by the leading _ and the @n appended these functions should use stdcall. i´ve absolutely no idea whats wrong.
@zaphod: which compiler do you use? im facing exactly the same problem compiling jcai
Code: Select all
Warning: resolving _GetAiName by linking to _GetAiName@4
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Warning: resolving _GetNewAI by linking to _GetNewAI@0
Warning: resolving _ReleaseAI by linking to _ReleaseAI@4
@zaphod: which compiler do you use? im facing exactly the same problem compiling jcai

True, it's always good to have compatibility across compilers. Though I think we should just wait for the linux port to be merged and then see how modules are handled...nevertheless i think i would be goud to figure out how to do that with gnu gcc under code::blocks, not only because it is free but it also saves a lot of disc space...
I don't really like the use of a .def file, since normally you can just see the calling convention from the function name.
i agree with you :)I don't really like the use of a .def file, since normally you can just see the calling convention from the function name.
i think beeing able to compile with gcc would would increase the number of people who could work on ais or other stuff. installing vc.net probably scares a lot of people....