LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-17-2007, 12:32 AM   #1
Bassam
Member
 
Registered: Mar 2003
Location: Malaysia
Posts: 63

Rep: Reputation: 15
How to build a C++ portable network application on Win32 and POSIX systems?


Dear All,
I have written a network application on Win32 system (Windows XP) using C++. I, however, realised that I need to have the same application to be portabl on POSIX systems as well. I don't want to use porting technology.

Regarding this issue, I have many question that I need you guys to clarify to me. I will raise up a question here and later will pump the others.

My application has many DDLs that could be linked dynamically to the main process. My question is how could my DLLs be replaced in POSIX system. I mean what is the way that could be used to modulrise applications on POSIX systems?


Your help is much appreciated

Regards
Bassam
 
Old 05-17-2007, 04:43 PM   #2
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
The applications don't need to be the same; just the communication across the network and (if applicable) the format of a transferable file.

I generally design as much as possible in portable code and leave link points for non-portable interfaces such as threads, GUIs, etc. I try to have all non-portable code isolated in its own libraries so that they can be switched out if necessary at link or run time.

The POSIX equivalent to DLL is shared library, ending with .so or .so.0.1, etc. They are essentially a linked object with no execution entry point and relocatable code. You don't need anything special to create them except for the '-fPIC' gcc option (for relocatable code which can be inserted anywhere into a program at run time), the '-shared' ld option, and optionally the '-soname [name + .so + version]' ld option. A soname is used to denote a compatibility version. For example, if all 0.1 versions of your library use the same API you might have libyourlib.so.0.1 as the soname for libyourlib.so.0.1.0, libyourlib.so.0.1.1, etc. That way if a program hard-links to libyourlib.so.0.1.0 it will use libyourlib.so.0.1.1, etc. as they are upgraded but won't use libyourlib.so.0.2.x.

To hard link to a shared library just use '-lyourlib' for libyourlib.so at link time. To link at run time (such as a plug-in) check out dlopen.
ta0kira

Last edited by ta0kira; 05-17-2007 at 04:46 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Serial port programming problem (Win32 VS POSIX) chanwing Programming 1 06-29-2005 12:17 PM
How to compile win32 application? dmigh Programming 3 11-20-2004 11:00 AM
Portable WIn32 hdd rottmanj Linux - Hardware 5 07-21-2003 09:05 AM
Porting win32 application into Linux sergeyy Linux - Software 1 06-23-2003 09:57 AM
win32 application Jargon Linux - Newbie 2 05-29-2002 01:26 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:29 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration