Compiling FBX on Linux

When I try to compile an FBX file on Linux I get an error:

> Executing task: dotnet build /home/robin/Project/MGTest/MGTest.csproj /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary <

Microsoft (R) Build Engine version 17.1.1+a02f73656 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.

  Determining projects to restore...
  All projects are up-to-date for restore.
  /home/robin/Project/MGTest/Content/Cube.fbx
/home/robin/Project/MGTest/Content/Cube.fbx : error : Importer 'OpenAssetImporter' had unexpected failure! [/home/robin/Project/MGTest/MGTest.csproj]
  System.DllNotFoundException: Unable to load shared library 'libdl.so' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibdl.so: cannot open shared object file: No such file or directory
     at Assimp.Unmanaged.UnmanagedLibrary.UnmanagedLinuxLibraryImplementation.dlopen(String fileName, Int32 flags)
     at Assimp.Unmanaged.UnmanagedLibrary.UnmanagedLinuxLibraryImplementation.NativeLoadLibrary(String path)
     at Assimp.Unmanaged.UnmanagedLibrary.UnmanagedLibraryImplementation.LoadLibrary(String path)
     at Assimp.Unmanaged.UnmanagedLibrary.LoadLibrary(String libPath)
     at Assimp.Unmanaged.UnmanagedLibrary.LoadLibrary()
     at Assimp.Unmanaged.UnmanagedLibrary.LoadIfNotLoaded()
     at Assimp.Unmanaged.AssimpLibrary.CreatePropertyStore()
     at Assimp.AssimpContext.CreateConfigs()
     at Assimp.AssimpContext.PrepareImport()
     at Assimp.AssimpContext.ImportFile(String file, PostProcessSteps postProcessFlags)
     at Microsoft.Xna.Framework.Content.Pipeline.OpenAssetImporter.Import(String filename, ContentImporterContext context) in C:\BuildAgents\MonoGameWin1\work\f7381a85a626990\MonoGame.Framework.Content.Pipeline\OpenAssetImporter.cs:line 291
     at Microsoft.Xna.Framework.Content.Pipeline.ContentImporter`1.Microsoft.Xna.Framework.Content.Pipeline.IContentImporter.Import(String filename, ContentImporterContext context) in C:\BuildAgents\MonoGameWin1\work\f7381a85a626990\MonoGame.Framework.Content.Pipeline\ContentImporter.cs:line 45
     at MonoGame.Framework.Content.Pipeline.Builder.PipelineManager.ProcessContent(PipelineBuildEvent pipelineEvent) in C:\BuildAgents\MonoGameWin1\work\f7381a85a626990\MonoGame.Framework.Content.Pipeline\Builder\PipelineManager.cs:line 669
/home/robin/.nuget/packages/monogame.content.builder.task/3.8.0.1641/build/MonoGame.Content.Builder.Task.targets(138,5): error MSB3073: The command "dotnet /home/robin/.nuget/packages/monogame.content.builder.task/3.8.0.1641/build//../tools/netcoreapp3.1/any/mgcb.dll /quiet /@:"/home/robin/Project/MGTest/Content/Content.mgcb" /platform:DesktopGL /outputDir:"/home/robin/Project/MGTest/Content/bin/DesktopGL/Content" /intermediateDir:"/home/robin/Project/MGTest/Content/obj/DesktopGL/Content" /workingDir:"/home/robin/Project/MGTest/Content/"" exited with code 1. [/home/robin/Project/MGTest/MGTest.csproj]
The terminal process "dotnet 'build', '/home/robin/Project/MGTest/MGTest.csproj', '/property:GenerateFullPaths=true', '/consoleloggerparameters:NoSummary'" terminated with exit code: 1.

I’m running Pop!_OS 21.10 64-bit where I could not find libdl.so but I have libdl.so.2 which is the same file but maybe the wrong version. This made me try on a fresh install on Ubuntu 21.10 where the libdl.sofile showed up but still see the same error message.

This is my Content.mgcb file:

#----------------------------- Global Properties ----------------------------#

/outputDir:bin/$(Platform)
/intermediateDir:obj/$(Platform)
/platform:DesktopGL
/config:
/profile:Reach
/compress:False

#-------------------------------- References --------------------------------#


#---------------------------------- Content ---------------------------------#

#begin Cube.fbx
/importer:OpenAssetImporter
/processor:ModelProcessor
/processorParam:ColorKeyColor=0,0,0,0
/processorParam:ColorKeyEnabled=True
/processorParam:DefaultEffect=BasicEffect
/processorParam:GenerateMipmaps=True
/processorParam:GenerateTangentFrames=False
/processorParam:PremultiplyTextureAlpha=True
/processorParam:PremultiplyVertexColors=True
/processorParam:ResizeTexturesToPowerOfTwo=False
/processorParam:RotationX=-90
/processorParam:RotationY=0
/processorParam:RotationZ=0
/processorParam:Scale=1
/processorParam:SwapWindingOrder=False
/processorParam:TextureFormat=DxtCompressed
/build:Cube.fbx

The Cube.fbx is the default cube from Blender without Camera and Lights.

Is anyone successful compiling FBX files on Linux and which distribution are you using?

The script sets up MonoGame so that content compilation works right from the start. It uses wine to do so. Maybe the script provides enough info for you to make it work on PopOs?

@Kwyrky your script looks really promising! I started by testing on Ubuntu to remove my lack of Linux knowledge from the equation but I cannot start the editor and the content compiler still fails. If I understand it correct, the idea is to run the content tools in Windows scope to make them work. Maybe I need to do something specific to run the content editor and compiler in Wine scope? Right now I have just clicked the content editor icon in Ubuntu launcher and started the compiler from compiling a test project.

On which version of Ubuntu did you run the script? After the script is finished logout and login or reboot is necessary. After that everything should work.
The script generates a .log file in /tmp/. You can check the file to see if something did not work.

@Kwyrky I’m running it on Ubuntu 21.10. I have rebooted as you suggested and that didn’t change anything. There is no .log file in /tmp/ but that would also only be there if there was an error during execution right?

The log should be there, if you run the script it saves a log to this folder. Maybe /tmp/ gets cleaned up sometimes or on reboot? I don’t know… Did you see the two demo MonoGame applications running when you ran the script? If not you could try rerun the script and check if a new log gets output that you can then check?

Yes, I saw both the blue and red screens. Could be that the log is erased after reboot. I can do another attempt later this week.

ok that is a good sign if you saw the apps running because it does compile content (shader and spritefont). You should check the script folder (where you cloned it to) and execute the command dotnet run inside the folders where the .csproj files are. It should build the applications and start them after a logout / login or reboot.
For the mgcb-editor not sure but it should run… if not maybe a dependency needs to be installed? Maybe try to execute the command mgcb-editor (should work everywhere because it is installed as global command)

If you saw both apps running you don’t need to, everything should be installed correctly or the apps would not have started. I don’t remember which one has which color but I think the CornflowerBlue is a template project and the other one with MonoGameOrange is a simple project which just loads content to verify that content build works fine even for shaders and spritefonts.

I don’t know but maybe the assimp importer does not work correct here… You could try different importers on the file there was an issue with the importer but I don’t remember exactly what the issue eas and if this is what is happening here. Did the FBX compile before? Make sure that it is a valid FBX file. If possible try to compile it on Windows to check?

@Kwyrky I did a reinstall and caught the log file for your leisure :wink:

I still think though that the content compiler is not running through Wine as the error is still about the missing libdl.so file. A file that Windows should not be looking for.

There are different tools when looking at content… The mgcb-editor is a dotnet tool which should be installed globally and run outside of wine. But the content compilation itself is happening inside wine afaik. And since you can build and run the test applications I think the content compilation part is working. The mgcb-editor is not working for some reason. I don’t know why?
What happens when you open a terminal and type mgcb-editor and enter the command? Maybe this gives some useful info if the tool can’t find / is missing a dependency?

My issue is actually with the content compiler and not the editor. But to answer your question, the editor fails with the following error message

System.NullReferenceException: Object reference not set to an instance of an object.
   at Gtk.Widget.DrawnSignalCallback(IntPtr inst, IntPtr arg0, IntPtr gch)

Coming back to the content compiler I have here the output of executing the content compiler

robin@robin-Standard-PC-Q35-ICH9-2009:~/Projects/MGTest$ dotnet /home/robin/.nuget/packages/monogame.content.builder.task/3.8.0.1641/build//../tools/netcoreapp3.1/any/mgcb.dll /quiet /@:"/home/robin/Projects/MGTest/Content/Content.mgcb" /platform:DesktopGL /outputDir:"/home/robin/Projects/MGTest/Content/bin/DesktopGL/Content" /intermediateDir:"/home/robin/Projects/MGTest/Content/obj/DesktopGL/Content" /workingDir:"/home/robin/Projects/MGTest/Content/"
/home/robin/Projects/MGTest/Content/Cube.fbx
/home/robin/Projects/MGTest/Content/Cube.fbx: error: Importer 'OpenAssetImporter' had unexpected failure!
System.DllNotFoundException: Unable to load shared library 'libdl.so' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibdl.so: cannot open shared object file: No such file or directory
   at Assimp.Unmanaged.UnmanagedLibrary.UnmanagedLinuxLibraryImplementation.dlopen(String fileName, Int32 flags)
   at Assimp.Unmanaged.UnmanagedLibrary.UnmanagedLinuxLibraryImplementation.NativeLoadLibrary(String path)
   at Assimp.Unmanaged.UnmanagedLibrary.UnmanagedLibraryImplementation.LoadLibrary(String path)
   at Assimp.Unmanaged.UnmanagedLibrary.LoadLibrary(String libPath)
   at Assimp.Unmanaged.UnmanagedLibrary.LoadLibrary()
   at Assimp.Unmanaged.UnmanagedLibrary.LoadIfNotLoaded()
   at Assimp.Unmanaged.AssimpLibrary.CreatePropertyStore()
   at Assimp.AssimpContext.CreateConfigs()
   at Assimp.AssimpContext.PrepareImport()
   at Assimp.AssimpContext.ImportFile(String file, PostProcessSteps postProcessFlags)
   at Microsoft.Xna.Framework.Content.Pipeline.OpenAssetImporter.Import(String filename, ContentImporterContext context) in C:\BuildAgents\MonoGameWin1\work\f7381a85a626990\MonoGame.Framework.Content.Pipeline\OpenAssetImporter.cs:line 291
   at Microsoft.Xna.Framework.Content.Pipeline.ContentImporter`1.Microsoft.Xna.Framework.Content.Pipeline.IContentImporter.Import(String filename, ContentImporterContext context) in C:\BuildAgents\MonoGameWin1\work\f7381a85a626990\MonoGame.Framework.Content.Pipeline\ContentImporter.cs:line 45
   at MonoGame.Framework.Content.Pipeline.Builder.PipelineManager.ProcessContent(PipelineBuildEvent pipelineEvent) in C:\BuildAgents\MonoGameWin1\work\f7381a85a626990\MonoGame.Framework.Content.Pipeline\Builder\PipelineManager.cs:line 669

