I’ve been trying to get my dev environment set up on my Mac per the instructions listed on the official MonoGame site and I have been having some issues.
I was able to eventually get Visual Studio 2022 to run a MonoGame project (target: mgdesktopgl) created with the .NET 6 SDK listed at the end of the article. The game runs great! However, the moment I had an image to my Content.mgcb file via the MGCB editor, my game won’t compile and I get the following error:
“Importer “TextureImporter” had unexpected failure!”
“The command “dotnet mgcb /quiet /@:”[filepath]/MyProject/Content/Content.mgcb” /platform:DesktopGL /outputDir:"[filepath]/MyProject/Content/bin/DesktopGL/Content" /intermediateDir:"[filepath]MyProject/Content/obj/DesktopGL/net6.0/Content" /workingDir:"[filepath]/MyProject/Content/"" exited with code 1. (MSB3073) (MyProject)"
Could I please get some advice here? I’ve seen elsewhere people recommend downloading VS 2012 as there is some sort of arcane dependency only that version actually has but I am on Mac so that is not possible afaik.
Thank you so much for any help, I just want to do a very simple task and it has been quite the headache.
Hi,
check that you have version 3.8.1.303
try running mgcb-editor-mac from command line dotnet mgcb-editor-mac
tell me if your mgcb-editor starts correctly?
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET program, but dotnet-mgcb-editor-mac does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
I have installed mgcb editor as instructed in all Mac tutorials I could find but it doesn’t seem to work. I have both .NET 6.0 x64 and ARM64 installed, not sure if that is relevant.
Building DesktopGLTest (Debug)
Build started 09/21/2022 12:09:39.
__________________________________________________
Project "/Users/gacarr/Documents/game-dev/DesktopGLTest/DesktopGLTest.csproj" (Build target(s)):
Target RunContentBuilder:
dotnet tool restore
Tool 'dotnet-mgcb' (version '3.8.1.303') was restored. Available commands: mgcb
Tool 'dotnet-mgcb-editor' (version '3.8.1.303') was restored. Available commands: mgcb-editor
Tool 'dotnet-mgcb-editor-linux' (version '3.8.1.303') was restored. Available commands: mgcb-editor-linux
Tool 'dotnet-mgcb-editor-windows' (version '3.8.1.303') was restored. Available commands: mgcb-editor-windows
Tool 'dotnet-mgcb-editor-mac' (version '3.8.1.303') was restored. Available commands: mgcb-editor-mac
Restore was successful.
dotnet mgcb /quiet /@:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/Content.mgcb" /platform:DesktopGL /outputDir:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/bin/DesktopGL/Content" /intermediateDir:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/obj/DesktopGL/net6.0/Content" /workingDir:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/"
/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/ball.png
/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/ball.png : error : Importer 'TextureImporter' had unexpected failure!
System.DllNotFoundException: Unable to load shared library 'FreeImage' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libFreeImage, 0x0001): tried: 'libFreeImage' (no such file), '/usr/local/lib/libFreeImage' (no such file), '/usr/lib/libFreeImage' (no such file), '/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/libFreeImage' (no such file)
at FreeImageAPI.FreeImage.GetFileTypeS(String filename, Int32 size)
at FreeImageAPI.FreeImage.GetFileType(String filename, Int32 size) in /home/runner/work/MonoGame/MonoGame/MonoGame.Framework.Content.Pipeline/Utilities/FreeImageAPI.cs:line 122
at Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.Import(String filename, ContentImporterContext context) in /home/runner/work/MonoGame/MonoGame/MonoGame.Framework.Content.Pipeline/TextureImporter.cs:line 83
at Microsoft.Xna.Framework.Content.Pipeline.ContentImporter`1.Microsoft.Xna.Framework.Content.Pipeline.IContentImporter.Import(String filename, ContentImporterContext context) in /home/runner/work/MonoGame/MonoGame/MonoGame.Framework.Content.Pipeline/ContentImporter.cs:line 45
at MonoGame.Framework.Content.Pipeline.Builder.PipelineManager.ProcessContent(PipelineBuildEvent pipelineEvent) in /home/runner/work/MonoGame/MonoGame/MonoGame.Framework.Content.Pipeline/Builder/PipelineManager.cs:line 669
/Users/gacarr/.nuget/packages/monogame.content.builder.task/3.8.1.303/build/MonoGame.Content.Builder.Task.targets(142,5): error MSB3073: The command "dotnet mgcb /quiet /@:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/Content.mgcb" /platform:DesktopGL /outputDir:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/bin/DesktopGL/Content" /intermediateDir:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/obj/DesktopGL/net6.0/Content" /workingDir:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/"" exited with code 1.
Done building target "RunContentBuilder" in project "DesktopGLTest.csproj" -- FAILED.
Done building project "DesktopGLTest.csproj" -- FAILED.
Build FAILED.
/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/ball.png : error : Importer 'TextureImporter' had unexpected failure!
/Users/gacarr/.nuget/packages/monogame.content.builder.task/3.8.1.303/build/MonoGame.Content.Builder.Task.targets(142,5): error MSB3073: The command "dotnet mgcb /quiet /@:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/Content.mgcb" /platform:DesktopGL /outputDir:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/bin/DesktopGL/Content" /intermediateDir:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/obj/DesktopGL/net6.0/Content" /workingDir:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/"" exited with code 1.
0 Warning(s)
2 Error(s)
Time Elapsed 00:00:00.46
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Build: 2 errors, 0 warnings
It definitely seems the issue is mgcb? So I guess I should rephrase my question to “how can I properly install mgcb-editor” on an M1 Mac?
Hi there! It should be an easy fix… What your going to want to do is follow the steps you did to install SDL in my tutorial, but instead your gonna want to clone FreeImage, just simply google something like ‘FreeImage GitHub’. Clone it, run the makefile, and run sudo make install. Should fix it!
Edit: Just saw your other post below! Do the same thing for freetype, clone it, cd into the directory, run make and then sudo make install.
Tried adding a spritefont to see if it was just a problem with pngs and I got the following error when I tried to build:
Building DesktopGLTest (Debug)
Build started 09/21/2022 13:46:10.
__________________________________________________
Project "/Users/gacarr/Documents/game-dev/DesktopGLTest/DesktopGLTest.csproj" (Build target(s)):
Target RunContentBuilder:
dotnet tool restore
Tool 'dotnet-mgcb' (version '3.8.1.303') was restored. Available commands: mgcb
Tool 'dotnet-mgcb-editor' (version '3.8.1.303') was restored. Available commands: mgcb-editor
Tool 'dotnet-mgcb-editor-linux' (version '3.8.1.303') was restored. Available commands: mgcb-editor-linux
Tool 'dotnet-mgcb-editor-windows' (version '3.8.1.303') was restored. Available commands: mgcb-editor-windows
Tool 'dotnet-mgcb-editor-mac' (version '3.8.1.303') was restored. Available commands: mgcb-editor-mac
Restore was successful.
dotnet mgcb /quiet /@:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/Content.mgcb" /platform:DesktopGL /outputDir:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/bin/DesktopGL/Content" /intermediateDir:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/obj/DesktopGL/net6.0/Content" /workingDir:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/"
/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/Score.spritefont
Building Font /System/Library/Fonts/Supplemental/Arial.ttf
/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/Score.spritefont : error : Processor 'FontDescriptionProcessor' had unexpected failure!
System.DllNotFoundException: Unable to load shared library 'freetype6' or one of its dependencies. In order to help diagnose loading problems, consider setting the DYLD_PRINT_LIBRARIES environment variable: dlopen(libfreetype6, 0x0001): tried: 'libfreetype6' (no such file), '/usr/local/lib/libfreetype6' (no such file), '/usr/lib/libfreetype6' (no such file), '/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/libfreetype6' (no such file)
at SharpFont.FT.FT_Init_FreeType(IntPtr& alibrary)
at SharpFont.Library..ctor()
at Microsoft.Xna.Framework.Content.Pipeline.Graphics.SharpFontImporter.Import(FontDescription options, String fontName) in /home/runner/work/MonoGame/MonoGame/MonoGame.Framework.Content.Pipeline/Graphics/Font/SharpFontImporter.cs:line 29
at Microsoft.Xna.Framework.Content.Pipeline.Processors.FontDescriptionProcessor.ImportFont(FontDescription options, Single& lineSpacing, Int32& yOffsetMin, ContentProcessorContext context, String fontName) in /home/runner/work/MonoGame/MonoGame/MonoGame.Framework.Content.Pipeline/Processors/FontDescriptionProcessor.cs:line 194
at Microsoft.Xna.Framework.Content.Pipeline.Processors.FontDescriptionProcessor.Process(FontDescription input, ContentProcessorContext context) in /home/runner/work/MonoGame/MonoGame/MonoGame.Framework.Content.Pipeline/Processors/FontDescriptionProcessor.cs:line 80
at Microsoft.Xna.Framework.Content.Pipeline.ContentProcessor`2.Microsoft.Xna.Framework.Content.Pipeline.IContentProcessor.Process(Object input, ContentProcessorContext context) in /home/runner/work/MonoGame/MonoGame/MonoGame.Framework.Content.Pipeline/ContentProcessor.cs:line 60
at MonoGame.Framework.Content.Pipeline.Builder.PipelineManager.ProcessContent(PipelineBuildEvent pipelineEvent) in /home/runner/work/MonoGame/MonoGame/MonoGame.Framework.Content.Pipeline/Builder/PipelineManager.cs:line 717
/Users/gacarr/.nuget/packages/monogame.content.builder.task/3.8.1.303/build/MonoGame.Content.Builder.Task.targets(142,5): error MSB3073: The command "dotnet mgcb /quiet /@:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/Content.mgcb" /platform:DesktopGL /outputDir:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/bin/DesktopGL/Content" /intermediateDir:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/obj/DesktopGL/net6.0/Content" /workingDir:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/"" exited with code 1.
Done building target "RunContentBuilder" in project "DesktopGLTest.csproj" -- FAILED.
Done building project "DesktopGLTest.csproj" -- FAILED.
Build FAILED.
/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/Score.spritefont : error : Processor 'FontDescriptionProcessor' had unexpected failure!
/Users/gacarr/.nuget/packages/monogame.content.builder.task/3.8.1.303/build/MonoGame.Content.Builder.Task.targets(142,5): error MSB3073: The command "dotnet mgcb /quiet /@:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/Content.mgcb" /platform:DesktopGL /outputDir:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/bin/DesktopGL/Content" /intermediateDir:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/obj/DesktopGL/net6.0/Content" /workingDir:"/Users/gacarr/Documents/game-dev/DesktopGLTest/Content/"" exited with code 1.
0 Warning(s)
2 Error(s)
Time Elapsed 00:00:00.59
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Build: 2 errors, 0 warnings
Is this an issue with my MonoGame installation? Am I missing a dependency? I am confused why such basic functions would be broken.
Here is an image of my sln. Is it missing something important?
Thank you! Unfortunately, I can’t seem to get any of the FreeImage installations to build. It seems they require an SDK for PPC and i386 but I can’t find either of those online. The repo I am pulling from can be found here.
When I run make I get this output:
/Library/Developer/CommandLineTools/usr/bin/make -f Makefile.osx
/Library/Developer/CommandLineTools/usr/bin/clang++ -Wno-ctor-dtor-privacy -D__ANSI__ -std=c++11 -stdlib=libc++ -Wc++11-narrowing -Os -fexceptions -fvisibility=hidden -DNO_LCMS -D__ANSI__ -arch x86_64 -I. -ISource -ISource/Metadata -ISource/FreeImageToolkit -ISource/LibJPEG -ISource/LibPNG -ISource/LibTIFF4 -ISource/ZLib -ISource/LibOpenJPEG -ISource/LibWebP -ISource/LibJXR -ISource/LibJXR/common/include -ISource/LibJXR/image/sys -ISource/LibJXR/jxrgluelib -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -mmacosx-version-min=10.11 -c Source/FreeImage/PluginTIFF.cpp -o Source/FreeImage/PluginTIFF.o-x86_64
Source/FreeImage/PluginTIFF.cpp:135:8: error: use of undeclared identifier 'half'
const half::uif half::_toFloat[1 << 16] =
^
Source/FreeImage/PluginTIFF.cpp:135:18: error: use of undeclared identifier 'half'
const half::uif half::_toFloat[1 << 16] =
^
Source/FreeImage/PluginTIFF.cpp:137:23: error: use of undeclared identifier 'half'
const unsigned short half::_eLut[1 << 9] =
^
Source/FreeImage/PluginTIFF.cpp:514:2: warning: 'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases [-Wauto-storage-class]
auto int e = (x.i >> 23) & 0x000001ff;
^~~~~
Source/FreeImage/PluginTIFF.cpp:525:6: warning: 'auto' storage class specifier is not permitted in C++11, and will not be supported in future releases [-Wauto-storage-class]
auto int m = x.i & 0x007fffff;
^~~~~
Source/FreeImage/PluginTIFF.cpp:1386:9: warning: enumeration value 'FIT_UNKNOWN' not handled in switch [-Wswitch]
switch(fit) {
^~~
Source/FreeImage/PluginTIFF.cpp:1386:9: note: add missing switch cases
switch(fit) {
^
3 warnings and 3 errors generated.
make[1]: *** [Source/FreeImage/PluginTIFF.o-x86_64] Error 1
make: *** [default] Error 2
And when I try to run make for FreeType (from gitlab) I get this error:
FreeType build system -- automatic system detection
The following settings are used:
platform unix
compiler cc
configuration directory ./builds/unix
configuration rules ./builds/unix/unix.mk
If this does not correspond to your system or settings please remove the file
`config.mk' from this directory then read the INSTALL file for help.
Otherwise, simply type `/Library/Developer/CommandLineTools/usr/bin/make' again to build the library,
or `/Library/Developer/CommandLineTools/usr/bin/make refdoc' to build the API reference (this needs Python >= 3.5).
Checking out submodule in `subprojects/dlg'
git submodule init
Submodule 'dlg' (https://github.com/nyorain/dlg.git) registered for path 'subprojects/dlg'
git submodule update
Cloning into '/Users/gacarr/repos/freetype/subprojects/dlg'...
Submodule path 'subprojects/dlg': checked out 'd142e646e263c89f93663e027c2f0d03739ab42d'
Copying files from `subprojects/dlg' to `src/dlg' and `include/dlg'
mkdir include/dlg
cp subprojects/dlg/include/dlg/output.h include/dlg
cp subprojects/dlg/include/dlg/dlg.h include/dlg
cp subprojects/dlg/src/dlg/dlg.c src/dlg
Generating modules list in ./objs/ftmodule.h...
done.
* module: truetype (Windows/Mac font files with extension *.ttf or *.ttc)
* module: type1 (Postscript font files with extension *.pfa or *.pfb)
* module: cff (OpenType fonts with extension *.otf)
* module: cid (Postscript CID-keyed fonts, no known extension)
* module: pfr (PFR/TrueDoc font files with extension *.pfr)
* module: type42 (Type 42 font files with no known extension)
* module: winfnt (Windows bitmap fonts with extension *.fnt or *.fon)
* module: pcf (pcf bitmap fonts)
* module: bdf (bdf bitmap fonts)
* module: sfnt (helper module for TrueType & OpenType formats)
* module: autofit (automatic hinting module)
* module: pshinter (Postscript hinter module)
* module: smooth (anti-aliased bitmap renderer)
* module: raster (monochrome bitmap renderer)
* module: ot-svg (OT-SVG glyph renderer module)
* module: sdf (signed distance field renderer)
* module: bsdf (bitmap to signed distance field converter)
* module: psaux (Postscript Type 1 & Type 2 helper module)
* module: psnames (Postscript & Unicode Glyph name handling)
cd builds/unix; \
./configure
/bin/sh: ./configure: No such file or directory
make: *** [setup] Error 127
Feel like I’m missing something fundamental since nothing seems to work? Any help is appreciated.
Eek, sorry! Totally forgot that FreeImage needs to be modified a bit to build properly ;p. So, there are a few steps you need to do, first off edit the follow files:
As a quick fix to get Monogame working on M1 do the following:
Install both the arm64 and the x64 SDKs of Dotnet SDK 6!
The arm64 version of the SDK is already installed with VS2022.
In Visual Studio 2022 in Preferences (Visual Studio->Preferences) under
SDK Locations → .Net Core change the path of the .NET Core Command Line to:
/usr/local/share/dotnet/x64/dotnet
Restart VS2022
After that you should be able to build your MonoGame project with an Apple M1.
As a side note: Installing the x64 SDK of dotnet 6 is enough to be able to run the MonoGame Content Builder Editor (using dotnet mgdb-editor inside your project), but you have to set the runtime which your game is built against explicitly to x64.
After that your are able to build, run and debug your game. Unfortunately only by using the x64 runtime instead of arm64. But once MonoGame runs fully (including building) on arm64 this is the way to go.
This should be added to the docs as new users might get confused with the proper setup on mac.
WOW that fixed it! Thank you so much! I was getting worried I had messed something up but that was an easy fix.
If someone could add this to the docs for Mac setup I bet this would help a lot of people; let me know if it’s something I could help with. I saw a handful of others online having issues with M1s but not a lot of answers.
And thank you Struggling Doge for your patient answers and awesome write-up on M1 as well, you provided one of the only resources I could find online about this stuff. Much love and hope you all have a nice rest of your day!
It took me a while to find this out. Even installing FreeImage via Homebrew brew install freeimage didn’t work at all.
I haven’t tested this with Visual Studio Code yet. I will post an update once I figured it out as well because it might be interesting.
@mrhelmut This might be helpful for others, so it should be added to the docs. See my post.
Yeah, the documentation is lacking to indicate how to change which SDK is used to workaround this issue.
I don’t think it is possible to bypass the version of freeimage used by MGCB by installing it system-wide manually.
The real fix would be to build freeimage with arm64+x64 binary and patch monogame itself so that MGCB can build stuff on M1/M2 natively. It’s not just freeimage, there’s a bunch of dependencies to rebuild and some of them aren’t open-source and don’t provide arm64 binaries.
Can you check which sdk is being used? If it’s the arm64 or x64 version? Despite VS2019 being x64 only I’m sure it is using the x64 dotnet sdk by default. And thats proven to work with Apple Silicon (M1 and M2 repectively).
But native arm64 building using MonoGame, atleast for the content pipeline is not possible as of missing dependencies compiled for arm64 stated by mrhelmut.
Made an account just to comment on this. Have the same errors as @groll did, but the fix from @StrugglingDoge didn’t work for me, as even after all the steps outlined, I’m getting build errors for Freeimage.
What worked for me was the solution @hecaex posted. Have you tried installing the x64 SDK of Dotnet 6 and setting that to the .NET Core Command Line like they described above? (it’s the post marked as solution, probably could have made that more clear in my original reply)