C ++ / CLI代码的二进制可移植性 [英] Binary portability of C++/CLI code

查看:98
本文介绍了C ++ / CLI代码的二进制可移植性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Visual C ++ 2005 Express Beta 1编译了当前C ++ / CLI

草案(版本1.5)中指定的hello world程序:

int main()

{

System :: Console :: WriteLine(" Hello World");

}

C:\c> cl / clr:safe temp.cpp

Microsoft(R)C / C ++优化编译器版本14.00.40607.16

for Microsoft(R) .NET Framework版本2.00.40607.16

版权所有(C)Microsoft Corporation。保留所有权利。


temp.cpp

Microsoft(R)增量链接器版本8.00.40607.16

版权所有(C)Microsoft公司。保留所有权利。


/out:temp.exe

temp.obj

==> / clr:safe只生成一个传递peverify的可执行文件:


C:\ c> peverify temp.exe / verbose


Microsoft (R).NET Framework PE Verifier。版本2.0.40607.16

版权所有(C)Microsoft Corporation。保留所有权利。


temp.exe中的所有类和方法已验证。


C:\c>



然后想要测试生成的可执行文件的二进制可移植性,

我试图在另一台CLI机器上运行生成的可执行文件:


root @ chrome cdrom] #monon temp.exe


**(temp.exe:1416):警告**:找不到程序集

Microsoft.VisualC,来自/mnt/cdrom/temp.exe的引用(assemblyref_index = 1)

主要/次要:8,0

构建: 1200,0

令牌:b03f5f7f11d50a3a

无法打开程序集temp.exe

[root @ chrome cdrom]#



看起来,MS对生成的

可执行文件引入了平台依赖性,即使对于纯C ++ / CLI代码也是如此。

如何删除无用的程序集引用Microsoft.VisualC?


祝你好运,


Ioannis Vranos

解决方案

Mono落后于您在VS2005中所看到的基于CLR版本

2.0。

您的程序也不会在.NET v1.0和1.1上运行,它需要v2.0


Willy。


Ioannis Vranos < iv*@guesswh.at.grad.com>在留言中写道

新闻:eE ************** @ TK2MSFTNGP12.phx.gbl ...

我编译了你好世界程序,在当前的C ++ / CLI
草案(版本1.5)中指定,使用Visual C ++ 2005 Express Beta 1:

int main()
{
System :: Console :: WriteLine(Hello World);
}

C:\c> cl / clr:safe temp.cpp
Microsoft(R) C / C ++优化编译器版本14.00.40607.16
用于Microsoft(R).NET Framework版本2.00.40607.16
版权所有(C)Microsoft Corporation。保留所有权利。

temp.cpp
Microsoft(R)增量链接器版本8.00.40607.16
版权所有(C)Microsoft Corporation。保留所有权利。

/out:temp.exe
temp.obj

==> / clr:safe只生成一个传递peverify的可执行文件:

C:\ c> peverify temp.exe / verbose

Microsoft(R).NET Framework PE Verifier 。版本2.0.40607.16
版权所有(C)Microsoft Corporation。保留所有权利。

temp.exe中的所有类和方法已经验证。

C:\c>


然后想要为了测试生成的可执行文件的二进制可移植性,我试图在另一台CLI机器上运行生成的可执行文件:

root @ chrome cdrom] #mono temp.exe

**(temp.exe:1416):警告**:无法找到程序集Microsoft.VisualC,
来自/mnt/cdrom/temp.exe的引用(assemblyref_index = 1)主要/次要:8,0
构建:1200,0
令牌:b03f5f7f11d50a3a
无法打开程序集temp.exe
[root @ chrome cdrom]#<看起来,MS引入了生成的可执行文件的平台依赖性,即使对于纯C ++ / CLI代码也是如此。

我怎样才能删除那些无用的东西汇编参考Microsoft.VisualC?


致以诚挚的问候,

Ioannis Vranos


Ioannis Vranos写道:如何删除对Microsoft.VisualC的无用程序集引用?




这是目前Visual C ++编译器中的一个错误。我们将Microsoft.VisualC.dll中的一些

类型移动到框架程序集中(例如

mscorlib.dll)。这些类型需要在Mono上引入才能工作,这对于b $ b应该是微不足道的。


简单的hello world示例不需要任何更改Mono ...现在只是VC编译器中的一个错误。




-

Brandon Bray ,Visual C ++编译器 http://blogs.msdn.com/branbray/

此帖子按原样提供,不提供任何保证,并且不授予任何权利。


布兰登,


你确定这一点,我的理解是用

VS2005 Beta1(及更高版本)构建的程序集只能在CLR v2.0上运行,因为

的变化元数据。

这是否仅适用于.NET并且不需要Mono检查所需的CLR版本

加载托管程序集时?

我错过了什么吗?


Willy。


" Brandon Bray [MSFT]" <峰; br ****** @ online.microsoft.com>在留言中写道

新闻:%2 **************** @ TK2MSFTNGP10.phx.gbl ...

Ioannis Vranos写道:

如何删除对Microsoft.VisualC的无用程序集引用?



这是目前Visual C ++编译器中的一个错误。我们将Microsoft.VisualC.dll中的一些类型移动到框架程序集中(例如
mscorlib.dll)。这些类型需要在Mono上引入才能工作,
这应该是微不足道的。

简单的hello world示例不需要对Mono进行任何修改......它现在只是VC编译器中的一个错误。

- Brandon Bray,Visual C ++编译器 http://blogs.msdn.com/branbray/
此帖子按原样提供,不提供任何保证,并且不授予任何保证权利。



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

解决方案

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



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.


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.



这篇关于C ++ / CLI代码的二进制可移植性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