[Previous] [Contents] [Index] [Next]

QCC, qcc

Compile command (QNX Neutrino, QNX 4)

Syntax:

For C:

qcc [options] [operands]

For C++:

QCC [options] [operands]

Options:

-A library[.a]
Build a new archive.
-a library[.a]
Add to the given archive.
-ansi
Compile strict ANSI code.
-Bstatic
Link statically against any subsequent libraries on the command line.
-Bdynamic
Link dynamically against any subsequent libraries on the command line.
-C
Preprocessor leaves comments.
-c
Compile only.
-D name[=value]
Define the symbol name, optionally setting its value.
-E
Preprocess to stdout.
-EB
-EL
Compile for big or little endian.
-g
Compile with debug.
-I path[:path ...]
Set the search path for #include directives.
-L path[:path ...]
Set the library search path.
Note: The development tools have been designed to work out of their processor directories (x86, ppcbe, etc.). This means you can use the same tool set for any target platform.

If you have development libraries for a certain platform, put them into the platform-specific library directory (e.g. /x86/lib), which is where the compiler tools look by default. Don't put the libraries in /lib or /usr/lib, which are ignored. Alternatively, use the -L option to specify the libraries' location.


-l library
("el") Add library.
-lang-c
Treat as C (the default for qcc).
-lang-c++
Treat as C++ (the default for QCC).
Note: You need to link C++ programs with the -lang-c++ option in order for exceptions to work.

-M
Generate a mapfile called output_file.map.
-N stacksize[K]
Specify the stack size, in bytes or kilobytes.
-n
Don't execute.
-nopipe
Use temporary files rather than pipes between phases.
-nostartup
Don't use ld_startup_* sections.
-nostdinc
Don't include the standard C include paths.
-nostdinc++
Don't include the standard C++ include paths.
-nostdlib
Don't use the ld_stdlib section.
-nostdlib++
Don't use the ld_stdlib++ section.
-O
Do compile-phase optimization.
-o outfile
Specify the name of the output file. The default is a.out.
Note: Note that the make utility, when used with the default settings, produces an output file with the same name as the input file. For example:
make file1
    

results in the executable output file file1.


-P
Preprocess to file.i (C) or file.ii (C++).
-p
Compile with profiling; see "Profiling," below.
-S
Compile, leave assembly in file.s.
-set-default
Set the current -V argument as the default target. For example:
qcc -V3.3.1,gcc_ntoppcbe -set-default

will set GCC 3.3.1 for PPC big-endian as the default.


Note: You must be root to use the -set-default option. Note also that the option is intended for use at the command line, not for makefiles.

-shared
When compiling, make the object position-independent so that it's suitable for inclusion in a shared object. When linking, combine the modules into a shared object.
-static
Link against static libraries only.
-U name
Undefine the given symbol.
-V [[compiler/]version,][target]
The compiler name, version number, and the target name. If you don't specify -V at all, qcc will use the default compiler, version, and target.

If you specify the target, qcc looks for the target configuration files in the following paths, according to how compiler, version, and target are specified:

If you specify: qcc looks here:
-Vtarget ${QCC_CONF_PATH}/compiler/version (where compiler is inferred from target, and version is the default).
-Vversion,target ${QCC_CONF_PATH}/compiler/version (where compiler is inferred from target; if that path doesn't exist, or if version contains a slash [/], then ${QCC_CONF_PATH}/version is used).
-Vcompiler,target ${QCC_CONF_PATH}/compiler/version (where version is the specified compiler's default version).
-Vcompiler/version,target ${QCC_CONF_PATH}/compiler/version

For example, this command:

qcc -Vgcc,

lists all targets in all versions of gcc. See the Examples section below for more examples.

The targets include:

For a list of supported targets, specify -V (or -Vcompiler or -Vcompiler/version or -Vversion, provided there's a valid ${QCC_CONF_PATH}/version directory).

-v[v]
Operate verbosely (the second v turns on verbosity in the compiler).
-W phase,arg[,arg ...]
Pass the specified option and its arguments through to a specific phase:

For example, if you want to pass the -MD option to the compiler, specify -Wc,-MD on the command line for qcc.

-w
Suppress all warnings (same as -w0).
Note: If you specify -w along with multiple warning options, all warnings are suppressed regardless of the order of the options. In other words, -w always wins.

-w[0-9]
Set the warning level (0=off).
-x extension
Treat the files that follow as being of type extension. The following values of extension are accepted:

as well as valid file extensions, such as .c, .cc, .cpp, .C, .i, .ii, .s, and .S.

Use -xnone to go back to normal suffix typing. For example, to compile myfile.h as if it were a .c file:

qcc -xc myfile.h
  
-Y lib_type
Select the C++ library type to be used (if available), lib_type can be:

Description:

QCC and qcc are the QNX compiler interface. They're based on the POSIX c89 utility. By default, QCC considers a program to be C++, while qcc considers it to be C.

QCC and qcc take a list of source and object modules on the command line and invokes the appropriate parser to compile each file. Object modules are passed straight through to the linker. The file suffix determines which parser is used, as follows:

Suffix Parser
.s Assembler
.S Assembler with preprocessor directives
.c C compiler
.i Preprocessed C file
.C, .cc, .cpp C++ compiler
.ii Preprocessed C++ file
.o Object file
.a Library file

These utilities don't allow multiple options to be specified after a dash character (-). For example, -gc isn't valid; you must specify -g -c instead. Operands (source and object files) and options may be mixed and specified in any order. Some options, such as -I and -L, are order-dependent -- the order in which they appear in the command line determines the order of the searches made. All command-line arguments are processed before any compilation or linking begins.


Note: The single-pass linker resolves symbols from left to right: If a module refers to a symbol that is contained in a library, make sure you specify the library to the right of the module.

When qcc encounters a compilation error that stops an object file from being created, it writes a diagnostic to the standard error and continues to compile other source files, but it bypasses the link phase and returns a nonzero exit status. If the link phase is entered and is unsuccessful, a diagnostic is written and qcc exits with a nonzero status.

The -c option suppresses the link phase. If you have many separate source files that you must update and modify individually, you'll probably use the -c option frequently.

You may occasionally wish to examine the assembly code produced by the code generator. The -S option produces an assembly file ending in .s.

If you need to specify a parameter to any of the language processors, you may use the -W c,option. Check the documentation on each processor to determine its options.

The compiler defines various manifests that can help you make decisions at compile time. For more information, see the Manifest functions chapter of the Library Reference.

Profiling

Here's how to profile your application, so you can see where it's spending its time:

  1. Compile and link your application with profiling by using the -p option to qcc. For example:
    make CCOPTS+=-p LDOPTS+=-p
      
  2. Slay qconn, or it will redirect the output.
  3. Run your application as root (this is important because the timers are privileged). The result of this run is a file called gmon.out, in your program's current working directory when it exits.
  4. Look at the profiled output with the command:
    gprof [your_app] | less
      

For more information, see the GNU documentation for gprof, and Profiling an Application in the IDE User's Guide.

Examples:

Compile myfile.c and create a 32-bit executable program for QNX Neutrino on an Intel x86 machine in the current directory with the name a.out:

qcc -Vgcc_ntox86 myfile.c

Compile myfile.c and create a 32-bit executable program for QNX Neutrino on an Intel x86 machine in the current directory with the name myfile:

qcc -Vgcc_ntox86 -o myfile myfile.c

Use the default compiler, version, and target:

qcc

Note: For QNX Momentics 6.3, the default compiler is gcc, the default version of the compiler is 2.95.3, and the default target is ntox86.

Use the default version of the compiler, and build for an ARM little-endian target:

qcc -Vgcc_ntoarmle

Use the 3.3.1 version of the compiler, and build for a PPC big-endian target:

qcc -V3.3.1,gcc_ntoppcbe

Use make to compile myfile.c and create an executable program in the current directory with the name myfile:

make myfile

Note: You can't use the default rules for make -- you need to specify the target. See make.

Make a shared library:

qcc -Vgcc_ntox86 -shared -c shared.c
qcc -Vgcc_ntox86 -shared -o libshared.so shared.o

Files:

a.out
The default output file. You can use the -o option to override this.
Configuration files:
${QCC_CONF_PATH}/version/*.conf
${QCC_CONF_PATH}/default
${QCC_CONF_PATH}/gcc/default
${QCC_CONF_PATH}/gcc/version/default

Environment variables:

QCC_CONF_PATH
The name of the directory that contains the configuration files. The default directory is ${QNX_HOST}/etc/qcc.

Exit status:

0
Success.
>0
An error occurred.

See also:

make

Manifest functions chapter of the Library Reference


[Previous] [Contents] [Index] [Next]