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%.