Hi All,
I have to write C++ code (server code) that will compile/run on both
Windwos and Linux OS's.
Could someone give me some pointers to info on this matter.
Thanks in advance for your help.
Silviu 5 8711
"silviu" <th************ *@yahoo.com> wrote... I have to write C++ code (server code) that will compile/run on both Windwos and Linux OS's.
Could someone give me some pointers to info on this matter.
The simplest solution is to use only standard mechanisms and classes.
Given that you have a standard-compliant compiler on each platform,
programs will be source-code compatible and should have the same
side effects (behaviour).
Victor
"silviu" <th************ *@yahoo.com> wrote in message
news:f5******** *************** ***@posting.goo gle.com... Hi All,
I have to write C++ code (server code) that will compile/run on both Windwos and Linux OS's.
Could someone give me some pointers to info on this matter.
Thanks in advance for your help.
Silviu
Simple. Don't write any platform-specific code! :-)
Seriously, though...do you have to provide a GUI? Handle files/directories?
Databases? Manage system resources? If yes, then you'll need at least
*some* code that is platform-dependant, which means it will be written
differently on each platform you target. Depending on your needs, there is
third-party, cross-platform software out there. Some SDK's are writtin with
this in mind, so that most porting work is simply a matter of setting up
your projects differently. You also have to deal with what compiler(s)
you'l be using, and that may change how you do some things.
If you don't have to worry about those things, then simply write your code
such that it follows the C++ standard (as discussed here), and avoid any
platform-specific junk (like MFC in VC++ apps.)
Check Google for cross-platform software if you need it.
Best of luck!
-Howard
silviu wrote: Hi All,
I have to write C++ code (server code) that will compile/run on both Windwos and Linux OS's.
Could someone give me some pointers to info on this matter.
Thanks in advance for your help.
Silviu
If you must use platform-specific code to handle the sort of stuff
Howard mentioned, do your best to compartmentaliz e that code away
from the rest of your program's logic.
--
--- remove zees if contacting via email ---
Just regular C++ should work on both platforms. Just be
careful about the case insensitivity of the Windows file system.
If you are planning to write GUI code, the best option is
wxWindows ( www.wxwindows.org)
Sandeep
-- http://www.EventHelix.com/EventStudio
EventStudio 2.0 - System Architecture Design CASE Tool th************* @yahoo.com (silviu) wrote in message news:<f5******* *************** ****@posting.go ogle.com>... Hi All,
I have to write C++ code (server code) that will compile/run on both Windwos and Linux OS's.
Could someone give me some pointers to info on this matter.
Thanks in advance for your help.
Silviu
I'd also recommend:
1- Layer your code so that you'll tuck all the OS specfic code in that
class, perhaps
an OSIL (OS Independent Layer) on top of OS1, OS2, ...., etc.
2- Use a common compiler if possible. For example if you will be using
GCC on Linux,
see if you can use the same GCC for your Windows. This way you let the
compiler and glibc++
authors figure out the differences and you stay out of that game.
3- If you must use Microsoft VC++, use their latest 7.x as 6.x does
not have all the STL
or their implementation might differ a bit.
4- If you use fancy C++ features, you might run into some issues; For
example RTTI is
definitly different in GCC and VC++.
5- If you ever plan to port to 64 bit, whach out as Microsoft is not
up to speed on that
for example in VC 64 bit, a long is still a 32 bit.
6- Work with iostream an not printf stuff as their format specs are
different.
If you use GCC on both, you don't have to worry about many of above
stuff
Now if you use Win32 API, you'll find that Microsoft has so many
Helper Functions
that you'll be both confused and for ever hooked on their products....
Just use plain o-C++ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Michael T Decerbo |
last post by:
The code below compiles without warnings or errors under g++ 3.2.1 on
Solaris, gcc 3.2.2 on Linux, and MSVC 6.0 on Windows.
Under g++ (GCC) 3.3.2, it produces the following errors:
% g++ -Wall testme_std.cpp
testme_std.cpp:24: error: no `I LblID<I, MaxInd>::add(const
std::basic_string<char, std::char_traits<char>, std::allocator<char> >&)'
member function declared in class `LblID<I, MaxInd>'
testme_std.cpp:24: error: template...
|
by: Eigenvector |
last post by:
I apologize if this is a trivial question, but it's always made me wonder
when I have to compile my code.
There are some #includes that you don't really need to reference in your
library and header references in the compilation string.
For instance the standard hello.c
#include <stdio.h>
int main()
|
by: Ilkka |
last post by:
I have created an C++ application with Windows Forms, ADO and SQL server
2005. Now I need to change something and started debugging the code. Then
suddenly I receive an error.
"An unhandled exception of type 'System.AccessViolationException' occurred
in mscorlib.dll
Additional information: Attempted to read or write protected memory. This is
often an indication that other memory is corrupt."
The progran ends on a windows form designer...
|
by: akjohn |
last post by:
My code compiles fine using VC++ 2005 and also with g++/gcc 3.4.2
(mingw...which came with the bloodshed dev c++ ide). But it only the
vc++ build works correctly, the gcc exe starts but hangs...suggesting
some memory problem. On building it with gcc 3.4.4 on red hat linux, I
get a seg fault.
I'm wondering why my code works fine with vc++ and not with g++/gcc.
Are there are any flags I can set in gcc to make it work ok ?. I'm
coding on...
|
by: jc |
last post by:
I have written a parser using bison and flex to read ASAP2 file for CAN
communications. entire development was done in an unix environment and
now the code is ready to be integrated to an existing CAN communication
software that i wrote earlier in windows environment(as we get drivers
for these CAN cards only for the windows).
my problem started when i started to move the code from linux to the
visual studio. after many compilation and...
| |
by: Lior |
last post by:
Hi,
I have small code, that compiles on Visual C++ into a shared library
(DLL).
I need to compile it under linux, but the code includes some data
types I'm not familiar with, such as DWORD, HANDLE, __int64, ULONG
etc.
What are those words?
|
by: Arcturus |
last post by:
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkh6waMACgkQq5h2IFR18WMFrwCgv/PNAC8FTZCErvc0KHnx0zpC
KhcAnjl/xFAEJb056UdQaCZqPfnGbqA+
=0Y8B
-----END PGP SIGNATURE-----
-----BEGIN PGP SIGNATURE-----
|
by: anchitgood |
last post by:
Hey, I have developed the following code and it is executing well on
windows. But I don't have LINUX installed on my system. I would be
grateful to you guys if you check whether this code is working fine on
linux. I know that C++ is independent of OS, but still check it on g++
compiler.
Thanks a lot in advance.
Anchit
CODE:
#include<iostream>
|
by: engAmrnajjar |
last post by:
I have a program (which is a university assignment) it does compile and run correctly on windows, but when i copy it an compile it on linux, it compiles and run successful but gives other results, i have been trying to figure out why for the last 10 hours and i could not ,
i have done debuging on Linux, and discovered that tere is an array of integer which values change automatically, i mean without any code that manipulaties the values, ...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
| |
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...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |