[Mono-dev] Building with Visual Studio 2005

Kornél Pál kornelpal at gmail.com
Mon Jul 10 07:21:01 EDT 2006


Hi,

I never tried to compile Mono with Visual Studio 2005 so I don't know what 
exactly is wrong but the problem is the following:

The GC (Garbage Collector) has to know about each thread in order to 
function. Under UNIX this requires to use custom thread functions that 
notify the GC.

Under Windows the problem is easier to solve because DllMain (DLL entry 
point function) gets notification when a thread was created so that the GC 
can be notified. But this requires to have a DLL that notifies the GC. 
Unfortunately there is no such notification for EXE images.

The solution is that mono.exe is only a stub that calls an entry point in 
mono-1.dll and everything else is done in mono-1.dll so that mono-1.dll 
receives thread creation notifications in its DllMain.

If mono.exe is compiled without having mono-1.dll or mono-1.dll entry point 
is not set to DllMain in win32_threads.c threads won't be registered with 
GC. If you supress such warings/errors the problem still won't be solved.

For more information see DLL_THREAD_ATTACH in
http://msdn.microsoft.com/library/en-us/dllproc/base/dllmain.asp
and see DllMain in
mono\libgc\win32_threads.c

Kornél

----- Original Message ----- 
From: "Janne Rantala" <janne.rantala at gmail.com>
To: <mono-devel-list at lists.ximian.com>
Sent: Monday, July 10, 2006 12:38 PM
Subject: Re: [Mono-dev] Building with Visual Studio 2005


> 2006/7/10, Rusmin Susanto <rusminsusanto at yahoo.com>:
>>
>> Hello.
>> I am trying to build Mono with Visual Studio 2005. I managed to build it.
>> However, when I run mono, I got the following error message:
>>
>> "Thread %p calling into managed code is not registered with the GC. On
>> UNIX, this can be fixed by #include-ing < gc.h> before <pthread.h> in the
>> file "
>>
>> After debugging, I found that the following function returns 0 because
>> both GC_DLL and GC_INSIDE_DLL are not defined. This function should 
>> return
>> 1.
>>
>> int GC_thread_is_registered (void)
>> {
>> #if defined(GC_DLL) || defined(GC_INSIDE_DLL)
>>  /* Registered by DllMain */
>>  return 1;
>> #else
>>  /* FIXME: */
>>  return 0;
>> #endif
>> }
>>
>>
>> I try to modify the code and guess where to define GC_DLL and
>> GC_INSIDE_DLL. But still no luck so far.
>>
>> Can someone tell me what's wrong? Where should I define GC_DLL and
>> GC_INSIDE_DLL ? Or what should I do?
>> Thanks.
>>
>>
>>
>> Rusmin
>>
>> ------------------------------
>> Yahoo! Music Unlimited - Access over 1 million songs. Try it 
>> free.<http://pa.yahoo.com/*http://us.rd.yahoo.com/evt=36035/*http://music.yahoo.com/unlimited/+%0A>
>>
>>
>> _______________________________________________
>> Mono-devel-list mailing list
>> Mono-devel-list at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>
>>
>>
>
> Hi!
>
> I used to get the same error. I've just commented those lines from
> threads.cand at least I've been able to run embedded samples without
> problems. This
> is what Sebastien Pouliot replied me at the time:
>
> "Yes, I'm unsure right now if it's a configuration problem (wrong define)
> or if some recent changes broke this.
>
> To run the sample I used the debugger to bypass the check (you could
> also comment the code). After that I didn't have any problem running the
> embed sample."
>
> So can't really say if it's good solution or not.
>
> Janne
>


--------------------------------------------------------------------------------


> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 




More information about the Mono-devel-list mailing list