Sunday, August 12, 2012

BWAPI

Notes to self from getting BWAPI compiling (C++):

1.) Build issue w/ "invalid macro": it turns out that VS2010 has a different way of specifying preprocessor macro values. Change "_secure_scl 0" to "_secure_scl=0" in all projects to fix.

2.) Warnings: MSB8012: $(TargetName) ('BWAPILIB') does not match the Librarian's OutputFile property value 'C:\projects\src\bwapi\trunk\bwapi\Release\BWAPI.lib' ('BWAPI') in project configuration 'Release|Win32'. This may cause your project to build incorrectly. To correct this, please make sure that $(TargetName) property value matches the value specified in %(Lib.OutputFile). This was again a problem with the conversion between VS2008 and VS2010, at least in part. BWAPI's bottom-level C++ .lib file is built by a project called BWAPILIB, and in the VS2008 .vcproj project the output library is just named BWAPI.lib. VS's converter apparently didn't understand this convention, so the new generated .vcxproj TargetName is left unset, so it defaults to BWAPILIB, which produces an output file called BWAPILIB.lib, hence the warning. To eliminate the warning, just explicitly set TargetName in a PropertyGroup in the .vcxproj.

3.) A mysterious, vexing set of template instantiation errors occured inside of the STL vector.cpp file ('_Alloc': must be a class or namespace when followed by '::' / 'size_type' : is not a member of '`global namespace''missing ';' before identifier '_Sizet' / etc.), but VS didn't say what caused it to be instantiated incorrectly. By using msbuild from the command line I was able to get enough info to track it down to these lines of code:

    unsigned int min = abs(x - position.x);
    unsigned int max = abs(y - position.y);
    if ( max < min )
      std::swap<unsigned int>(min,max);

For some reason, explicitly adding the template argument to std::swap causes vector.cpp to go haywire. You have to delete the bolded code. Ultimately I think this is a VS compiler bug because it makes no sense to me as a C++ issue.

Hopefully we will now be able to start writing some AIs.

-M.

--
Hahahahaaaa!!! That is ME laughing at YOU, cruel world.
    -Jordan Rixon

I could not love thee, dear, so much,
Loved I not Honour more.

No comments: