Can't generate mono glue on OSX

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Eric De Sedas
:warning: Old Version Published before Godot 3 was released.

Hello, I’ve been trying to manually compile the master branch for the Godot engine to directly generate an executable, but I’m having trouble when trying to generate an executable supporting the mono environment.

I have tried following the guide in the docs, but I can’t get pass the Generate the Glue part. Whenever I run the command:

$ scons p=osx tools=yes module_mono_enabled=yes mono_glue=no

I get the following output:

scons: Reading SConscript files ...
Package monosgen-2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `monosgen-2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'monosgen-2' found
OSError: 'pkg-config monosgen-2 --libs-only-L' exited 1:
  File "/Users/ericdesedas/Development/projects/godot/godot_source/SConstruct", line 398:
    config.configure(env)
  File "./modules/mono/config.py", line 162:
    tmpenv.ParseConfig('pkg-config monosgen-2 --libs-only-L')
  File "/usr/local/Cellar/scons/3.0.1/libexec/scons-local/SCons/Environment.py", line 1557:
    return function(self, self.backtick(command))
  File "/usr/local/Cellar/scons/3.0.1/libexec/scons-local/SCons/Environment.py", line 594:
    raise OSError("'%s' exited %d" % (command, status))

I tried following the error’s instructions about adding the PKG_CONFIG_PATH variable, but I still get the same error.

I have already checked the following possible issues:

  • I already have the latest mono version installed (5.4.1.6),
    which was installed via the official mac package (not using the
    brew version).
  • Already set the MONO_PATH env variable (pointing to
    /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5),
    just to make sure my installation was going to play nice with the
    editor. I can run the official beta build provided in the latest
    news update
    .
  • I defined the PKG_CONFIG_PATH env variable (pointing to
    /Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig),
    and I can confirm that the path contains the file monosgen-2.pc
    (the one the error is complaining about).
  • I can compile without mono doing the typical scons p=osx command.

Is there anything else I need to do so that I can compile the source code?

The issue was resolved for me by setting the PKG_CONFIG_PATH as so

export PKG_CONFIG_PATH=/Library/Frameworks/Mono.framework/Versions/5.4.1/lib/pkgconfig/

hasahmed | 2018-02-20 21:37

Cool, just came here from google and above exports fixed my problem

Brandon Lamb | 2018-07-08 02:30

:bust_in_silhouette: Reply From: Ben Beshara

Hi Eric,

I had the same issue and have just spent a good few hours trying to remedy it - I even reset my MacBook to see if it was something wrong with my setup. But I think I’ve found a solution.

It involves modifying the {godot dir}/modules/mono/config.py file by adding tmpenv = Environment(ENV = os.environ) right above tmpenv.ParseConfig('pkg-config monosgen-2 --libs-only-L'), which as far as I can tell is the point of failure, and using the following build script:

#!/bin/bash
clear
export PKG_CONFIG_PATH=/Library/Frameworks/Mono.framework/Versions/Current/lib/pkgconfig
echo "========Building GODOT without mono glue========"
python scons.py p=osx target=release_debug tools=yes module_mono_enabled=yes mono_glue=no
echo "========Generating mono glue========"
bin/godot.osx.opt.tools.64.mono --generate-mono-glue modules/mono/glue
echo "========Building Godot with Mono========"
python scons.py p=osx target=release_debug tools=yes module_mono_enabled=yes
echo "========Copying App Bundle========"
cp -r ./misc/dist/osx_tools.app ./bin/godot.app
echo "========Copying executable to App Bundle========"
mkdir ./bin/godot.app/Contents/MacOS/
cp ./bin/godot.osx.opt.tools.64.mono ./bin/godot.app/Contents/MacOS/Godot
echo "Done!"

(I’m using scons-local placed in the godot directory created by git, hence the python scons.py - if you’re using the global version of scons replace this with just scons)

I hope this helps!

this worked for me too, thanks! have you thought of submitting a pull request on github?

Jorge Nonell | 2018-01-18 07:44