Compile Linux code in window

Source: Internet
Author: User

Write Linux code in Windows
I can't find a convenient tool when writing code in Linux. VI and Emacs provide automatic functions, but they still do not
VC + visual assistant is convenient, hence the idea of Linux code in windows. This attempt was once despised by baboons
"You are not allowed to live", but after practice, I have survived the village chief :-)
I. experiment environment
1. One Machine with Win2k is installed, and vc6 + vs2003 + visual assistant + Source insight is installed.
2. One server with Linux as3 installed with all software packages
Step 2
1. Copy/usr/include on a Linux machine to a specified directory on a Windows machine, as shown in
F:/linuxhead
Copy/usr/lib/GCC-lib/i386-redhat-linux/3.2.3/include/to the directory named "gcchead"
2. Add the path ("tool"-> "option"-> "project"-> "VC ++ directory"-> "include file") to the header file of vs2003.
F:/linuxhead/include directory
F:/linuxhead/gcchead/include directory
Make sure the two directories are at the top of the directory list.
3. Create an empty project, add a main. cpp file, include common Linux header files, and compile them.
// Content of Main. cpp
# Include <sys/types. h>
# Include <sys/socket. h>
# Include <time. h>
# Include <sys/time. h>
# Include <netinet/in. h>
# Include <ARPA/inet. h>
# Include <errno. h>
# Include <fcntl. h>
# Include <netdb. h>
# Include <signal. h>
# Include <stdio. h>
# Include <stdlib. h>
# Include <string. h>
# Include <sys/STAT. h>
# Include <sys/uio. h>
# Include <unistd. h>
# Include <sys/Wait. H>
# Include <sys/UN. h>
# Include <sys/select. h>
# Include <sys/Param. h>
# Include <sys/poll. h>
# Include <strings. h>
# Include <sys/IOCTL. h>
# Include <pthread. h>
# Include <syslog. h>
# Include <termios. h>
# Include <GRP. h>
# Include <PWD. h>
# Include <sys/resource. h>
# Include <setjmp. h>
# Include <sys/Mman. h>
# Include <sys/IPC. h>
# Include <sys/msg. h>
# Include <Linux/dirent. h>
# Include <Linux/unistd. h>
# Include <sys/SEM. h>
# Include <sys/SHM. h>
# Include <sys/utsname. h>
# Include <utime. h>
# Include <sys/Wait. H>
Int main (INT argc, char * argv [])
{
Return 0;
}

The following errors occur during compilation:
1. bits/types. H (31): Fatal error c1083: Unable to open the contained file: "stddef. h": no such file or directory
The stddef. h file is not found.
This file is found in the/Linux directory, and the Linux directory is added to the include directory.

2. bits/in. H (69): Error c2380: type before "ip_opts" (does the constructor have a return type or an invalid redefinition of the current type name ?)
Because
Struct ip_opts
{
Struct in_addr ip_dst;/* first hop; zero without source route .*/
Char ip_opts [40];/* actually variable in size .*/
}; The member name is the same as the structure name, which is considered incorrect by VC. Therefore, the member name must be changed to ip_opta.

3. gcchead/include/stdarg. H (43): Error c2146: syntax error: ";" missing (before the identifier "_ gnuc_va_list)
Typedef _ builtin_va_list _ gnuc_va_list;
Because the _ builtin_va_list type does not exist
Typedef void * _ gnuc_va_list;

4. stdlib. H (833): Error c2065: "wchar_t": Undeclared identifier
Extern int mbtowc (wchar_t * _ restrict _ PwC,
_ Const char * _ restrict _ s, size_t _ n) _ Throw;
Add a sentence
# Include "Linux/NLS. H"

5. Linux/NLS. H (7): Error c2146: syntax error: ";" missing (before the identifier "wchar_t)
Typedef _ 2010wchar_t;
Add
# Include "ASM/types. H"

6. ASM/types. H (11): Error c2144: syntax error: "char" should be preceded by ";"
Typedef _ signed _ char _ S8;
Add a sentence # DEFINE _ signed

7. Linux/dirent. H (6): Error c2146: syntax error: ";" missing (before identifier "d_off)
_ Kernel_off_t d_off;
Add a line # include "ASM/posix_types.h"

8. Linux/dirent. H (12): Error c2146: syntax error: ";" missing (before the identifier "d_ino)
_ U64 d_ino;
Add a line # include "ASM/types. H"
Add two lines in the ASM/types. h file.
Typedef _ signed _ long _ s64;
Typedef unsigned long _ u64;

After the above problem is solved, the compilation passes.

P.s has told me that magic C ++ can also implement the functions I need without limit. However, after I downloaded his 4.0 version, I had a lot of problems and finally ended up failing.
So I had to "do it myself, please"

 

 

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.