473,395 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Binary portability of C++/CLI code

I compiled the hello world program, as specified in the current C++/CLI
draft (version 1.5), by using Visual C++ 2005 Express Beta 1:
int main()
{
System::Console::WriteLine("Hello World");
}
C:\c>cl /clr:safe temp.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 14.00.40607.16
for Microsoft (R) .NET Framework version 2.00.40607.16
Copyright (C) Microsoft Corporation. All rights reserved.

temp.cpp
Microsoft (R) Incremental Linker Version 8.00.40607.16
Copyright (C) Microsoft Corporation. All rights reserved.

/out:temp.exe
temp.obj
==> The /clr:safe only produces an executable that passes peverify:

C:\c>peverify temp.exe /verbose

Microsoft (R) .NET Framework PE Verifier. Version 2.0.40607.16
Copyright (C) Microsoft Corporation. All rights reserved.

All Classes and Methods in temp.exe Verified.

C:\c>


Then wanting to test the binary portability of the produced executable,
I tried to run the produced executable as it is, in another CLI machine:

root@chrome cdrom]# mono temp.exe

** (temp.exe:1416): WARNING **: Could not find assembly
Microsoft.VisualC, references from /mnt/cdrom/temp.exe (assemblyref_index=1)
Major/Minor: 8,0
Build: 1200,0
Token: b03f5f7f11d50a3a

cannot open assembly temp.exe
[root@chrome cdrom]#


As it seems, MS introduces platform dependencies on the produced
executables, even for pure C++/CLI code.
How can I remove that useless assembly reference to "Microsoft.VisualC"?


Best regards,

Ioannis Vranos
Nov 17 '05 #1
9 1709
Mono is miles behind what you see in VS2005 which is based on CLR version
2.0.
Your program won't run on .NET v1.0 and 1.1 either, it needs v2.0

Willy.

"Ioannis Vranos" <iv*@guesswh.at.grad.com> wrote in message
news:eE**************@TK2MSFTNGP12.phx.gbl...
I compiled the hello world program, as specified in the current C++/CLI
draft (version 1.5), by using Visual C++ 2005 Express Beta 1:
int main()
{
System::Console::WriteLine("Hello World");
}
C:\c>cl /clr:safe temp.cpp
Microsoft (R) C/C++ Optimizing Compiler Version 14.00.40607.16
for Microsoft (R) .NET Framework version 2.00.40607.16
Copyright (C) Microsoft Corporation. All rights reserved.

temp.cpp
Microsoft (R) Incremental Linker Version 8.00.40607.16
Copyright (C) Microsoft Corporation. All rights reserved.

/out:temp.exe
temp.obj
==> The /clr:safe only produces an executable that passes peverify:

C:\c>peverify temp.exe /verbose

Microsoft (R) .NET Framework PE Verifier. Version 2.0.40607.16
Copyright (C) Microsoft Corporation. All rights reserved.

All Classes and Methods in temp.exe Verified.

C:\c>


Then wanting to test the binary portability of the produced executable, I
tried to run the produced executable as it is, in another CLI machine:

root@chrome cdrom]# mono temp.exe

** (temp.exe:1416): WARNING **: Could not find assembly Microsoft.VisualC,
references from /mnt/cdrom/temp.exe (assemblyref_index=1)
Major/Minor: 8,0
Build: 1200,0
Token: b03f5f7f11d50a3a

cannot open assembly temp.exe
[root@chrome cdrom]#


As it seems, MS introduces platform dependencies on the produced
executables, even for pure C++/CLI code.
How can I remove that useless assembly reference to "Microsoft.VisualC"?


Best regards,

Ioannis Vranos

Nov 17 '05 #2
Ioannis Vranos wrote:
How can I remove that useless assembly reference to "Microsoft.VisualC"?


This is currently a bug in the Visual C++ compiler. We moved a number of
types from Microsoft.VisualC.dll into the frameworks assemblies (like
mscorlib.dll). Those types will need to be introduced on Mono to work, which
should be trivial.

The simple hello world example shouldn't need any changes to Mono... it's
just a bug in the VC compiler right now.

--
Brandon Bray, Visual C++ Compiler http://blogs.msdn.com/branbray/
This posting is provided AS IS with no warranties, and confers no rights.
Nov 17 '05 #3
Brandon,

Are you sure about this, my understanding is that assemblies built with
VS2005 Beta1 (and later) could only run on a CLR v2.0 due to changes in the
metadata.
Is this only true for .NET and does'nt Mono check the CLR version required
when loading a managed assembly?
Am I missing something?

Willy.

"Brandon Bray [MSFT]" <br******@online.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Ioannis Vranos wrote:
How can I remove that useless assembly reference to "Microsoft.VisualC"?


This is currently a bug in the Visual C++ compiler. We moved a number of
types from Microsoft.VisualC.dll into the frameworks assemblies (like
mscorlib.dll). Those types will need to be introduced on Mono to work,
which
should be trivial.

The simple hello world example shouldn't need any changes to Mono... it's
just a bug in the VC compiler right now.

--
Brandon Bray, Visual C++ Compiler http://blogs.msdn.com/branbray/
This posting is provided AS IS with no warranties, and confers no rights.

Nov 17 '05 #4
Willy Denoyette [MVP] wrote:
Brandon,

Are you sure about this, my understanding is that assemblies built with
VS2005 Beta1 (and later) could only run on a CLR v2.0 due to changes in the
metadata.
Is this only true for .NET and does'nt Mono check the CLR version required
when loading a managed assembly?
Am I missing something?

I have successfully ran the C++/CLI hello world program produced by VC++
2005 Express Beta 1 under Mono 1, by including the Microsoft.VisualC.Dll
of .net 2 technical preview along with the exe(!).

However I prefer a more elegant approach.

[root@chrome cdrom]# ls
Microsoft.VisualC.Dll temp.exe temp.obj
[root@chrome cdrom]# mono temp.exe
Hello World
[root@chrome cdrom]#


Best regards,

Ioannis Vranos
Nov 17 '05 #5
Willy Denoyette [MVP] wrote:
Brandon,

Are you sure about this, my understanding is that assemblies built with
VS2005 Beta1 (and later) could only run on a CLR v2.0 due to changes in
the metadata.
Is this only true for .NET and does'nt Mono check the CLR version required
when loading a managed assembly?
Am I missing something?


You are correct that the metadata format was changed. The new format is
being adopted in the next version of the ECMA CLI standard. I would expect
Mono to work with that. While I'm not tracking the development of Mono, I'm
sure they've at least got something working with generics (the main reason
behind revising the metadata format).

All that said, we're expecting /clr:safe to have the same portability as the
Microsoft C# compiler.

--
Brandon Bray, Visual C++ Compiler http://blogs.msdn.com/branbray/
This posting is provided AS IS with no warranties, and confers no rights.
Nov 17 '05 #6
Brandon Bray [MSFT] wrote:
How can I remove that useless assembly reference to "Microsoft.VisualC"?

This is currently a bug in the Visual C++ compiler. We moved a number of
types from Microsoft.VisualC.dll into the frameworks assemblies (like
mscorlib.dll). Those types will need to be introduced on Mono to work, which
should be trivial.

The simple hello world example shouldn't need any changes to Mono... it's
just a bug in the VC compiler right now.


Thank you for your reply. Could you tell me which types were moved from
Microsoft.VisualC.dll into the frameworks assemblies please?


Best regards,

Ioannis Vranos
Nov 17 '05 #7
Hi Brandon,
This is currently a bug in the Visual C++ compiler. We moved a number of
types from Microsoft.VisualC.dll into the frameworks assemblies (like
mscorlib.dll).


Humm... was this post beta 1? At least on my copy, all the types in
Microsoft.VisualC.dll that were there in v1.1 are there on the beta1 bits...
plus a bunch new ones!

--
Tomas Restrepo
to****@mvps.org
Nov 17 '05 #8
Ioannis Vranos wrote:
Thank you for your reply. Could you tell me which types were moved from
Microsoft.VisualC.dll into the frameworks assemblies please?


Here's everything I know. Things are subject to change (consider this likely
to happen). Currently, all types were moved to mscorlib.dll, and are in the
System.Runtime.CompilerServices namespace.

The following types were shipped in Everett, and the compiler now uses the
type in the CompilerServices namespace instead.

Everett Whidbey
------- -------
IsConstModifier IsConst
IsCXXPointerModifier IsExplicitlyDereferenced
IsCXXReferenceModifier IsImplicitlyDereferenced
IsLongModifier IsLong
IsVolatileModifier IsVolatile
NoSignSpecifiedModifier IsSignUnspecifiedByte

While the following types can be found in Microsoft.VisualC.dll, they will
be removed before we RTM. Microsoft.VisualC.dll will ship with exactly the
same types it shipped with in Everett. The compiler uses the new types from
the CompilerServices namespace instead.

