Hi Peng,

I've also noticed that some options for gcc are not listed in the output of
--help.  I generally look here for help:
https://gcc.gnu.org/onlinedocs/gcc/Option-Summary.html
and then I just try the option I want and see if the compiler accepts it.
Some work, some don't.  I have not found a complete list of what does and
doesn't work with mingw-w64 compilers.

You asked about basic compilation commands.  Below are the basic options
and commands I use for compiling C code.  I use the tools on Windows 10,
but I expect the commands are similar on the Mac.  I will write "gcc" for
the C compiler - you can replace that with x86_64-w64-mingw32-gcc (for
64-bit executable) or with i686-w64-mingw32-gcc (32-bit).

Simplest compile command to get an executable: gcc <list_of_C_files>
Example: say you want to compile main.c, apple.c and orange.c:
> gcc main.c apple.c orange.c
The output of the command is the executable a.exe

You can use the -o option to specify the name of the output file.
For example: as above, but with the output file named fruit.exe:
> gcc main.c apple.c orange.c -o fruit.exe

I like to use the C99 standard, so I also use -std=c99, like this:
> gcc -std=c99 main.c apple.c orange.c -o fruit.exe

You could also compile each .c file individually to an object file using
the -c option:
> gcc -c -std=c99 main.c -o main.obj
> gcc -c -std=c99 apple.c -o apple.obj
> gcc -c -std=c99 orange.c -o orange.obj
... then compile the final executable by giving the object files to the
compiler:
> gcc -std=c99 main.obj apple.obj orange.obj -o fruit.exe

The compiler looks for header files in your current directory and a list of
its own directories.  If you want it to look for a header file in another
directory you can use -I.  For example, say in apple.c you have the line
 #include "apple.h"
and the header file apple.h is in a subdirectory of your current directory
named my_headers.  Then you could do this:
> gcc -c -std=c99 -I "./my_headers" apple.c -o apple.obj

(-I is not listed in the output of --help, at least not on my machine.)

Those are the basic options that I use.  For anything else I search online
for help.

Good luck!

Clint

On Sun, Jan 10, 2021 at 11:52 AM Peng Yu <pengyu...@gmail.com> wrote:

> > > They look like gcc and g++. But their options (according to --help)
> > > are much fewer than the gcc and g++. What are the options are missing
> > > in the *-w64-mingw32-* tools?
> > How are you testing this, and on what system?
>
> I use the --help option of *--w64-mingw32-gcc on Mac OS X.
>
> --
> Regards,
> Peng
>
>
> _______________________________________________
> Mingw-w64-public mailing list
> Mingw-w64-public@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
>

_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to