Page 1 of 1

Building Ogre .NET bindings

Posted: Fri Aug 09, 2019 3:49 pm
by demeter
Hello,

I found out Ogre has official .NET bindings now-a-days and would like to use it because I'm experienced with .NET but know only little about C++ and zero about cmake. :)

I found this bit of info: https://github.com/OGRECave/ogre/tree/m ... les/Csharp but I can't find that "build/csharp" folder that it talks about. I downloaded the master branch and looked for build, csharp, and *.cs, but except for a cmake file and the demo .cs file, I cant find anything.

I also searched through a prebuilt SDK download, but I didnt find any "ogre.dll", i did find a "libOgre.ddl" though.

Does anyone know how to build for .NET use, or know of some more info about this?

thanks

Re: Building Ogre .NET bindings

Posted: Fri Aug 09, 2019 5:19 pm
by paroj
the contents of "build/csharp/" will be auto-generated if you build ogre with the CSharp component (requires SWIG). Here, "build" refers to the build folder.
The prebuild SDK currently does not include the .NET part as it was not yet tested on Windows. However I probably can change that for the devel builds..

Re: Building Ogre .NET bindings

Posted: Fri Aug 09, 2019 9:20 pm
by demeter
Hi, i gotten a lot further now...

* I managed to get CMake generate with csharp support (i had to manually configure the SWIG exe (swigwin 4.0.0) in CMakeCache.txt) -> then it worked
* I built the c++ OGRE.sln -> csharp folder
* Building these cs files failed, so i made a .net project and used Visual Studio to see what was going on. I fixed two simple mistakes (an unneeded override and an enum that used uint values but was signed int) -> ogre.dll

But now, lastly, i'm lacking this libOgre.so you speak of. It didn't get generated anywhere, and when I run the built example.cs it complains Unable to load DLL 'libOgre_d', so that makes sense. But I don't know where to get it.

thanks

Re: Building Ogre .NET bindings

Posted: Sat Aug 10, 2019 7:08 am
by paroj
The csharp bindings consist of two parts. The ogre.dll you built and the libOgre.so native Part (probably Ogre_d.dll on Windows).
It should be located in build/lib or the csharp subfolder. Maybe you will have to rename it to libOgre_d.dll

Re: Building Ogre .NET bindings

Posted: Sat Aug 10, 2019 3:15 pm
by demeter
The libOgre project doesn't build, because OgreOverlay doesn;t build, because it didn't find ft2build.h.

So apparently is from the FreeType library (although the CMake log suggested FreeType was good to go). So, I downloaded freetype (https://github.com/ubawurinna/freetype-windows-binaries), added the include folder and now it gives me linker errors, eg.:

unresolved external symbol _FT_Init_FreeType referenced in function "public: virtual void __thiscall Ogre::Font::loadResource(class Ogre::Resource *)" (?loadResource@Font@Ogre@@UAEXPAVResource@2@@Z) OgreOverlay C:\ogre3d\build\Components\Overlay\OgreFont.obj 1

I can see the mising method names with a texteditor in the freetype.lib, so it's the right library. But when i add them to the library folders in the Visual Studio project, it keeps giving the same linker errors. So, either I include them incorrectly, or it doesnt like something about it...

Re: Building Ogre .NET bindings

Posted: Sat Aug 10, 2019 3:49 pm
by frostbyte2
meh, loading precompiled c++ binaries never works...( can be mismatched compiler version, compilation/linker flags etc )
its best to build all dependencies from source with the same compiler env/settings and on the same machine( just to be on the safe side )
that way if anything goes wrong at least you know whats the problem so you can fix it.
afaik ogre build scripts should download all dependencies and build them for you
otherwise https://bitbucket.org/cabalistic/ogredeps

Re: Building Ogre .NET bindings

Posted: Sat Aug 10, 2019 8:03 pm
by paroj
Yeah, freetype should have been built in build/Dependencies. Maybe it did Not properly find the debug lib name

Re: Building Ogre .NET bindings

Posted: Sun Aug 11, 2019 9:27 pm
by demeter
I think I'm almost there now... I can build almost all projects (dlls) of Ogre, and when I copy the build output to the example build output folder, the example starts but crashes when loading the scene. Indeed: dll Plugin_DotScene wont compile yet. (I just ignored it until now because I believed it unneeded for my usecase).

As a matter of fact, only 2 projects with errors remain:

Image

I searched for these identifiers to try fixing the mismatches, but can't find their origin...

If you want me to repost this as a new question, let me know. This is just a "getting the 2 remaining Ogre dlls to build on Windows" problem.

Re: Building Ogre .NET bindings

Posted: Sun Aug 11, 2019 11:11 pm
by paroj
Something is wrong with your pugixml build. Either disable ogre_tools and dotscene Plugin in cmake or Go Back to the 1.12.1 tag

Re: Building Ogre .NET bindings

Posted: Mon Aug 12, 2019 11:51 am
by demeter
It works!

Wow, quite a journey :) Thanks for the help.

I made an extensive blog about the cleaned up process, for my future self and maybe others: https://hellholegames.wordpress.com/201 ... evelopers/

Thanks for all the help!!

Re: Building Ogre .NET bindings

Posted: Fri Aug 16, 2019 11:08 am
by paroj
demeter wrote:
Mon Aug 12, 2019 11:51 am
I made an extensive blog about the cleaned up process, for my future self and maybe others: https://hellholegames.wordpress.com/201 ... evelopers/
https://github.com/OGRECave/ogre/pull/1242

just updated the devel build to include the C# sources as well. Everything .NET related is now in lib/cli/. Take a look at the latest SDK master snapshot whether this simplifies things for you.