Linux program transplantation for windows and linux

Source: Internet
Author: User

Linux program transplantation for windows and linux

1. The path name must use the forward slash "/". (Both forward and backward slashes are recognized in windows. In linux, only forward slashes are recognized .)

2. If you cannot save Chinese Characters in vim, enter the following command:

: Set fileencoding = prc

: Set encoding = prc

Or install iconv. (Earlier linux system default encoding for Chinese characters for UTF-8, and windows is the National Standard Code GBK by default, so the Chinese characters in the windows program to linux will become garbled, in turn will not, windows can automatically recognize Chinese character encoding formats .)

3. You can use the freetds Development Kit to connect to sqlserver in linux. Remember to make relevant settings during compilation to find libct. a and libsybdb. a, or the corresponding dynamic library. (Microsoft sqlserver in linux... Of course ......)

4. develop the habit of using Conditional compilation. All linux exclusive, plus

# Ifdef _ LINUX

......

# Endif

You can add the-D_LINUX parameter to the compilation option.

Avoid repeated compilation of header files:

# Ifndef _ HEAD _

# Define _ HEAD _

# Include "head. h"

# Endif

5. Flexible namespace usage

6. Do not use case sensitivity or Chinese characters for file names. (Windows is case-insensitive, which can merge files in upper and lower case .)

 

 

To be continued ......


How to port a program to linux in windows

Windows:
Compiled to 64-bit. Except for the 64-bit pointer and handle, the other basic data types remain unchanged.

In Linux:
/****** Size of types on centos_x32 *****************/
Size of char: 1
Size of int: 4
Size of long: 4
Size of float: 4
Size of long: 8
Size of double: 8
Size of long double: 12
Size of char *: 4
/******* Size of types on centos_x64 *****************/
Size of char: 1
Size of int: 4
Size of long: 8
Size of float: 4
Size of long: 8
Size of double: 8
Size of long double: 16
Size of char *: 8

How can I port a program in Linux to Windows for running? what changes need to be made, such as library loading?

The transplantation of a program is to change the library... as for what library, you need to check what library your program uses and find a replacement under windows.

Function names must be different. If you do not use cross-platform class libraries such as qt gtk, you must change code 80%.

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.