Compiling with /clr:safe?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Compiling with /clr:safe?

Postby Bloody_Grunt » Fri Sep 17, 2010 2:45 pm

Hi, what's the probability of being able to compile Newton with /clr:safe on? Compiling with this option means that the generated assembly is a completely managed one, no different from an assembly produced in C# or VB.net. If a managed assembly was provided, it would enable Indie developers to use Newton on platforms such as the Xbox or on Mono in .Net applications.

A couple of links explaining the how of migrating
http://msdn.microsoft.com/en-us/library ... 80%29.aspx
http://msdn.microsoft.com/en-us/library ... 80%29.aspx
http://msdn.microsoft.com/en-us/library ... 80%29.aspx

Forgive my noobiness if this can't or won't be done, I'm not a C++ developer.

Edit: looking into it only clr:safe will run on mono http://www.mono-project.com/CPlusPlus
Original: Asking about compiling to clr:pure
Bloody_Grunt
 
Posts: 4
Joined: Fri Sep 17, 2010 2:36 pm

Re: Compiling with /clr:safe?

Postby Julio Jerez » Fri Sep 17, 2010 5:10 pm

Bloody_Grunt wrote:If a managed assembly was provided, it would enable Indie developers to use Newton on platforms such as the Xbox or on Mono in .Net applications.

how can a project compiled for and x86 arch be run on a motorola power PC arch?
I do not that clr option can make Newton can be run on xbox consoles, it is a matter of licence an legal issuesm, it is not about tecnology.
you are probably thinks Netwon is writen in c# which it is not, it is C++.

or and I all wrong, and teh CLR option generate jus in time compile code?
Is that is the case I migh even buy a xb0x to try out. I woudl love to see newton running on an xBox360.


I did not read the whole article, but teh first paragrha do no say anythomng abput genrating code with CIL only,
hwo to do that? has you tested that it is possibel to make code tah will work on oteh platform
The CLI is able to host C++ compiled code on all supported platforms as long as the compiled code only contains CIL instructions and not a mix of CIL and native code. Microsoft Managed C++ and C++/CLI compilers produce mixed-mode assemblies by default.

Mixed-mode assemblies are experimentally supported only on Windows because native code is platform specific. With the help of Wine (http://www.winehq.org/) mixed-mode assemblies can be used on other platforms by the Windows version of Mono.


Newton is a very pain vanilla c++ app the compile with zero changes on many platform, so tha shoudl be possible. But I have being burned before.
what is Mono?
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Compiling with /clr:safe?

Postby ledahut » Fri Sep 17, 2010 5:25 pm

Julio Jerez wrote:what is Mono?


As say on the main page:
An open source, cross-platform, implementation of C# and the CLR that is binary compatible with Microsoft.NET


If fact mono is a .net clone, it can compile C# source code, and can run .net binary programs [even under linux].
ledahut
 
Posts: 98
Joined: Mon Jun 21, 2010 8:03 am
Location: France

Re: Compiling with /clr:safe?

Postby Julio Jerez » Fri Sep 17, 2010 5:36 pm

that's what I thought.
Newton is not open source, and it is not c#, so CLR will not do anythong at all.

Microsoft not letting VS compile C++ code to CIL is an arbitraty decition that has nothing to do with technological barriers, and everything to do with busseness.
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Compiling with /clr:safe?

Postby Bloody_Grunt » Fri Sep 17, 2010 5:43 pm

how can a project compiled for and x86 arch be run on a motorola power PC arch?
I do not that clr option can make Newton can be run on xbox consoles, it is a matter of licence an legal issuesm, it is not about tecnology.
you are probably thinks Netwon is writen in c# which it is not, it is C++.

C# and VB.Net do not compile to machine code like C++ does. It compiles to what is called IL (intermediate language). It's using the same concept that Java uses to be able to run on different architecture. You write Java code, and compile to an intermediate language (Java bytecode in this example), then a translator (called a JVM converts it machine code on the fly). Compiling with clr:safe on produces IL code, which can then be translated by .Net or Mono (Microsoft/Novell's version of a JVM for C#)

The CLI is able to host C++ compiled code on all supported platforms as long as the compiled code only contains CIL instructions and not a mix of CIL and native code. Microsoft Managed C++ and C++/CLI compilers produce mixed-mode assemblies by default.

Mixed-mode assemblies are experimentally supported only on Windows because native code is platform specific. With the help of Wine (http://www.winehq.org/) mixed-mode assemblies can be used on other platforms by the Windows version of Mono.

Sorry, it does look Mono themselves are writing off the idea, but further in the article in reads:
If you don't use CRT at all you can use it under Mono.

Using /clr:safe you cannot use CRT so it will run under Mono. Note that /clr:safe uses a more strict syntax than /clr:pure so it may be better to use /clr:pure.
Bloody_Grunt
 
Posts: 4
Joined: Fri Sep 17, 2010 2:36 pm

Re: Compiling with /clr:safe?

Postby Julio Jerez » Fri Sep 17, 2010 6:23 pm

So if I compile with the clr option, and do ann the fixes to make compile,
are you saying that the code generated will work on a Linux Box running teh Mono thing, for example, even of the code was writen in C++?
if this is true those that mean I will run on Mac, and XBox 360 too?

My impresion is the I will have to write the entire engine in C# for that, and I will not do that.
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Compiling with /clr:safe?

Postby thedmd » Fri Sep 17, 2010 7:26 pm

Personally I do not know any compiler able to compile C++ into pure CLR. Microsoft introduced C++/CLR as a bridge between native and managed code, but it require to use special syntax, managed memory and so on.
Even if Newton will compile I think it will suffer greatly in performance. There is no access to any vector unit.

Sorry for not being optimistic.
thedmd
 

Re: Compiling with /clr:safe?

Postby Bloody_Grunt » Fri Sep 17, 2010 11:06 pm

Julio Jerez wrote:So if I compile with the clr option, and do ann the fixes to make compile,
are you saying that the code generated will work on a Linux Box running teh Mono thing, for example, even of the code was writen in C++?
if this is true those that mean I will run on Mac, and XBox 360 too?

My impresion is the I will have to write the entire engine in C# for that, and I will not do that.


You would not have to rewrite in C#, behind the scenes, the .dll written in C++, but compiled clr:safe on, would looks identical to one created in C# (it would decompile into IL). Mono can run such .dll's on a host of operating systems. Linux including. The reason I mentioned Xbox 360, is because Microsoft themselves have allowed indie developers to run C# on the 360. If you're an actual developer and can afford the Xbox Development Kit (XDK), that you'd be able to use Newton fine in it's current C++ form.

It'd be difficult because you have to replace CRT routines with a .Net equivalent. this page provides what macros would have to be replaced, as well as what they are to be replaced with.
Then this page lists of a couple of setting that must be changed before compiling.
Bloody_Grunt
 
Posts: 4
Joined: Fri Sep 17, 2010 2:36 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 131 guests