C ++ cross-platform applications

Source: Internet
Author: User
Tags wxwidgets

Slogan: code once, compiled everywhere! :-)

One encoding, which is completed on vc7.1, vi, and even ulteredit.
Compile code everywhere, copy the written code to other operating systems, and compile and run it without having to modify even a line of code.
Does it sound like SUN. In fact, the portability of c ++ is deemed to be more than that of java. The reason why java is famous is that B .S makes it clear: the interests of vendors.
 
Well, you don't need to talk nonsense.
 
It is also difficult and easy to build a c ++ cross-platform application.
What are the difficulties? The so-called application is a practical application and involves a wide range of topics. Generally, we need to consider at least the following aspects:
0. Language and basic library
1. Operating System related
2. Network
3. Database
4. Interface
There are many other things, such as XML and encryption/Decryption. Here we will first discuss the items listed above.
As we all know, different operating systems may have the same functions in real time. For example, parameters and returned values have different definitions (socket), and even different semantics (sleep. If you need to maintain the difference on your own, you must write the following code:
# If defined WINNT
# Elif defined LINUX
...
This is definitely a huge project. As for how big the project is, you can take a look at ACE development costs. This is hard!
In order to realize my slogan, what I want to do is to find a cross-platform library that has been proven by everyone's practices to help with coding. It is easy to build on the shoulders of giants. Some of my options are listed one by one below:

0. Language and base library:
Standard C ++ and boost


The standard C ++ was developed in 98 years. Currently, the mainstream C ++ compilers support it well. Vc7.1 and gcc4.0 and later are recommended. Boost is a set of C ++ libraries built up by a group of C ++ standards committees. Many of these libraries are imported into C ++ tr1, which can be said to be quasi-standard. We have a good reason to use the library here. For string-like operations, you can use the boost string algorithms library. for formatting operations, you can use boost: format and the regular expression boost: RegEx. The boost content is quite rich. For more information, see
The http://www.boost.org/libs/libraries.htm here has a list of boost libraries.

1. Operating System related:
ACE (ADAPTIVE Communication Environment) and boost

Ace encapsulates the mutex, signal, process, and thread related to the operating system and can be used directly. However, if no ace is used, not every program is related to the network. If no ace is used, it may not be used. At this time, you can consider using the corresponding boost class thread: thread, boost.: process, etc.

2. Network
ACE


Ace is very good for network applications. In addition to simple packaging for heterogeneous platforms, there are also design models to cope with various environments. It can even be said that C ++ is currently the only choice for cross-platform network programming. ACE also provides packaging for high performance requirements such as iocp (winnt) or epoll (linux2.6.

3. Database
OTL (Oracle, Odbc and DB2-CLI Template Library)


To support databases, not only cross-platform, but also cross-database, is it more ideal than you think. OTL supports the following databases: OTL Oracle, SQL Server, access, and MySQL. There are other libraries such as DTL, but I think this library not only supports ODBC, but also supports native database interfaces, which can provide better performance.

4. Interface
QT, wxWidgets


Although I have been using MFC for many years, I still hate the countless macros of MFC. Although wxWidgets is good, its style is obvious. Use QT. object-oriented programming is quite pleasant. However, QT is a two-way authentication. If your program is free of charge, it will be free of charge. If your program is going to sell money, it will also need it, and the price is very high. Therefore, wxWidgets can be considered for copyright and cost considerations.

I have listed many things and hope to help you. However, note that the number of platforms supported by each database is small and inconsistent. You need to estimate the platform that may be used for application. However, it is enough in general. The above Library supports at least two types of files: Windows and Unix/Linux. Here, we can basically move our own programs in Windows and Linux! ".

 
Related
ACE: http://www.cs.wustl.edu /~ Schmidt/ace.html
Boost: http://www.boost.org/
OTL: http://otl.sourceforge.net/
QT: http://www.trolltech.com/

Imported from blog

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.