Compare the compilation of Linux and UNIX-general Linux technology-Linux programming and kernel information. The following is a detailed description. In Unix, cc is usually used for compilation. in LINUX, most software is compiled using gcc, and the compilation parameters are different in detail.
Only list one or two:
1.-lsocket
If a socket is used in unix,-lsocket must be added to makefile, which is no longer required in linux, because libc. so in linux contains socket-related content.
2. Compile to so
$ {CC}-o $ @-shared-fPIC $ {OBJECT}
-Shared this option specifies to generate a dynamic Connection Library (let the connector generate a T-type export symbol table, sometimes also generate a weak connection W type export symbol), without this sign external programs cannot connect, it is equivalent to an executable file.
-FPIC: indicates that the compiled code is in a separate position. If this option is not used, the compiled code is location-related. Therefore, during dynamic loading, the code is copied to meet the needs of different processes, but cannot achieve the purpose of truly sharing code segments.
3. Use so
-L $ {HOME}/lib-lxml
-L $ {HOME}/lib: indicates that the library to be connected is in $ HOME/lib.
-Lxml: an implicit naming rule is used by the compiler to search for a dynamically connected library. That is, the Library name is determined by adding lib before the given name and. so, for example, libxml. so.
LD_LIBRARY_PATH: The environment variable indicates the path where the dynamic connector can load the dynamic library.
4. main () function
Gcc requires that 'main' must return 'int'. cc does not have this requirement.
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