Caution: This version of this document is no longer maintained. For the latest documentation, see http://www.qnx.com/developers/docs.

gcc

Compile and link a program (GNU)


Note: We recommend you use qcc instead of invoking gcc directly. You can use the -V option to qcc to invoke gcc. For example:
qcc -Vgcc_ntoarmle my_file.c

Syntax:

gcc_variant [ option | filename ]...
g++_variant [ option | filename ]...

Runs on:

All supported hosts.

Options:

The gcc_variant depends on the target platform, as follows:

Target platform: gcc_variant:
ARM ntoarm-gcc
PowerPC ntoppc-gcc
SH4 ntosh-gcc
x86 ntox86-gcc

The g++_variant depends on the target platform, as follows:

Target platform: g++_variant:
ARM ntoarm-g++
PowerPC ntoppc-g++
SH4 ntosh-g++
x86 ntox86-g++

QNX Neutrino cross-development options

-b [ntox86  | ntoppc | ntosh]

Overall options

-c  -S  -E  -o file  -pipe  -v  -x language

C language options

-ansi  -fallow-single-precision  -fcond-mismatch  
-fno-asm  -fno-builtin  -ffreestanding  -fhosted  
-fsigned-bitfields  -fsigned-char  
-funsigned-bitfields  -funsigned-char  
-fwritable-strings  -traditional  -traditional-cpp  
-trigraphs

C++ language options

-fall-virtual  -fdollars-in-identifiers  
-felide-constructors  -fenum-int-equiv  
-fexternal-templates  -ffor-scope  -fno-for-scope
-fhandle-signatures  -fmemoize-lookups  
-fname-mangling-version-n  -fno-default-inline  
-fno-gnu-keywords -fnonnull-objects -fguiding-decls
-foperator-names  -fstrict-prototype  -fthis-is-variable
-ftemplate-depth-n  -nostdinc++  -traditional  +en

Warning options

-fsyntax-only  -pedantic  -pedantic-errors
-w  -W  -Wall  -Waggregate-return  
-Wbad-function-cast  -Wcast-align  -Wcast-qual  
-Wchar-subscript  -Wcomment  -Wconversion  -Werror  
-Wformat  -Wid-clash-len  -Wimplicit -Wimplicit-int 
-Wimplicit-function-declarations -Wimport  -Winline
-Wlarger-than-len  -Wmain  -Wmissing-declarations
-Wmissing-prototypes  -Wnested-externs
-Wno-import  -Wold-style-cast  -Woverloaded-virtual  
-Wparentheses  -Wpointer-arith  -Wredundant-decls  
-Wreorder  -Wreturn-type  -Wshadow  -Wsign-compare  
-Wstrict-prototypes  -Wswitch  -Wsynth
-Wtemplate-debugging  -Wtraditional  -Wtrigraphs
-Wundef  -Wuninitialized  -Wunused  -Wwrite-strings

Debugging options

-a  -ax  -dletters  -fpretend-float
-fprofile-arcs  -ftest-coverage
-g  -glevel  -gcoff  -gdwarf  -gdwarf-1  -gdwarf-1+  
-gdwarf-2  -ggdb  -gstabs  -gstabs+  -gxcoff  -gxcoff+
-p  -pg  -print-file-name=library  
-print-libgcc-file-name  -print-prog-name=program  
-print-search-dirs  -save-temps

QNX extension:

-MAP

Optimization options

-fbranch-probabilities
-fcaller-saves  -fcse-follow-jumps  -fcse-skip-blocks
-fdelayed-branch   -fexpensive-optimizations
-ffast-math  -ffloat-store  -fforce-addr  -fforce-mem
-ffunction-sections  -finline-functions
-fkeep-inline-functions  -fno-default-inline
-fno-defer-pop  -fno-function-cse
-fno-inline  -fno-peephole  -fomit-frame-pointer
-frerun-cse-after-loop  -fschedule-insns
-fschedule-insns2  -fstrength-reduce  -fthread-jumps
-funroll-all-loops  -funroll-loops
-O  -O0  -O1  -O2  -O3

Preprocessor options

-Aquestion(answer)  -C  -dD  -dM  -dN
-Dmacro[=defn]  -E  -H
-idirafter dir
-include file  -imacros file
-iprefix file  -iwithprefix dir
-iwithprefixbefore dir  -isystem dir
-M  -MD  -MM  -MMD  -MG  -nostdinc  -P  -trigraphs
-undef  -Umacro  -Wp,option

Assembler option

-Wa,option

Linker options

object-file-name  -llibrary
-nostartfiles  -nodefaultlibs  -nostdlib
-s  -static  -shared  -symbolic
-Wl,option  -Xlinker option
-u symbol

Directory options

-Bprefix  -Idir  -I-  -Ldir  -specs=file

Target options

-b machine  -V version

Machine-dependent options

PowerPC options:

-mcpu=cpu type
-mtune=cpu type
-mpower  -mno-power  -mpower2  -mno-power2
-mpowerpc  -mno-powerpc
-mpowerpc-gpopt  -mno-powerpc-gpopt
-mpowerpc-gfxopt  -mno-powerpc-gfxopt
-mnew-mnemonics  -mno-new-mnemonics
-mfull-toc   -mminimal-toc  -mno-fop-in-toc  
-mno-sum-in-toc  -mxl-call  -mno-xl-call  -mthreads  
-mpe -msoft-float  -mhard-float  -mmultiple  
-mno-multiple  -mstring  -mno-string  -mupdate  
-mno-update  -mfused-madd  -mno-fused-madd  
-mbit-align  -mno-bit-align
-mstrict-align  -mno-strict-align  -mrelocatable
-mno-relocatable  -mrelocatable-lib  
-mno-relocatable-lib
-mtoc  -mno-toc  -mtraceback  -mno-traceback
-mlittle  -mlittle-endian  -mbig  -mbig-endian
-mcall-aix  -mcall-sysv  -mprototype  -mno-prototype
-msim  -mmvme  -mads  -myellowknife  -memb
-msdata  -msdata=opt  -G num

i386 options:

-mcpu=cpu type
-march=cpu type
-mieee-fp  -mno-fancy-math-387
-mno-fp-ret-in-387  -msoft-float  -msvr3-shlib
-mno-wide-multiply  -mrtd  -malign-double
-mreg-alloc=list  -mregparm=num
-malign-jumps=num  -malign-loops=num
-malign-functions=num

SH options:

-m1 -m2 -m3 -m3e -m4
-ml -mb
-mdalign -mbigtable -mrelax -mspace -msmall

Code-generation options

-fcall-saved-reg  -fcall-used-reg
-ffixed-reg  -finhibit-size-directive
-fcheck-memory-usage  -fprefix-function-name
-fno-common  -fno-ident  -fno-gnu-linker
-fpcc-struct-return  -freg-struct-return
-fshared-data  -fpic  -fPIC  -fexceptions
-fshort-enums  -fshort-double  -fvolatile  
-fvolatile-global  -fverbose-asm  -fpack-struct  
-fstack-check  +e0  +e1

Note: If you use exceptions, you must link with the -lang-c++ option to qcc. This option is the default for QCC.

Description:

We recommend you use qcc or QCC instead of gcc to compile and link your programs.

For detailed documentation about gcc, see the GNU website at http://www.gnu.org/.


Note: If you have trouble using the default debug format (-gdwarf), switch to -gdwarf-2 or -gstabs.

Exit status:

0
Success.
33
A nonfatal compilation error was encountered.
34
A fatal compilation error was encountered.
35
Unable to open a required file.

Contributing author:

GNU

See also:

gcov, gdb, qcc