You asked if I could test the Cube.fbx on Windows, I haven’t yet but I’ve tested it on Ubuntu 16.04 where it works with the content compiler running outside Wine. I have not seen it work on Ubuntu 18 and 19 and dotnet 3.1 is not supported for 17.

Also I looked into how Wine works, and if I’m doing it correctly then I can confirm that dotnet.exe exists in the Wine prefix but when trying to execute dotnet.exe from the prefix it fails:

robin@robin-Standard-PC-Q35-ICH9-2009:~/.winemonogame/drive_c/windows/system32$ ls dotnet.exe
dotnet.exe
robin@robin-Standard-PC-Q35-ICH9-2009:~/.winemonogame/drive_c/windows/system32$ WINEPREFIX="/home/robin/.winemonogame" wine dotnet.exe
0009:err:module:__wine_process_init L"C:\\windows\\system32\\dotnet.exe" not found

Looks like assimp is missing this dll. I don’t know if it will help but you can try to switch from “Open Asset Import Library” to “Fbx Importer” in your .mgcb file and see if it helps.

It is a good idea but the FbxImporter is just a wrapper around Assimp

@Kwyrky I found why wine says it cannot find dotnet.exe. The wine prefix .winemonogame has 64-bit architecture which makes windows look for dotnet.exe inside syswow64 rather than system32. Maybe you should update the script to force the wine prefix to be of 32-bit architecture or update the destination of the unzippping to eg:

