• cygwin Mingw


    cygwin is a unix-like enviroment and command-line interface for microsoft windows.

    cygwin is huge and includes most of the Unix tools and utilities. It also include the commonly used Bash shell.b

    for c ,use gcc 

    for c++,use g++

    below is an example

    for hello.c. if the main function have parameter,than just put the paramter value after the executable file(below is hello.exe).

    > gcc -o hello.exe hello.c    //NT
      // Compile and link source file hello.c into executable hello.exe
    > hello
      // Execute hello.exe under CMD shell

    NT:after -o,place hello.exe ahead,not hello.c
    More GCC Compiler Options

    A few commonly-used GCC compiler options are:

    $ g++ -Wall -g -o Hello.exe Hello.cpp
    • -o: specifies the output executable filename.
    • -Wall: prints "allwarning messages.
    • -g: generates additional symbolic debugging information for use with gdb debugger.
    Compile and Link Separately

    The above command compile the source file into object file and link with other object files (system library) into executable in one step. You may separate compile and link in two steps as follows:

    // Compile-only with -c option
    > g++ -c -Wall -g Hello.cpp
    // Link object file(s) into an executable
    > g++ -g -o Hello.exe Hello.o

    The options are:

    • -ccompile into object file "Hello.o". By default, the object file has the same name as the source file with extension of ".o" (there is no need to specify -o option). No linking with other object file or library.
    • Linking is performed when the input file are object files ".o" (instead of source file ".cpp" or ".c"). GCC uses a separate linker program (calledld.exe) to perform the linking.
    Compile and Link Multiple Source Files

    Suppose that your program has two source files: file1.cppfile2.cpp. You could compile all of them in a single command:

    > g++ -o myprog.exe file1.cpp file2.cpp 

    However, we usually compile each of the source files separately into object file, and link them together in the later stage. In this case, changes in one file does not require re-compilation of the other files.

    > g++ -c file1.cpp
    > g++ -c file2.cpp
    > g++ -o myprog.exe file1.o file2.o
    Compile into a Shared Library

    To compile and link C/C++ program into a shared libary (".dll" in Windows, ".so" in Unixes), use -shared option. Read "Java Native Interface" for example.

    1.4  GCC Compilation Process

    GCC compiles a C/C++ program into executable in 4 steps as shown in the above diagram. For example, a "gcc -o hello.exe hello.c" is carried out as follows:

    Verbose Mode (-v)

    You can see the detailed compilation process by enabling -v (verbose) option. For example,

    > gcc -v hello.c -o hello.exe

    above from below link:  

    GCC and Make:  Compiling, Linking and Building C/C++ Applications

    http://www3.ntu.edu.sg/home/ehchua/programming/cpp/gcc_make.html

    •  
    • Cygwin User's Guide

    http://cygwin.com/cygwin-ug-net/cygwin-ug-net.html 

  • 相关阅读:
    tf.placeholder函数说明
    网易雷火 游戏研发一面 5.7
    【python3】with的用法
    一分钟理解softmax函数(超简单)
    网易雷火 笔试 4.25
    cun
    HDU-2045-RPG上色(递推)
    HDU-2050-折线分割平面 (递推)
    POJ-2389-Bull Math(高精度乘法)
    HDU-1002-A + B Problem II(高精度加法)
  • 原文地址:https://www.cnblogs.com/aprilapril/p/2909263.html
Copyright © 2020-2023  润新知