EmbDev.net

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


Author: Vi Micro (jothi)
Posted on:

Rate this post
0 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.

Author: Clifford Slocombe (clifford)
Posted on:

Rate this post
0 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

Author: Martin Thomas (Guest)
Posted on:

Rate this post
0 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...
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

Author: Vi Micro (jothi)
Posted on:

Rate this post
0 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

Author: Vi Micro (jothi)
Posted on:

Rate this post
0 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...
> 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

Author: Clifford Slocombe (clifford)
Posted on:

Rate this post
0 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

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.