Mono Pkg-Config.exe Keeps Crashing?

1.6k views Asked by At

I'm new to Mono - thought I'd give cross platform a try - my main IDE is Visual Studio and so the process of building applications through the command prompt is a bit foreign to me.

I was following the Mono Basics tutorial, and have gotten to the point where it says Winforms Hello World. I copied the code provided and saved it to a .cs file (on the Desktop).

I then opened up a command prompt and pointed it towards the Desktop directory. I ran the command:

mcs hello.cs -pkg:dotnet

And the result was: Pkg-Config.exe not working

The console told me that it was a CS8027 error but nothing else.

I have 3 environment variables that I added, with no fix:

  • PATH -> path to mono\bin
  • PATH -> path to mono\lib\pkgconfig
  • PKG_CONFIG_PATH -> path to mono\lib\pkgconfig

This happens whenever I try to use pkg-config.exe (tried to use pkg-config.exe --list-all but the same problem arose).

I've checked other answers/questions about the CS8027 error but the solutions did not help - it still crashes every time!

4

There are 4 answers

0
SolarisPol On

Had the same problem. I had all the proper VC++ runtimes installed, but still crashed.

pkg-config.exe references librares (.dll) that are compiled in different versions of .Net. Your PATH (or pkg-config itself) might be referencing a different version than the one the .dll uses, or not have it at all.

pkg-config is a short-hand anyway. I fixed it by explicitly including the .dll I'm referencing using the proper version of .Net for me:

mcs hello.cs -r:"C:\Program Files\Mono\lib\mono\4.5-api\System.Windows.Forms.dll"
0
besrml On

In my system the problem was the empty space inside the path of install and how that is managed inside of the pc files.

A workaround is to edit the pc files to change the prefix entry to the short path. In my system:

prefix=C:/PROGRA~1/Mono

instead of

prefix=${pcfiledir}/../..
0
directhex On

pkg-config is built with a different version of MSVC to Mono itself. You need the 32-bit VC++12 runtime installed for it to work. That ought to be included with mono.msi, as per https://github.com/mono/release/commit/8394dcc254510977c3e654abf916a48c6c6894fb

If you check the Windows event log, under Applications, you might get more information on what didn't work.

2
Mattias Jönsson On

I had this problem, could help some.

D:\Code\Mono>mcs hello.cs -pkg:dotnet
error CS8027: Error running pkg-config. Check the above output.

I needed to download the following DLL:s from https://www.dll-files.com/

  • libiconv-2.dll
  • libgcc_s_sjlj-1.dll
  • libintl-8.dll
  • libglib-2.0-0.dll

Put them in C:\Program Files\Mono\bin

All DLLs should be 32 bits even if Mono was 64 bits.