nref / Irrlicht.Net

The ubiquitous Irrlicht graphics engine for .NET
zlib License
5 stars 0 forks source link

Building net6.0 for windows #1

Open zzstuzor opened 1 year ago

zzstuzor commented 1 year ago

Hi @slater1, this looks like a great project, thanks for putting it together.

I've just gone through and built the irrlicht-mirror .lib files successfully and copied the x64 lib files over to the irrlicht.net repo /irrlicht/bin folders etc. I had to disable DX9 support by commenting out _IRR_COMPILE_WITH_DIRECT3D_9_ in IrrCompileConfig.h.

I'm using the Irrlicht17.0.sln file, with Visual Studio 2022 (v143) and the Windows SDK Version 10.0 (latest installed version).

I unloaded the irrlicht.netFramework project, but when I try to build irrlicht.netcore, I get the following error:

LNK2038 mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in ArchiveLoader.obj Irrlicht.NetCore D:\code\irrlicht.net.git\Irrlicht.NetCore\Irrlicht.lib(Irrlicht.obj)

I think I need to build the (/MD) but for curiosity I tried changing the RuntimeLibrary property to (/MT) but then I just get the following:

D8016 '/clr:netcore' and '/MT' command-line options are incompatible Irrlicht.NetCore

Is there something I'm doing wrong in the building of the irrlicht engine? I noticed in the comments it suggests Windows SDK v7.1 - would this potentially be causing my problems?

Also to build the .net wrapper, is it currently configured to build for netcore 3.1 or something? How do I specify I want to compile it for net6.0?

Thanks

nref commented 1 year ago

Hey @zzstuzor , thanks for posting the issue, and sorry for the trouble!

It's configured for net6.0-windows in Irrlicht.NetCore.vcxproj.

The dynamic linkage (/MD) should work. The Irrlicht solution outputs static libs as well as dynamic libs. The dynamic ones are expected by the netcore wrapper. Then at runtime Irrlicht.dll should be in the bin directory. There is a script Irrlicht.Net/get-irrlicht.ps1 which copies the right files to the right places.

So after building Irrlicht17.0.sln you have the .lib and .dll:

Irrlicht lib folder image

Irrlicht bin folder image

Then after running get-irrlicht.ps1, Irrlicht.NetCore has copies of both: image

Sorry that's not more straightforward.

nref commented 1 year ago

By the way, you can install the DX9 SDK if you want to use Direct3D.

https://www.microsoft.com/en-us/download/details.aspx?id=6812

When installing, you'll likely encounter error S1023. Super easy workaround.

https://learn.microsoft.com/en-us/troubleshoot/windows/win32/s1023-error-when-you-install-directx-sdk

zzstuzor commented 1 year ago

It's configured for net6.0-windows in Irrlicht.NetCore.vcxproj.

OK great.

The Irrlicht solution outputs static libs as well as dynamic libs.

Ah ok so I just had to build both configuratoins - [Release] and [Static lib - Release] in Irrlicht17.0.sln.

There is a script Irrlicht.Net/get-irrlicht.ps1 which copies the right files to the right places.

FYI this seems a little bit broken. The irrlicht-mirror that your repo refers to (commit 7448cdf) outputs to folders named lib/Win32-visualstudio, lib/Win64-visualStudio, bin/Win32-VisualStudio and bin/Win64-VisualStudio - whereas the script is expecting Win32 and x64. I tried to fix them but then it started complaining that irrlicht.net/irrlicht.dll doesn't exist - so I just copied the files manually.

image

Also note your repo has already has irrlicht.dll in the irrlicht.net/bin folders, for both debug and release - are they supposed to be there? I copied over them and now irrlicht.net builds successfully.

Thank you @slater1 , you are a legend!