EmbDev.net

Forum: ARM programming with GCC/GNU tools regarding library file include in winarm


von Vi M. (jothi)


Rate this post
useful
not useful
I am writing program in winarm, ADuC7024. I am include my own library
file. How will include the library file in main file. How will generate
the make file.

von Clifford S. (clifford)


Rate this post
useful
not useful
vi micro wrote:
> I am writing program in winarm, ADuC7024. I am include my own library
> file. How will include the library file in main file. How will generate
> the make file.

Do you mean library file or header file? They are not the same thing,
although libraries normally have an associated header file.

Header files are simply included in source code with the #include
preprocessor directive. You can specify the full path there, or add an
include search path to the compiler options using the -I option.

Libraries to be linked are specified as linker options. If the library
follows teh GNU naming convention of libXXX.a, then it may be linked
with the -lXXX option. Otherwise you can simply specify the full path to
the library. If you don't specify the full path, the path must be added
to the library search paths via the -L linker option.

The compiler is dicymented at: http://gcc.gnu.org/onlinedocs/
The Linker is documeted at:
http://www.gnu.org/software/binutils/manual/ld-2.9.1/ld.html

It is possible to invoke the linker through the compiler, and as such
the linker options are 'passed through'. This is a common approach when
a project comprises a single source module.

Clifford

von Martin Thomas (Guest)


Rate this post
useful
not useful
vi micro wrote:
> I am writing program in winarm, ADuC7024. I am include my own library
> file. How will include the library file in main file. How will generate
> the make file.

If it's a "real" library (something with a filename libxyz.a): see the
Options -l and -L in the gnu gcc- and ld-manuals. With -l the name of
the library is given -L extends the linker's search-patch for libraries.
The name of the library is the filename without the leading "lib" and
the file-extension (example -lxyz for libxyz.a or -lm for libm.a). My
example-applications for the ARM efsl-interfaces might give an idea,
since the efsl can be used as "real" library (libefsl.a) in this
examples. See the makefiles in the code-archive from
http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/efsl_arm/index.html
which demonstrate the use of -l and -L.

(I'm using the term "real" for an ".a"-library since it seems that the
term library is often used for driver source-code (.c/.cpp-files. i.e.
"UART-library", "LCD-libary") which is compiled togehter with the
application-source. With "real" library I mean an object-code-collection
in an "lib*.a"-file.)

Martin Thomas

von Vi M. (jothi)


Rate this post
useful
not useful
Clifford Slocombe wrote:
> vi micro wrote:
>> I am writing program in winarm, ADuC7024. I am include my own library
>> file. How will include the library file in main file. How will generate
>> the make file.
>
> Do you mean library file or header file? They are not the same thing,
> although libraries normally have an associated header file.
>
> Header files are simply included in source code with the #include
> preprocessor directive. You can specify the full path there, or add an
> include search path to the compiler options using the -I option.
>
> Libraries to be linked are specified as linker options. If the library
> follows teh GNU naming convention of libXXX.a, then it may be linked
> with the -lXXX option. Otherwise you can simply specify the full path to
> the library. If you don't specify the full path, the path must be added
> to the library search paths via the -L linker option.
>
> The compiler is dicymented at: http://gcc.gnu.org/onlinedocs/
> The Linker is documeted at:
> http://www.gnu.org/software/binutils/manual/ld-2.9.1/ld.html
>
> It is possible to invoke the linker through the compiler, and as such
> the linker options are 'passed through'. This is a common approach when
> a project comprises a single source module.
>
> Clifford



I am using the -L option also. But the linker is generating the follow
error


Linking: test.elf
arm-elf-gcc -mthumb -mcpu=arm7tdmi -mthumb-interwork -I. -gstabs
-DROM_RUN  -Os -Wall -Wcast-align -Wcast-qual -Wimplicit
-Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow
-Wunused -Wa,-adhlns=Startup.lst   -MD -MP -MF .dep/test.elf.d Startup.o
test.o syscalls_7024.o     --output -Wl,-Map=test.map,--cref  -lm  -lc
-lgcc  -lstdc++ -lad7024  -TADuC702X-ROM.ld
c:/winarm/bin/../lib/gcc/arm-elf/4.1.0/../../../../arm-elf/lib/thumb/int 
erwork\libc.a(exit.o):
In function `exit':exit.c:(.text+0x1a): undefined reference to `_exit'
collect2: ld returned 1 exit status
make.exe: *** [test.elf] Error 1


Please reply as the proble

von Vi M. (jothi)


Rate this post
useful
not useful
Martin Thomas wrote:
> vi micro wrote:
>> I am writing program in winarm, ADuC7024. I am include my own library
>> file. How will include the library file in main file. How will generate
>> the make file.
>
> If it's a "real" library (something with a filename libxyz.a): see the
> Options -l and -L in the gnu gcc- and ld-manuals. With -l the name of
> the library is given -L extends the linker's search-patch for libraries.
> The name of the library is the filename without the leading "lib" and
> the file-extension (example -lxyz for libxyz.a or -lm for libm.a). My
> example-applications for the ARM efsl-interfaces might give an idea,
> since the efsl can be used as "real" library (libefsl.a) in this
> examples. See the makefiles in the code-archive from
> http://www.siwawi.arubi.uni-kl.de/avr_projects/arm_projects/efsl_arm/index.html
> which demonstrate the use of -l and -L.
>
> (I'm using the term "real" for an ".a"-library since it seems that the
> term library is often used for driver source-code (.c/.cpp-files. i.e.
> "UART-library", "LCD-libary") which is compiled togehter with the
> application-source. With "real" library I mean an object-code-collection
> in an "lib*.a"-file.)
>
> Martin Thomas



I am using the -L option also. But the linker is generating the follow
error


Linking: test.elf
arm-elf-gcc -mthumb -mcpu=arm7tdmi -mthumb-interwork -I. -gstabs
-DROM_RUN  -Os -Wall -Wcast-align -Wcast-qual -Wimplicit
-Wpointer-arith -Wswitch -Wredundant-decls -Wreturn-type -Wshadow
-Wunused -Wa,-adhlns=Startup.lst   -MD -MP -MF .dep/test.elf.d Startup.o
test.o syscalls_7024.o     --output -Wl,-Map=test.map,--cref  -lm  -lc
-lgcc  -lstdc++ -lad7024  -TADuC702X-ROM.ld
c:/winarm/bin/../lib/gcc/arm-elf/4.1.0/../../../../arm-elf/lib/thumb/int 
erwork\libc.a(exit.o):
In function `exit':exit.c:(.text+0x1a): undefined reference to `_exit'
collect2: ld returned 1 exit status
make.exe: *** [test.elf] Error 1


Please reply as the problem

von Clifford S. (clifford)


Rate this post
useful
not useful
vi micro wrote:
c:/winarm/bin/../lib/gcc/arm-elf/4.1.0/../../../../arm-elf/lib/thumb/int 
erwork\libc.a(exit.o):
> In function `exit':exit.c:(.text+0x1a): undefined reference to `_exit'
> collect2: ld returned 1 exit status
> make.exe: *** [test.elf] Error 1

_exit is one or the Newlib syscalls. You have to provide this as part of
your board support. Examples for a number of chips/boards are included
with the WinARM distribution.

Refer to the Newlib documentation for details of the syscalls.
http://sourceware.org/newlib/libc.html (section 12).

Clifford

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.