Linux GCC Compilation Diary

Source: Internet
Author: User
Tags openssl

The GCC compiler is a combination of many compiler portals, such as when compiling a. cpp file, using the C + + compiler, when compiling. c files.

When compiling a C + + program, the library file and header file can be specified by-l[dir],-l[name] Specifies the name of the library file. When specifying the name of a library file, you follow the specified paradigm. For example, the library file libabc.a, [lib]abc[.a] in the brackets section of the default, this time the library file name is called: ABC, so at the time of GCC compilation, through the-LABC to load the library.

Typically a C + + program uses a standard library, such as a string in your code
#include <string>

using namespace Std;

At compile time, you will encounter fatal error:string:No such file or directory compilation terminated, because standard library code is used in the code, and the library is not included at compile time. The C + + standard (static/dynamic) library name is: LIBSTDC++.A, libstdc++.so, so the compile-time GCC directive attaches-lstdc++

gcc-i/usr/include/openssl/-wall Testzs.cpp-o testzsexe-lcrypto-ldl-lstdc++

This directive contains 3 libraries, and the-O output compiles as follows: Testzsexe,-wall represents the output compilation warning message, if-wall is changed to-werror, it stops compiling when a warning message is encountered. -i specifies the path to the library header file. In this case, you can also not specify the/I directive. Because/usr/include is the system default header file path. Use #include <openssl/....h> in your code.

When the window platform code moves the value to Linux, it encounters the following exception: Fopen_s?was not declared in this SCOP, no fopen_s (...) in Linux function, so either start with the fopen function of the Linux platform, or re-implement the fopen_s function.

Linux GCC Compilation journal

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.