Everett Whidbey
------- -------
CxxUdtReturnStyleModifier IsUdtReturn
IsBoxedModifier IsBoxed
IsIntrinsicModifier IsJitIntrinsic
IsMarshalWorkaround CompilerMarshalOverride
NativeEnumAttribute ScopelessEnumAttribute

This was not moved to mscorlib, but I believe it needs to be. As it is
rarely emitted, we can live with the compiler emitting a reference to
Microsoft.VisualC.dll for now. As soon as it is moved to mscorlib, the type
will be removed from Microsoft.VisualC.dll.

Everett Whidbey
------- -------
HFAAttribute

This needs to be removed from both mscorlib and Microsoft.VisualC.dll. The
implementation for marshalling doesn't need it.

Everett Whidbey
------- -------
HasCopySemanticsAttribute HasCopySemanticsAttribute

There is no matching type in Microsoft.VisualC.dll for these, and the
compiler is using them.

Everett Whidbey
------- -------
IsByValue
IsPinned

This type was never moved to mscorlib, and the compiler doesn't need it. As
it was put into Microsoft.VisualC.dll after Everett shipped, we will remove
it.

Everett Whidbey
------- -------
IsCopyCtorModifier

These I think are unnecessary. As they were shipped in Everett, the
Microsoft.VisualC.dll assembly will still have them, but the compiler should
stop using them entirely.

Everett Whidbey
------- -------
DebugInfoInPDBAttribute
DecoratedNameAttribute
IsSignedModifier
MiscellaneousBitsAttribute
NeedsCopyConstructorModifier

--
Brandon Bray, Visual C++ Compiler http://blogs.msdn.com/branbray/
This posting is provided AS IS with no warranties, and confers no rights.
Nov 17 '05 #9
Tomas Restrepo (MVP) wrote:
Humm... was this post beta 1? At least on my copy, all the types in
Microsoft.VisualC.dll that were there in v1.1 are there on the beta1
bits... plus a bunch new ones!


We created new types in mscorlib.dll before Beta 1, but the Beta 1 compiler
does not use them. Post Beta 1 compilers do use them.

There are a bunch of new types in Microsoft.VisualC.dll that we do not need
now that we are using types from mscorlib.dll. These should be removed from
the assembly such that when Whidbey ships, Microsoft.VisualC.dll looks
exactly the same as it did when Everett shipped.

We still need to ship Microsoft.VisualC.dll for a few reasons: (1) existing
programs built with the 7.0 and 7.1 compiler need it so they can move to a
newer version of the Frameworks. And, (2) the old syntax uses the older
modifiers in several cases. So, it is reasonable to expect the old syntax to
create dependencies on the Microsoft.VisualC.dll, but this should never
happen with the new syntax.

I hope that's what you wanted to know!

--
Brandon Bray, Visual C++ Compiler http://blogs.msdn.com/branbray/
This posting is provided AS IS with no warranties, and confers no rights.
Nov 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Charles T. | last post by:
Hi, I currently writing a serialize/unserialize architecture. The read/write function will read/write from a binary file. My question is is there some sort on defined standart to use when...
7
by: KantKwitDansin1 | last post by:
I have a file "a.dat" containing 10^4 32 bit binary numbers. I need to read in these numbers and deterimine if they are prime. The primality part I will have to figure out later, but I was...
10
by: Angus Comber | last post by:
Hello My code below opens a Word document in binary mode and places the data into a buffer. I then want to search this buffer for a string. I tried using strstr but think it stops looking when...
15
by: T Koster | last post by:
Hi group, I'm having some difficulty figuring out the most portable way to read 24 bits from a file. This is related to a Base-64 encoding. The file is opened in binary mode, and I'm using...
26
by: Michel Rouzic | last post by:
I have a binary file used to store the values of variables in order to use them again. I easily know whether the file exists or not, but the problem is, in case the program has been earlier...
4
by: knapak | last post by:
Hello I'm a self instructed amateur attempting to read a huge file from disk... so bear with me please... I just learned that reading a file in binary is faster than text. So I wrote the...
2
by: akitoto | last post by:
Hi there, I am using the std::stringstream to create a byte array in memory. But it is not working properly. Can anyone help me? Code: #include <vector> #include <sstream> #include...
3
by: masood.iqbal | last post by:
Hi, Kindly excuse my novice question. In all the literature on ifstream that I have seen, nowhere have I read what happens if you try to read a binary file using the ">>" operator. I ran into...
9
by: deepakvsoni | last post by:
are binary files portable?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.