C loader of .NET runtime (mscoree.h include errors)

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

C loader of .NET runtime (mscoree.h include errors)

Lloyd Dupont-2
I'm trying to compile with GCC a very simple .NET loader.
(I'm using SDK.NET 2.0 beta 2)
the code is attached...
 
Anyway there is an include of <mscoree.h>
it produces plenty of error kind of:
../mscoree.h:487: error: syntax error before numeric constant
../mscoree.h:487: warning: data definition has no type or storage class
 
At line 487 there is something like that:
EXTERN_GUID(LIBID_mscoree, 0x5477469e,0x83b1,0x11d2,0x8b,0x49,0x00,0xa0,0xc9,0xb7,0xc9,0xc4);
 
Which means nothing to me...
Any idea about what the error could be?
 
---------------------------------------
PS: good on you earnie, you'll find that .NET is a great and productive environment!
try out 2.0, it's even better
 
You could also try C# express (from MS), it will cost (the final release) no more than 50$, and you should try VS.NET2005, the beta is free, so you will see if it's worth it!
 
You should also try mono (http://www.mono-project.com)

simple_loader.c (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: C loader of .NET runtime (mscoree.h include errors)

Mark Junker
Lloyd Dupont schrieb:

> I'm trying to compile with GCC a very simple .NET loader.
> (I'm using SDK.NET 2.0 beta 2)
> the code is attached...
>  
> Anyway there is an include of <mscoree.h>
> it produces plenty of error kind of:
> ../mscoree.h:487: error: syntax error before numeric constant
> ../mscoree.h:487: warning: data definition has no type or storage class
>  
> At line 487 there is something like that:
> EXTERN_GUID(LIBID_mscoree,
> 0x5477469e,0x83b1,0x11d2,0x8b,0x49,0x00,0xa0,0xc9,0xb7,0xc9,0xc4);
>  
> Which means nothing to me...
> Any idea about what the error could be?

1. Try using the Platform SDK headers. The EXTERN_GUID macro is defined
in RpcNdr.h as:

#if _MSC_VER >= 1100
#define EXTERN_GUID(itf,l1,s1,s2,c1,c2,c3,c4,c5,c6,c7,c8)  \
  EXTERN_C const IID DECLSPEC_SELECTANY itf =
{l1,s1,s2,{c1,c2,c3,c4,c5,c6,c7,c8}}
#else
#define EXTERN_GUID(itf,l1,s1,s2,c1,c2,c3,c4,c5,c6,c7,c8) EXTERN_C const
IID itf
#endif

2. It might help to define INITGUID before you include all windows headers

It might help because you have to define the GUIDs in you application
because you cannot use Microsofts GUID libraries.

Regards,
Mark



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: C loader of .NET runtime (mscoree.h include errors)

Lloyd Dupont-2
Hey.. tricky!
this #define is missing in <mingw>/include/rpcndr.h but it's in the
<Platform SDK>/include/RpcNdr.h

mhh....
going to link erro now.. thanks!
and good german summer day (from Aussie winter evening) ;)

----- Original Message -----
From: "Mark Junker" <[hidden email]>
To: <[hidden email]>
Sent: Monday, June 20, 2005 3:56 PM
Subject: Re: [Mingw-users] C loader of .NET runtime (mscoree.h include
errors)


> Lloyd Dupont schrieb:
>
>> I'm trying to compile with GCC a very simple .NET loader.
>> (I'm using SDK.NET 2.0 beta 2)
>> the code is attached...
>>  Anyway there is an include of <mscoree.h>
>> it produces plenty of error kind of:
>> ../mscoree.h:487: error: syntax error before numeric constant
>> ../mscoree.h:487: warning: data definition has no type or storage class
>>  At line 487 there is something like that:
>> EXTERN_GUID(LIBID_mscoree,
>> 0x5477469e,0x83b1,0x11d2,0x8b,0x49,0x00,0xa0,0xc9,0xb7,0xc9,0xc4);
>>  Which means nothing to me...
>> Any idea about what the error could be?
>
> 1. Try using the Platform SDK headers. The EXTERN_GUID macro is defined in
> RpcNdr.h as:
>
> #if _MSC_VER >= 1100
> #define EXTERN_GUID(itf,l1,s1,s2,c1,c2,c3,c4,c5,c6,c7,c8)  \
>  EXTERN_C const IID DECLSPEC_SELECTANY itf =
> {l1,s1,s2,{c1,c2,c3,c4,c5,c6,c7,c8}}
> #else
> #define EXTERN_GUID(itf,l1,s1,s2,c1,c2,c3,c4,c5,c6,c7,c8) EXTERN_C const
> IID itf
> #endif
>
> 2. It might help to define INITGUID before you include all windows headers
>
> It might help because you have to define the GUIDs in you application
> because you cannot use Microsofts GUID libraries.
>
> Regards,
> Mark
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> _______________________________________________
> MinGW-users mailing list
> [hidden email]
>
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users 



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: C loader of .NET runtime (mscoree.h include errors)

Lloyd Dupont-2
I have made some progress.
There might still be a few syntax error (I'm not sure what is a LPCWSTR)
but there are link errors!

I don't understand these ones:
.../ccwhcaaa.o(.text+0x3c):simple_loader.c: undefined reference to
`FormatMessageA@28'
.../libgcc.a(w32-shared-ptr.o)(.text+0x31): undefined reference to
`_imp__GetAtomNameA@12'
.../libgcc.a(w32-shared-ptr.o)(.text+0x159): undefined reference to
`_imp__FindAtomA@4'

I did compile with this command line:
gcc -o sloader.exe simple_loader.c -I"C:/Program
Files/Microsoft.NET/SDK/v2.0/include" -L"c:/windows/system32" -lkernel32 -lmscoree

and, as you could see, I have linked against "Kernel32", which contains
definition for FormatMessage, GetAtomName, etc...

So how come I have these errors ?

Also I linked directly against mscoree.dll and I'm not sure it will work...
any tip on what I should do if it doesn't? or maybe it alwasy does?


----- Original Message -----
From: "Lloyd Dupont" <[hidden email]>
To: <[hidden email]>
Sent: Monday, June 20, 2005 4:10 PM
Subject: Re: [Mingw-users] C loader of .NET runtime (mscoree.h include
errors)


> Hey.. tricky!
> this #define is missing in <mingw>/include/rpcndr.h but it's in the
> <Platform SDK>/include/RpcNdr.h
>
> mhh....
> going to link erro now.. thanks!
> and good german summer day (from Aussie winter evening) ;)
>
> ----- Original Message -----
> From: "Mark Junker" <[hidden email]>
> To: <[hidden email]>
> Sent: Monday, June 20, 2005 3:56 PM
> Subject: Re: [Mingw-users] C loader of .NET runtime (mscoree.h include
> errors)
>
>
>> Lloyd Dupont schrieb:
>>
>>> I'm trying to compile with GCC a very simple .NET loader.
>>> (I'm using SDK.NET 2.0 beta 2)
>>> the code is attached...
>>>  Anyway there is an include of <mscoree.h>
>>> it produces plenty of error kind of:
>>> ../mscoree.h:487: error: syntax error before numeric constant
>>> ../mscoree.h:487: warning: data definition has no type or storage class
>>>  At line 487 there is something like that:
>>> EXTERN_GUID(LIBID_mscoree,
>>> 0x5477469e,0x83b1,0x11d2,0x8b,0x49,0x00,0xa0,0xc9,0xb7,0xc9,0xc4);
>>>  Which means nothing to me...
>>> Any idea about what the error could be?
>>
>> 1. Try using the Platform SDK headers. The EXTERN_GUID macro is defined
>> in RpcNdr.h as:
>>
>> #if _MSC_VER >= 1100
>> #define EXTERN_GUID(itf,l1,s1,s2,c1,c2,c3,c4,c5,c6,c7,c8)  \
>>  EXTERN_C const IID DECLSPEC_SELECTANY itf =
>> {l1,s1,s2,{c1,c2,c3,c4,c5,c6,c7,c8}}
>> #else
>> #define EXTERN_GUID(itf,l1,s1,s2,c1,c2,c3,c4,c5,c6,c7,c8) EXTERN_C const
>> IID itf
>> #endif
>>
>> 2. It might help to define INITGUID before you include all windows
>> headers
>>
>> It might help because you have to define the GUIDs in you application
>> because you cannot use Microsofts GUID libraries.
>>
>> Regards,
>> Mark
>>
>>
>>
>> -------------------------------------------------------
>> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
>> from IBM. Find simple to follow Roadmaps, straightforward articles,
>> informative Webcasts and more! Get everything you need to get up to
>> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
>> _______________________________________________
>> MinGW-users mailing list
>> [hidden email]
>>
>> You may change your MinGW Account Options or unsubscribe at:
>> https://lists.sourceforge.net/lists/listinfo/mingw-users
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> _______________________________________________
> MinGW-users mailing list
> [hidden email]
>
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users 

simple_loader.c (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: C loader of .NET runtime (mscoree.h include errors)

Mark Junker
Lloyd Dupont schrieb:

> I did compile with this command line:
> gcc -o sloader.exe simple_loader.c -I"C:/Program
> Files/Microsoft.NET/SDK/v2.0/include" -L"c:/windows/system32"
> -lkernel32 -lmscoree

Change the order of the "-l" switches to -lmscoree -lkernel32
The gcc linker is quite picky about the library order.

Regards,
Mark



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: C loader of .NET runtime (mscoree.h include errors)

Lloyd Dupont-2
I already unsuccessfully tried! (or even puting them 1st)
I also have a really weird error:
d000010.o(.text+0x0): multiple definition of `_onexit'
/mingw/lib/crt2.o(.text+0x270):crt1.c: first defined here
d000013.o(.text+0x0): multiple definition of `atexit'
/mingw/lib/crt2.o(.text+0x260):crt1.c: first defined here

multiple definition of a symbol?!



Also I make this WideChar conversion method is it alright? does it exsit in
the API?
static WCHAR buf[256];
static WCHAR* MakeWString(char* narrow)
{
 WCHAR* tmp = buf;
 while(*tmp = *narrow)
 {
  tmp ++;
  narrow ++;
 }
 return buf;
}


----- Original Message -----
From: "Mark Junker" <[hidden email]>
To: <[hidden email]>
Sent: Monday, June 20, 2005 4:55 PM
Subject: Re: [Mingw-users] C loader of .NET runtime (mscoree.h include
errors)


> Lloyd Dupont schrieb:
>
>> I did compile with this command line:
>> gcc -o sloader.exe simple_loader.c -I"C:/Program
>> Files/Microsoft.NET/SDK/v2.0/include" -L"c:/windows/system32" -lkernel32  
>> -lmscoree
>
> Change the order of the "-l" switches to -lmscoree -lkernel32
> The gcc linker is quite picky about the library order.
>
> Regards,
> Mark
>
>
>
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
> _______________________________________________
> MinGW-users mailing list
> [hidden email]
>
> You may change your MinGW Account Options or unsubscribe at:
> https://lists.sourceforge.net/lists/listinfo/mingw-users 



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: C loader of .NET runtime (mscoree.h include errors)

Mark Junker
Lloyd Dupont schrieb:

> I already unsuccessfully tried! (or even puting them 1st)

Umm ... you have to specify the libraries at the end of the command line
but the "-lkernel32" should be the last library specified ...

> I also have a really weird error:
> d000010.o(.text+0x0): multiple definition of `_onexit'
> /mingw/lib/crt2.o(.text+0x270):crt1.c: first defined here
> d000013.o(.text+0x0): multiple definition of `atexit'
> /mingw/lib/crt2.o(.text+0x260):crt1.c: first defined here
>
> multiple definition of a symbol?!

This "d00*.o" stuff comes from an import library but I don't have a clue
which one it is ...

Here a few infos about your link command line:

> gcc -o sloader.exe simple_loader.c -I"C:/Program
> Files/Microsoft.NET/SDK/v2.0/include" -L"c:/windows/system32"
> -lkernel32 -lmscoree

It should be something like

gcc -o sloader.exe simple_loader.c -I"C:/Program
Files/Microsoft.NET/SDK/v2.0/include" -lmscoree -lkernel32

1. Don't specify C:\Windows\System32 as library path
2. Where do you have the "libmscoree" from?

When the mscoree is created by using pexports and dlltool, you have to
do some work before you can really use it.
GCC appends a @n to all STDCALL function names but these names are
stored without the @n in the DLL. The output of pexports (the DEF file)
must therefore be reworked. You have to take a look at the number and
size of the arguments for every function you use and add a @n (n is a
multiple of 4). Then you have to (too bad - I know) run this created DEF
file through dlltool with the following arguments:

dlltool --dllname mscoree.dll --def your_created_def_file.def
--output-lib libmscoree.a -k

This lib*.a file is now usable with GCC.

You might say that both GCC and M$ use the COFF/AR format for their
object files and archives but I have to disappoint you that M$ made some
proprietary changes and are therefore incompatible.

> Also I make this WideChar conversion method is it alright? does it
> exsit in the API?
> static WCHAR buf[256];

[..]

> }


Sorry, this is not right ... you should use iconv for character set
conversions or use the C (mbtowc & others) or Windows API
(MultiByteToWideChar & others).

Regards,
Mark



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: C loader of .NET runtime (mscoree.h include errors)

Earnie Boyd
In reply to this post by Lloyd Dupont-2
On 5:26:25 am 2005-06-20 "Lloyd Dupont" <[hidden email]> wrote:

> I'm trying to compile with GCC a very simple .NET loader.
> (I'm using SDK.NET 2.0 beta 2)
> the code is attached...
>
> Anyway there is an include of <mscoree.h>
> it produces plenty of error kind of:
> ../mscoree.h:487: error: syntax error before numeric constant
> ../mscoree.h:487: warning: data definition has no type or storage
> class
>

Are you using GCC or G++?


> At line 487 there is something like that:
> EXTERN_GUID(LIBID_mscoree, 0x5477469e,0x83b1,0x11d2,0x8b,0x49,0x00,0xa
> 0,0xc9,0xb7,0xc9,0xc4);
>
> Which means nothing to me...
> Any idea about what the error could be?
>
> ---------------------------------------
> PS: good on you earnie, you'll find that .NET is a great and
> productive environment! try out 2.0, it's even better
>

Actually csc is installed in the .NET Framework folder.  SharpDevelop finds
it and uses it.

> You could also try C# express (from MS), it will cost (the final
> release) no more than 50$, and you should try VS.NET2005, the beta is
> free, so you will see if it's worth it!
>

I'm not ready for the beta yet.

> You should also try mono (http://www.mono-project.com)

I have it installed.  But if csc comes with the computer why bother when
I'm not using a Linux environment?  The SDK is a free download.

Earnie



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: C loader of .NET runtime (mscoree.h include errors)

Lloyd Dupont-2
In reply to this post by Mark Junker
thanks mark for all the tips..
well I get a bit frustrated with all the work involved for my bug work
around.

finally I gave a go to managed C++
works much better! will go this way, I think...

PS: for mscoree, I was just tryng to link directly against the dll, it used
to work so I din't bother using dllwrap & such tool...



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
_______________________________________________
MinGW-users mailing list
[hidden email]

You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users