473,881 Members | 1,641 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Integrating libraries or exe's complied on different compilers

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.

Regards,
Sh
Nov 15 '08 #1
14 1840
sh************* *@gmail.com kirjutas:
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
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. Is there any alternative for the same. What about libraries
compiled with two different compilers. If someone can give some
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
Nov 15 '08 #2
sh************* *@gmail.com wrote:
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.
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.
Nov 15 '08 #3
sh************* *@gmail.com wrote:
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.
Assuming communicate == link then the only safe way is through functions
with extern "C" linkage.

--
Ian Collins
Nov 15 '08 #4
Ian Collins wrote:
sh************* *@gmail.com wrote:
>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.
Assuming communicate == link then the only safe way is through functions
with extern "C" linkage.
Even that's not safe, because they may have different ABIs into the
Standard Library
Nov 15 '08 #5
On Nov 15, 6:04*pm, Paavo Helde <nob...@ebi.eew rote:
shyam.lingego.. .@gmail.com kirjutas:
[...]
all. Is there any alternative for the same. What about
libraries compiled with two different compilers. If someone
can give some
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.
The physical layout of std::string is part of a C++ ABI, so if
their is a C++ ABI, there should be no problem. (On the
platforms I work on, there isn't, and this doesn't work. In
fact, the C++ ABI even depends on compiler options, and you
can't necessarily link two libraries compiled with the same
compiler. From what I understand, this is more or less
general.)
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.
A C ABI must define how struct's are laid out. All that I know
do. (In particular, both Windows and Posix do, since both use
struct's in their system ABI.) Of course, a compiler still
might have options, or pragmas, to break this compatibility.

--
James Kanze (GABI Software) email:ja******* **@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientier ter Datenverarbeitu ng
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Nov 16 '08 #6
red floyd wrote:
Ian Collins wrote:
>sh************* *@gmail.com wrote:
>>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.
Assuming communicate == link then the only safe way is through functions
with extern "C" linkage.

Even that's not safe, because they may have different ABIs into the
Standard Library
Which systems would that apply to?

--
Ian Collins
Nov 16 '08 #7
Ian Collins wrote:
red floyd wrote:
>Ian Collins wrote:
>>sh************* *@gmail.com wrote:
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.

Assuming communicate == link then the only safe way is through functions
with extern "C" linkage.
Even that's not safe, because they may have different ABIs into the
Standard Library

Which systems would that apply to?
Windows? Possibly any Unix that has both a proprietary compiler and gcc?
Nov 16 '08 #8
red floyd wrote:
Ian Collins wrote:
>red floyd wrote:
>>Ian Collins wrote:
sh************* *@gmail.com wrote:
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.
>
Assuming communicate == link then the only safe way is through
functions
with extern "C" linkage.

Even that's not safe, because they may have different ABIs into the
Standard Library

Which systems would that apply to?
Windows? Possibly any Unix that has both a proprietary compiler and gcc?
Unless the platform is really FUBAR, all C compilers for that platform
follow the platform's ABI conventions. Otherwise they wouldn't be able
to use any of the platform's standard headers.

--
Ian Collins
Nov 16 '08 #9
On 2008-11-16 02:38:53 -0500, Ian Collins <ia******@hotma il.comsaid:
red floyd wrote:
>Ian Collins wrote:
>>red floyd wrote:
Ian Collins wrote:
sh************* *@gmail.com wrote:
>Hi all,
>>
>If I have two c++ programs and I compile that using two different
>compiler s 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
>differen t 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.
>>
Assuming communicate == link then the only safe way is through
functions
with extern "C" linkage.
>
Even that's not safe, because they may have different ABIs into the
Standard Library

Which systems would that apply to?
Windows? Possibly any Unix that has both a proprietary compiler and gcc?

Unless the platform is really FUBAR, all C compilers for that platform
follow the platform's ABI conventions. Otherwise they wouldn't be able
to use any of the platform's standard headers.
The point was that different implementations of the standard library
may have, for example, different implementations of std::string.

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The
Standard C++ Library Extensions: a Tutorial and Reference
(www.petebecker.com/tr1book)

Nov 16 '08 #10

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

Similar topics

12
2605
by: Woodster | last post by:
I currently have some code for an application that is running on Win32. I have tried to keep anything not directly gui related as separate as possible for portability reasons, including file access. Now has come the time to try and implement the program on a Windows CE platform. Problem is, that the MFC CArchive class uses an integer file pointer and calls to open, close etc and my file handling class is doing everything with FILE *, such...
7
5217
by: Steve | last post by:
Hi, We have an application framework library that gets statically linked to any applications we produce. (Windows apps, but I don't think that matters here). The framework is based heavily on the STL and the API uses many STL constructs. Because of the static linking, and the fact that both app and framework are built by the same compiler, we don't have any problems.
1
1159
by: jim.massengale | last post by:
The Libraries that I am linking with are compiled in Visual 6.0. I have an exported CEPAttribute with the function CEPAttribute::GetLineStyle(CString &_strValue). The project that I am compiling in VC7 (2003) uses the CEPAttribute but doesn't call the ::GetLineStyle(CString) function. When it links I get the following error: error LNK2001: unresolved external symbol "public: virtual int __thiscall CEPAttribute::GetLineStyle(class...
3
33121
by: salunkerahul | last post by:
Hello All, I have some static libraries generated on MSVC 2005 express edition and I have to use them along with static libraries created with MSVC 2003 and create an application on MSVC2003. example.lib - generated on MSVC2005 All other libs - generated on MSVC2003 I have attached the compiler options as well as the error log along. Any tips/suggestions will be of great help. Thanks in Advance
2
1823
by: pssraju | last post by:
Hi, Third party software vendors are putting restrictions on compiler for specific platforms, which inturn limiting scope for my application to explore other compilers. Would it be possible for me build an my application (using one type compiler say Sun Workshop CC) which inturn uses 3rd party libraries(shared) which were built using another compiler (say gcc)? I tried to simulate the same with small test program and I am getting...
30
3835
by: Dave -Turner | last post by:
So I just downloaded Bloodshed devcpp, opened up the Hello example, compiled it, no problems ..... well, except one - the exe is 474,990 bytes! What's the secret to compiling small exes? Thanks
1
146
by: CBFalconer | last post by:
kooladi wrote: Yes. The first module that satisfies a function load request will normally resolve that function forever. This sequence is normally needed to make libraries flexible, but is not part of the standard. -- : Chuck F (cbfalconer at maineline dot net) : <http://cbfalconer.home.att.net> Try the download section.
12
3185
by: nik | last post by:
Hi, I've compiled my application on my vista machine, and it won't run at all on my xp machine. In the windows error report I get Exception code; 0xe0434f4d. I searched for that exception, but didn't see anything related to my problem. I can run a different .exe that I made on the vista machine on the xp machine, so I am wondering what is different/wrong with this one. The xp machine does have vb6 installed on it, could that be an...
2
8614
by: Saser | last post by:
First post, lol. Please bear with my English, I'm a 14 year old guy from Sweden. I just started learning C# a few days ago, so I wanted to create something simple (but yet still useful). I'm making a console application which launches the compilers for different programming languages. So far have I got compilers for Java, C/C++, C# and Pascal. This is how the program works: 1. The user types in the path to the file (s)he wants to...
0
9776
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10718
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10402
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9555
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7953
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7111
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5781
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3225
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.