1 <!-- Copyright (C) 2003 Red Hat, Inc. -->
2 <!-- This material may be distributed only subject to the terms -->
3 <!-- and conditions set forth in the Open Publication License, v1.0 -->
4 <!-- or later (the latest version is presently available at -->
5 <!-- http://www.opencontent.org/openpub/). -->
6 <!-- Distribution of the work or derivative of the work in any -->
7 <!-- standard (paper) book form is prohibited unless prior -->
8 <!-- permission is obtained from the copyright holder. -->
12 >Compiler and Linker Options</TITLE
13 ><meta name="MSSmartTagsPreventParsing" content="TRUE">
16 CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
19 TITLE="eCos User Guide"
20 HREF="ecos-user-guide.html"><LINK
22 TITLE="eCos Programming Concepts and Techniques"
23 HREF="ecos-programming-concepts-and-techniques.html"><LINK
25 TITLE="Application Build Tree"
26 HREF="repository-app-build-tree.html"><LINK
28 TITLE="Compiling a C++ Application"
29 HREF="compiling-cpp-app.html"></HEAD
40 SUMMARY="Header navigation table"
57 HREF="repository-app-build-tree.html"
71 HREF="compiling-cpp-app.html"
84 NAME="COMPILER-AND-LINKER-OPTIONS">Chapter 26. Compiler and Linker Options</H1
94 HREF="compiler-and-linker-options.html#COMPILING-C-APP"
95 >Compiling a C Application</A
99 HREF="compiling-cpp-app.html"
100 >Compiling a C++ Application</A
109 the GNU C and C++ compilers. <SPAN
112 > relies on certain features of these
113 tools such as constructor priority ordering and selective linking
114 which are not part of other toolchains.
120 > options are required for <SPAN
124 and others can be useful. This chapter gives a brief description
125 of the required options as well as some recommended <SPAN
132 > options (described in the <SPAN
142 NAME="COMPILING-C-APP">Compiling a C Application</H1
144 >The following command lines demonstrate the
151 > set of options required to
152 compile and link an <SPAN
155 > program written in C. </P
163 >Remember that when this manual shows
173 you should use the full name of the cross compiler,
185 >. When compiling for the
186 synthetic Linux target, use the native
190 > which must have the features
222 >gcc -o program file.o -L<SPAN
228 >/lib -Ttarget.ld -nostdlib</PRE
239 >Certain targets may require extra options, for example
240 the SPARClite architectures require the option
252 >/examples/Makefile</TT
254 or the “Global compiler flags” option
255 (CYGBLD_GLOBAL_CFLAGS) in your generated
259 > configuration) to see if any extra options are
260 required, and if so, what they are. </P
262 >The following command lines use some other options
263 which are recommended because they use the
264 selective linking feature:</P
283 >/include -I. -ffunction-sections -fdata-sections -g -O2 file.c
289 >gcc -o program file.o -ffunction-sections -fdata-sections -Wl,--gc-sections -g -O2 \
295 >/lib -Ttarget.ld -nostdlib</PRE
308 SUMMARY="Footer navigation table"
319 HREF="repository-app-build-tree.html"
328 HREF="ecos-user-guide.html"
337 HREF="compiling-cpp-app.html"
347 >Application Build Tree</TD
353 HREF="ecos-programming-concepts-and-techniques.html"
361 >Compiling a C++ Application</TD