06.02.2013 Views

ARM Compiler toolchain Using the Linker - ARM Information Center

ARM Compiler toolchain Using the Linker - ARM Information Center

ARM Compiler toolchain Using the Linker - ARM Information Center

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4.25 Specifying user libraries when linking<br />

4.25.1 See also<br />

Image structure and generation<br />

To specify user libraries:<br />

• include <strong>the</strong>m with path information explicitly in <strong>the</strong> input file list<br />

• add <strong>the</strong> --userlibpath option to <strong>the</strong> armlink command line with a comma-separated list of<br />

directories, and <strong>the</strong>n specify <strong>the</strong> names of <strong>the</strong> libraries as input files.<br />

You can use <strong>the</strong> --library=name option to specify static libraries, libname.a, or dynamic shared<br />

objects, libname.so. Dynamic searching is controlled by <strong>the</strong> --search_dynamic_libraries option.<br />

For example, <strong>the</strong> following command searches for libfoo.so before libfoo.a:<br />

armlink --arm_linux --shared --fpic --search_dynamic_libraries --library=foo<br />

If you do not specify a full path name to a library on <strong>the</strong> command line, <strong>the</strong> linker tries to locate<br />

<strong>the</strong> library in <strong>the</strong> directories specified by <strong>the</strong> --userlibpath option. For example, if <strong>the</strong> directory<br />

/mylib contains my_lib.a and o<strong>the</strong>r_lib.a, add /mylib/my_lib.a to <strong>the</strong> input file list with <strong>the</strong><br />

command:<br />

armlink --userlibpath /mylib my_lib.a *.o<br />

If you add a particular member from a library this does not add <strong>the</strong> library to <strong>the</strong> list of<br />

searchable libraries used by <strong>the</strong> linker. To load a specific member and add <strong>the</strong> library to <strong>the</strong> list<br />

of searchable libraries include <strong>the</strong> library filename on its own as well as specifying<br />

library(member). For example, to load strcmp.o and place mystring.lib on <strong>the</strong> searchable library<br />

list add <strong>the</strong> following to <strong>the</strong> input file list:<br />

mystring.lib(strcmp.o) mystring.lib<br />

Note<br />

Any search paths used for <strong>the</strong> <strong>ARM</strong> standard libraries specified by ei<strong>the</strong>r <strong>the</strong> linker<br />

command-line option --libpath or <strong>the</strong> <strong>ARM</strong>LIB or <strong>ARM</strong>CC41LIB environment variables are not<br />

searched for user libraries.<br />

Tasks<br />

• Controlling how <strong>the</strong> linker searches for <strong>the</strong> <strong>ARM</strong> standard libraries on page 4-36.<br />

Reference<br />

<strong>Linker</strong> Reference:<br />

• --libpath=pathlist on page 2-96<br />

• --library=name on page 2-97<br />

• --search_dynamic_libraries, --no_search_dynamic_libraries on page 2-144<br />

• --userlibpath=pathlist on page 2-179.<br />

<strong>ARM</strong> ® C and C++ Libraries and Floating-Point Support Reference:<br />

• Chapter 2 The C and C++ libraries.<br />

Introducing <strong>the</strong> <strong>ARM</strong> <strong>Compiler</strong> <strong>toolchain</strong>:<br />

• Toolchain environment variables on page 2-14.<br />

<strong>ARM</strong> DUI 0474C Copyright © 2010-2011 <strong>ARM</strong>. All rights reserved. 4-38<br />

ID080411 Non-Confidential

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!