[Mono-dev] mono_config_parse won't link, needs extern "C" declaration in header file
Sebastian Good
sebastian at palladiumconsulting.com
Tue Apr 1 16:51:52 EDT 2008
I am compiling an application against the Mono embedding API, version 1.2.6.
All is wonderful, except I cannot link successfully when I try to compile
against mono_config_parse(const char*). The mono.lib which was nicely
supplied to me on this mailing list some months ago claims that the function
is exported by mono.dll. Running dumpbin /exports mono.dll also shows
mono_config_parse as an entry point in the DLL, yet I get the following
error from MSVC
error LNK2019: unresolved external symbol "void __cdecl
mono_config_parse(char const *)" (?mono_config_parse@@YAXPBD at Z) referenced
in function "public: __thiscall MonoEmbed::MonoEmbed(class
std::basic_string<char,struct std::char_traits<char>,class
std::allocator<char> >)" (??0MonoEmbed@@QAE at V?$basic_string@
DU?$char_traits at D@std@@V?$allocator at D@2@@std@@@Z)
I believe this is because the relevant declarations are not marked extern
"C". Doing so (by adding G_BEGIN_DECLS and G_END_DECLS to
<mono/metadata/mono-config.h>) makes the link on Windows successful. It
still fails under Linux (see below).
However actually executing mono_config_parse(NULL) blows the executable out
of the water, when executing under Windows. The call is
mono_set_dirs((monoPath + "/lib").c_str(), (monoPath + "/etc").c_str());
mono_config_parse(NULL);
and the exception/stacktrace is
Unhandled exception at 0x7c918fea in DataAccessCApiTest.exe: 0xC0000005:
Access violation writing location 0x00000010
ntdll.dll!7c918fea()
[Frames below may be incorrect and/or missing, no symbols loaded for
ntdll.dll]
ntdll.dll!7c9106eb()
msvcrt.dll!77c2c3c9()
msvcrt.dll!77c2c3ce()
msvcrt.dll!77c2c3ce()
msvcrt.dll!77c2c3e7()
ntdll.dll!7c90104b()
mono.dll!68fb5692()
mono.dll!68fb5879()
mono.dll!68fb3ee2()
libglib-2.0-0.dll!672e1474()
libglib-2.0-0.dll!672e290f()
ntdll.dll!7c9106eb()
msvcrt.dll!77c2c3c9()
msvcrt.dll!77c2c3ce()
msvcrt.dll!77c2c42e()
libglib-2.0-0.dll!672e4179()
libglib-2.0-0.dll!672d2437()
libglib-2.0-0.dll!672e04de()
mono.dll!68fb4113()
msvcrt.dll!77c36d37()
libglib-2.0-0.dll!672d00b0()
mono.dll!68fb4230()
mono.dll!68fb42ae()
mono.dll!68fb4404()
So of course this means re-building Mono. Once that's done, everything
works.
There are a raft of problems with the embedding APIs that require many
manual changes to get them to work. Have these been fixed in newer code
drops? Specifically, there are edits to threads.h and of course the above.
Many thanks -- I hope this is helpful.
- Sebastian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20080401/7ee0919a/attachment-0001.html
More information about the Mono-devel-list
mailing list