Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

is vc++ program portable on linux? can i make it portable? 1

Status
Not open for further replies.

ArvindKumar17

Programmer
Jan 7, 2003
13
0
0
MU
hi,
Are programs developped in VC++ portable in linux.
Are there are anyway to make them portable - like the use of DLL.

It is not as if C/C++ is not available on linux. Then, how can I make a program from VC++ portable on linux.

I have to develop my client program in C++. Is VC++ the only platform where I can built it or are there any other platform.

regards
arvind
 
Usually C++ programs are not cross OS portable, but they can communicate between them by using TCP/IP, RPC or CORBA. Using TCP/IP, RPC or CORBA you will make them OS and language neutral. Ion Filipski
1c.bmp


filipski@excite.com
 
hi,
I know that I can communicate via CORBA. But if the client program has been programmed in VC++ will it be portable on linux.
You have to consider that in VC++, the client program was build using the windows API but on linux those API will not be there making it not portable.
PLease let me know u views.

regards
arvind
gunheaa@softhome.net
 
Some C++ is portable, and some is OS specific. Linux doesn't use Microsoft classes, and will not, for example, be compatible with MFC GUI code.

You can, however, make back-end classes that are portable, then code two different interfaces (or whatever) that use the same (back-end) class.
 
Also can be compatible only source code, not the compilled code. Where you use WinAPI you should change it to Linux specific API. Ion Filipski
1c.bmp


filipski@excite.com
 
You can use Qt for API - then Your source code can be compiled on Windows/Unix/Linux without any changes.
You can download Qt (there are freeware too) from:
 
Commonality of GUI is a major concern, as described above. There are also some minor differences with native C code and libraries. These need to be understood and bracketed out with #DEFINE and #IFDEF / #ENDIF directives. For example,

1. The formats of binary data stored in files may be little endian or big endian, depending on platform. So you need a converter if you want to make data files compatible across platforms. Example:

#define IS_WINDOWS
//
//
float xxx;
// read xxx from binary file

#ifdef IS_WINDOWS
swap_endian( (char*)&xxx, sixeof(float));
#endif


2. I came across this:

#include <fstream.h>
fstream infile;
#ifdef IS_WINDOWS
infile.open(filename, ios::in | ios::binary); // required in Windows
#else
infile.open(filename, ios::in); // binary option disallowed in UNIX
#endif

 
Good idea tchouch. I have spend some time fo find ST for windows, but had not enough time. Ion Filipski
1c.bmp


filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top