[Mono-dev] mono_config_parse (was: Embedding mono on windows: the missing (lib)mono.llib)

Sebastian Good sebastian at palladiumconsulting.com
Tue Aug 21 18:23:31 EDT 2007


> Date: Tue, 21 Aug 2007 10:30:43 +0200
> From: Robert Jordan <robertj at gmx.net>
> Subject: Re: [Mono-dev] Embedding mono on windows: the missing
> 	(lib)mono.lib
> Hi,
>
> Sebastian Good wrote:
>   
>> > I am attempting to embed a mono runtime in my C++ application. I'm using 
>> > the standard 1.4.2 mono install (on WinXP) & Visual Studio 2005. I've 
>> > generated the expected C++ compiler flags using
>> > 
>> >    pkg-config --msvc-syntax --cflags --libs mono
>> > 
>> > And while my simple hello-world embedding application now compiles 
>> > nicely, it fails to link with
>> > 
>> >    LNK1104: cannot open file 'mono.lib'
>> > 
>> > I can confirm my install has no 'mono.lib', or even 'libmono.lib'. A 
>> > search of this list and other sites suggests this is not all that 
>> > uncommon. People seem to be trying to build mono using Cygwin in order 
>> > to recreate the missing mono.lib (and sometimes running into other 
>> > problems doing that). Am I being a knucklehead or is the standard mono 
>> > Windows install missing this library? Is there an alternative to 
>> > building mono myself? Should I be more interested in the '*.a' files 
>> > sitting in my /lib directory?
>>     
>
> Quick workaround:
>
> mono.def (see attachment) is built during the cygwin
> build process. From this file, you can generate mono.lib
> using MSVC's lib tool:
>
> lib /nologo /machine:x86 /def:mono.def /out:mono.lib
>
> Because the embedded API is stable, i.e. doesn't change often,
> you can use the lib with several Mono versions.
>
> Robert
> -------------- next part --------------
> An embedded and charset-unspecified text was scrubbed...
> Name: mono.def
> Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070821/e11fb03c/attachment.pl 
>   
Thanks very much Robert, this certainly did the trick. All is now linkin 
and even running but failing to find mscorlib, which suggests to me it 
is time to call mono_config_parse. A couple of notes. The samples at 
http://www.mono-project.com/Embedding_Mono do not have the proper 
#include directive, which appears to be

    #include <mono/metadata/mono-config.h>

This gets us access to void mono_config_parse(const char *filename), 
though we then fail to link again, with

    error LNK2001: unresolved external symbol "void __cdecl 
mono_config_parse(char const *)"

The .c and .h and Makefiles, as well as the defs file you sent I all 
seem to agree that mono-config.c is linked into mono.dll -- indeed the 
mono_config_parse function is even listed as an entry point in the 
mono.dll I included. I have to say I don't understand why it won't link.

I have tried working around this by setting various environment 
variables (e.g. MONO_PATH, MONO_CFG_DIR, etc.) but all result in the 
runtime error of

    The assembly mscorlib.dll was not found or could not be loaded. It 
should have been installed in the 
'c:\dev\ndi\InteropMonoEmbed\lib\mono\1.0\mscorlib.dll' directory.

It just seems to be looking for a lib relative to the path in which it 
executes. I would be grateful for any hints on how to either 
successfully link to the mono_config_parse (assuming this enables mono 
to find its assemblies) or some way of pointing mono at its own 
assemblies. Many thanks again.

- Sebastian



-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3301 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070821/b1ec432f/attachment.bin 


More information about the Mono-devel-list mailing list