SWIG?

Hey guys,

Has anyone managed to get Box2D working in C# using SWIG? I can't seem to get it to work. I'm cross-posting this from SO.

---

I'm trying to compile Box2D for use in C# with SWIG.

I've created this Box2D.i file,

Code: Select all

%module Box2D
%{
#include "Box2D/Box2D.h"
%}
%include "Box2D/Box2D.h"


Which I placed one level up from the Box2D.h file file, and "compiled" it with,

Code: Select all

swig.exe -csharp -c++ -includeall -ignoremissing -outdir SWIG Box2d.i


This gives me all the .cs wrapper classes and Box2D_wrap.cxx. Problem is, I'm not quite sure what to do next.

I've tried adding that cxx file back into the C++ project and recompiling with /cli enabled, but when I try using the library in a C# app I just get errors. I've tried creating a fresh CLI library and adding the cxx file and linking both the unmanaged Box2D.dll and .lib, which I think I got the compile once... but that didn't work either.

1. What am I doing wrong?
2. How can I get it to work?

Using CMake, Windows 7, Visual Studio 2010, latest Box2D from SVN.
I've not used SWIG before, but why don't you just use one of the Box2D C# ports?
genbox wrote:I've not used SWIG before, but why don't you just use one of the Box2D C# ports?


Thought they both used XNA, which I didn't like, but I see now that Farseer supports "vanilla" .NET. Maybe I'll just use that instead of killing myself then... project seems alive and healthy too. I thought it would be falling behind the C++ version.

Oh, btw Genbox, the samples don't compile. Looks like it's trying to connect to your repo which I don't have the credentials for, so I click cancel, and then it says "Open Offline?", I go "OK", and then it says,

T:\Farseer\Samples\DemoBaseXNA\DemoBase XNA.csproj : error : The project file 'T:\Farseer\Samples\DemoBaseXNA\DemoBase XNA.csproj' cannot be opened.

The project type is not supported by this installation.


The Class library compiles fine though.

Rev. 79650
That is when downloading the project off the source control directly. I always recommend the released files in the download section instead.

If you have any comments about Farseer Physics Engine, feel free to leave a message on our forums.

Original thread: https://box2d.org/forum/viewtopic.php?t=5790