[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

 

Chapter 2.

 

Help and General Information



This chapter tells you how to get started with the command-line tools. It gives you information on the names of the tools, and how to invoke the tools in such a way that you see help information.


About Command-Line Compilers and Linkers

The CodeWarrior development environment supports several platforms as targets for your code. Metrowerks provides tools you can use in command-line environments so that you can directly invoke the compilers, linkers, and assemblers frfom the command line.

The command-line tools are very similar between the different Metrowerks-supported targets. In other words, many command-line options for the Win32 x86 tools will be the same for the Embedded PowerPC tools.

The sections in this chapter include:


Tool Naming Conventions

The way the command-line tools are named is as follows:


  mw<tool><arch|OS>

where <tool> is cc for the C/C++ compiler, ld for the linker, and asm for the assembler.

<arch|OS> is usually the target processor except where there are multiple versions of tools for an architecture.

For example, for Embedded PowerPC, the <arch|OS> is eppc (mwcceppc, mwldeppc, mwasmeppc).

For Win/x86, the <arch|OS> is empty (mwcc, mwld, mwasm).


Working with Environment Variables

To use the command-line tools, several environment variables must be changed or defined. This may be done in the autoexec.bat file in Windows 95/98 or in the Environment tab under the System control panel in Windows NT.

The topics in this section include:


The CWFolder Environment Variable

In this example, %CWFolder% refers to the path where CodeWarrior for Embedded PowerPC was installed. Note that it is not necessary to include quote marks when defining environment variables that include spaces. Windows does not strip out the quotes and this leads to unknown directory warnings. Use the following syntax if defining variables in batch files or at the command line:


set CWFolder=C:\Program Files\Metrowerks\CodeWarrior


Setting the PATH Environment Variable

In this example, the PATH variable should include the following two paths for the Embedded PowerPC tools (other tools will be different, check the release notes):


%CWFolder%\Bin
%CWFolder%\EPPC_Tools\Command_Line_Tools

The first path contains the FlexLM license manager DLL, and the second path contains the tools.

In order for FlexLM to work properly, you can simply copy the following file into the directory from which you will be using the command line tools:


  ..\CodeWarrior\license.dat

Alternately, you can define the variable LM_LICENSE_FILE as:


  %CWFolder%\license.dat

This variable points to license information. It may point to alternate versions of this file, as needed.


Search Path Environment Variables

Several environment variables are used at runtime to search for system include paths and libraries which can shorten command lines for many tasks. All of the variables mentioned here are lists which are separated by semicolons (';') in Windows and colons (':') in Solaris.

For example, in Embedded PowerPC, unless -nodefaults is passed to on the command line, the compiler searches for an environment variable called MWCEABIPPCIncludes or MWCIncludes (in that order). These variables contain a list of system access paths to be searched after the system access paths specified by the user. The assembler also does this, using the variables MWAsmEABIPPCIncludes or MWAsmIncludes.

Analogously, unless -nodefaults or -disassemble is given, the linker will search the environment for a list of system access paths and system library files to be added to the end of the search and link orders. For example, with Embedded PowerPC, the variable MWEABIPPCLibraries or MWLibraries contains a list of system library paths to search for files, libraries, and command files.

Associated with this list is the variable MWEABIPPCLibraryFiles or MWLibraryFiles which contains a list of libraries (or object files or command files) to add to the end of the link order. These files may be located in any of the cumulative access paths at runtime.

If you are only building for one target, it is okay to use MWCIncludes, MWAsmIncludes, MWLibraries, and MWLibraryFiles. The target-specific versions of the variables come in handy when targeting multiple targets, since the target-specific variables override the generic variables. Note that if the target-specific variable exists, the generic variable will not be used; the contents of the two variables will not be combined.


A Word about File Extensions

Files specified on the command line are identified by contents and file extension, as in the CodeWarrior IDE.

The C/C++ compiler will accept non-standard file extensions as source but will emit a warning. By default, the compiler assumes that a file with any extensions besides .c, .h, .pch is C++ source. The linker must be able to identify all files as object code, libraries, or command files, or else they will be ignored.

Linker command files must end in .lcf. They may be simply added to the link line, for example, for Embedded PowerPC:


     mwldeppc file.o lib.a commandfile.lcf

For more information on linker command files, refer to the Targeting manual for your platform.


Help and Administrative Options

This section contains information on general and help information available from the tools on the command line. It gives a general example of how to retrieve information on the tools interactively from the command line.

For example, to obtain help information from a tool that has some compatibility options with Visual C++, invoke the tool like this:


  mwcc /?

Another way to get more specific information from a tool is to invoke it like this:


  mwcc /help [keyword,...]

In this example, keyword is something like usage, all, this or some other valid keyword.

For example:


  mwcc /help usage

or:


  mwcc /help opt=help

provides information about the help options available for use with the mwcc Win32 x86 tool.


Command-Line Settings Conventions

The Metrowerks command line compilers translate source code (for example, C and C++) into object code. Object code generated by these compilers is processed by the Metrowerks command line linkers to produce executable objects like applications, dynamic link libraries (DLLs), code resources, and static libraries.

Each compiler has various options that you can set. If you are familiar with the CodeWarrior development environment you will see that many of these options correspond to settings in the CodeWarrior target settings dialogs.

This chapter organizes information into these topics:

In all cases, text in braces-the [ and ] characters-is optional. The braces themselves never appear in the actual command. For example, you could write -str[ings] pool as either


  -strings pool

or


  -str pool

Where an option has several possible permutations, the possibilities are separated by a pipe-the | character. For example:


  -sym on|off|full|fullpath

reflects the fact that the -sym command may be followed by one or more of four possibilities. So you might have -sym on, -sym off, -sym full, or -sym on, fullpath.

The + (plus sign) it means that the parameter to an option must "stick" to the option name and not be separated by a space. For example, /D+name[=value] means that you should specify
/DVAR or /DVAR=3, but not /D VAR.

In cases where you provide a variable parameter, like a file name, that item is in italic text. For example, -precompile filename means you must provide a file name. The explanation that accompanies each compiler option makes it clear what you must provide.


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: July 20, 2000