7z x "$SCRIPT_DIR/dotnet-sdk-31.zip" -o"/home/robin/.winemonogame/drive_c/windows/syswow64/"

That said, I have yet to see the content build work. I will continue looking into making it run.

1 Like

I don’t have time to look into it but good that you seem to make progress and that you can find out more. I don’t fully understand the 32/64 architecture thing because I just did not have the usecase of what you are trying there. I just tried mgcb-editor as a command and dotnet run for the projects so no content compilation explicitly.
What I can say is that this part of the script is coming from the original documentation. So since MG 3.8.1 is coming soon with updated documentation and everything… Maybe wait and see if this is still the same then and if not you could ask about that specifically again?

Did you find out more? I don’t have time to look into this but you could of course try yourself if creating a seperate wine prefix with 32 bit architecture helps?

I did try rolling the wine setup without your script but failed to make it work. I’ll give up for now and maybe try again when 3.8.1 or 3.9 comes out.

1 Like

I’m facing the same issue on my Manjaro.
After lurking a bit I found some clues:

  1. According to comment on FS#73830 : Some so links missing in glibc package (libdl.so and pthread.so), libdl.so was merged into libc.so in latest glibc package, so mgcb can’t find it.
  2. libdl’s call goes from AssimpNet package and few days ago AssimpNet devs pushed a code that trying to fix that: Starnick / AssimpNet / issues / #83 - liblibdl.so not found — Bitbucket
  3. I was trying to build mgcb from sources using AssimpNet beta package - failed. Then I added AssimpNet as git submodule and tried to rebuild all from scratch - and it failed again :sweat_smile:
    As a result I can switch my error from missing libdl to NullReferenceException somwhere in Assimp.MemoryHelper class. I don’t know how to fix it yet, but maybe this information will be useful to someone.
1 Like