将库或exe集成在不同的编译器上 [英] Integrating libraries or exe's complied on different compilers

查看:90
本文介绍了将库或exe集成在不同的编译器上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


如果我有两个c ++程序,我在Unix上使用两个不同的

编译器进行编译。这两个exe是否可以相互沟通

。由于exe'的生成方式是两个不同的编译器不同,所以可以通过

进行通信。有没有替代方案。用两个不同的编译器编译的图库

怎么样?如果有人可以提供一些

的反馈,那将会有很大帮助。


问候,

Sh

推荐答案

sh *** ***********@gmail.com kirjutas:
sh**************@gmail.com kirjutas:

大家好,


如果我有两个c ++程序,我在Unix上使用两个不同的

编译器进行编译。这两个exe是否可以相互沟通

。由于exe'的生成方式是两个不同的编译器不同,因此可以通过
进行通信
Hi all,

If I have two c++ programs and I compile that using two different
compilers on Unix. Is it possible for these two exe''s to communicate
with one another. Since the way the exe''s are generated by two
different compilers are different is it possible to communicate at



我希望你是意识到您的浏览器能够与Web

服务器通信,无论Web服务器编译的是哪个编译器。对于任何两个应用程序来说,这通常是一个真实的:同意通信

频道并使用不依赖于编译器的外部格式 -

类型大小或结构填充等具体细节。

I hope you are aware that your browser is able to communicate with a web
server regardless of by which compiler the webserver is compiled. This is
in general true for any two applications: agree on a communication
channel and use an external format which does not depend on compiler-
specific details like type sizes or struct padding.


all。有没有替代方案。用两个不同的编译器编译的图库

怎么样?如果有人可以提供一些
all. Is there any alternative for the same. What about libraries
compiled with two different compilers. If someone can give some



您可能意味着是否可以将由

不同编译器编译的C ++库链接在一起。这是标准所定义的,这意味着你不能以b / b
的方式进行此操作。


只有两个编译器都遵循相同的ABI(应用程序

二进制接口)。 ABI通常被定义为语言平台的特定组合

,例如,适用于Linux的C ++ ABI x86_64。我相信

是一些标准化C ++ ABI的平台,所以如果两个编译器都遵循这个,那么他们应该能够互相交流。


但是,这还不够。例如,如果一个库对std :: string使用small-

字符串优化而另一个库没有,那么任何

尝试从一个传递一个std :: string图书馆对另一个人来说最可能是惨不忍睹。这就是C ++的单定义规则

开始的地方,我想 - 如果库使用不同的std :: string

定义,结果是未定义的。因此所有这些业务都是非常实现的,并且最好避免(除非一个编译器供应商

明确表示他们的产品保证兼容兼容

与来自其他供应商的那个,就像英特尔C ++
编译器一样。


仅使用C类型和externC函数可能会有所帮助,因为C ABI

是针对更多平台的标准化。我不太清楚C ABI对于结构填充/打包这样的东西是什么意思,我可能会在任何情况下避免它们使用

而是使用数组。


hth

Paavo

You probably mean whether you can link together C++ libraries compiled by
different compilers. This is undefined by the standard, meaning that you
cannot do this portably.

It is only possible if both compilers follow the same ABI (application
binary interface). The ABI is typically defined for a certain combination
of a language platform, e.g. C++ ABI for Linux on x86_64. I believe there
are some platforms with standardized C++ ABI, so if both compilers follow
this, they should be able to talk to each other.

However, this is not enough. For example, if one library uses small-
string optimization for std::string and the other does not, then any
attempt to pass a std::string from one library to another will most
probably fail miserably. This is where the one-definition-rule of C++
kicks in, I guess - if the libraries are using different std::string
definitions, the result is undefined. So all this business is very
implementation-defined and best to be avoided (unless one compiler vendor
explicitly says their product is guaranteed to be binarily compatible
with the one from another vendor, like is the case for Intel C++
compiler).

Using only C types and extern "C" functions may be helpful, because C ABI
is standardized for more platforms. I am not too sure what the C ABI says
about things like struct padding/packing, I would probably avoid them for
any case and use arrays instead.

hth
Paavo


sh ************** @ gmail.com 写道:

如果我有两个c ++程序,我在Unix上使用两个不同的
编译器进行编译。这两个exe是否可以相互沟通


If I have two c++ programs and I compile that using two different
compilers on Unix. Is it possible for these two exe''s to communicate
with one another.



也许你应该首先向我们解释你如何期望用* same *编译器编译的两个

程序与每个人进行通信/>
其他,然后也许我们会更好地理解什么是

你看到的两个程序用*不同*

编译器编译的问题在这方面。

Maybe you should first explain to us exactly how you expect two
programs compiled with the *same* compiler to communicate with each
other, and then maybe we will understand a bit better exactly what is
the problem you are seeing with two programs compiled with *different*
compilers in this regard.


sh ** ************ @ gmail.com 写道:

大家好,


如果我有两个c ++程序,我在Unix上使用两个不同的
编译器进行编译。这两个exe是否可以相互沟通

。由于exe'的生成方式是两个不同的编译器不同,所以可以通过

进行通信。有没有替代方案。用两个不同的编译器编译的图库

怎么样?如果有人可以给出一些

反馈,那将会有很大帮助。
Hi all,

If I have two c++ programs and I compile that using two different
compilers on Unix. Is it possible for these two exe''s to communicate
with one another. Since the way the exe''s are generated by two
different compilers are different is it possible to communicate at
all. Is there any alternative for the same. What about libraries
compiled with two different compilers. If someone can give some
feedback on the same it will be of great help.



假设沟通==链接那么唯一安全的方式是通过函数

与externC联系。


-

Ian Collins

Assuming communicate == link then the only safe way is through functions
with extern "C" linkage.

--
Ian Collins


这篇关于将库或exe集成在不同的编译器上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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