I have 3 questions :-
I am using winarm based on GCC 4.0.2
1) I am using mktime and gmtime_r functions in my code. They build fine
but do not link. I know this is down to a missing library, but which
library do I need ?
here is my current makefile linker code
#LIBS = --start-group -lc -lm -lgcc -lstdc++ --end-group
LIBS = --start-group -lc -lm -lstdc++ --end-group
LFLAGS = -nostartfiles $(LIBS) -Map $(NAME).map -T$(LINK)
2) If I include the lstdc++ in a pure C project does it create any
overhead ?
3) The lpc_2129_newlib_cpp_20050820.zip demo has the following in the
make file
#Support for newlibc-lpc (file: libnewlibc-lpc.a)
NEWLIBLPC = -lnewlib-lpc
...
# Linker flags.
# -Wl,...: tell GCC to pass this to linker.
# -Map: create map file
# --cref: add cross reference to map file
LDFLAGS = -nostartfiles -Wl,-Map=$(TARGET).map,--cref
LDFLAGS += -lc
LDFLAGS += $(NEWLIBLPC) $(MATH_LIB)
LDFLAGS += -lc -lgcc
LDFLAGS += $(CPLUSPLUS_LIB)
Where do I find the ibnewlibc-lpc.a in the Winarm package ?
All the best, and thanks to the people behind WinARM for a great
project!!!
Fordp wrote:
(Personaly I realy prefer real full names. Anyway:)
> 1) I am using mktime and gmtime_r functions in my code. They build fine> but do not link. I know this is down to a missing library, but which> library do I need ?>> here is my current makefile linker code>> #LIBS = --start-group -lc -lm -lgcc -lstdc++ --end-group> LIBS = --start-group -lc -lm -lstdc++ --end-group> LFLAGS = -nostartfiles $(LIBS) -Map $(NAME).map -T$(LINK)
Not enough information. Please give the error-message, create a simple
example-application and place it somewhere on an internet-server. AFAIK
some time-functions use a syscall to interface with the hardware,
sometimes just providing a dummy-syscall is enough to make the linker
"happy".
> 2) If I include the lstdc++ in a pure C project does it create any> overhead ?
You can simple try yourself. Create and check the map-file for changes
after make clean all with an without the c++ library-option. When using
makefiles based on the WinARM-template (which is based on the
WinAVR-template) the summary of the memory-usage is part of the output
of make all.
> 3) The lpc_2129_newlib_cpp_20050820.zip demo has the following in the> make file> ...> Where do I find the ibnewlibc-lpc.a in the Winarm package ?
Suggestion: Find it by searching for the file-name.
Start->Search->Files->search in c:\WinARM, seach for libnewlib-lpc.a
(==>arm-elf/lib/). You might want to read the readme.file for WinARM
3/06 even if you are using an older version. The location of the library
is mentioned two times in this readme since it has been a FAQ. (I wonder
how many people do not know about the file-search function in Windows).
Martin Thomas
> #LIBS = --start-group -lc -lm -lgcc -lstdc++ --end-group> LIBS = --start-group -lc -lm -lstdc++ --end-group> LFLAGS = -nostartfiles $(LIBS) -Map $(NAME).map -T$(LINK)
You have commented out the version of LIBS that links libgcc.a - why
would you do that?
If the linker only links object code from a library if it is required to
resolve a symbol. Therefore if you have not used C++ the presence of
libstdc++ will not affect the final code. It could conceivably extend
the build marginally time if the linker has to iterate the group more
than once.
Clifford
Fordp wrote:
> Clifford Slocombe Wrote :>> You have commented out the version of LIBS that links libgcc.a - why>> would you do that?>> I did that because it could not find the library.>
Well it is clearly present in the directory dump you provided. You DO
have to tell the linker where it is though! This is a case where the
'more information' that Martin requested would help. The log should
include the linker invokation as well as the resultant errors -
verbatim, not paraphrased or manually transcribed. You can cut & paste
from console windows - right-click, Mark, select with the mouse, press
enter - the text will be in the paste buffer.
For example, I have a macro in my make file that looks like this:
CLIBPATHS = -L$(WINARM_TOOLS_ROOT)/lib/gcc/arm-elf/4.0.2/interwork
-L$(WINARM_TOOLS_ROOT)/arm-elf/lib/interwork
It is used in the linker invokation to specify the paths to the correct
libraries:
$(LD) $(OBJECTS) ./lib/$(OSLIB) $(CLIBPATHS) $(LFLAGS) -o
./output/$(PROJNAME).out
- the Thumb/ARM interwork libraries in this case, but you might use the
defaults (one folder up, or one of the other 'special' libraries.
Clifford
I have established that the library functions I want are implemented in
newlib.
I am still struggling to get the linker to find libgcc.a.
I am not sure the newlib stuff is in libgcc.a.
I will keep trying.
I am building for the LPC2103 and I have no thumb code at this time.
All the best.
FordP
Fordp wrote:
> I have established that the library functions I want are implemented in> newlib.
Yes thay are, newlib is implemented by libc.a and libm.a
> I am still struggling to get the linker to find libgcc.a.>
You have not provided the requested information (a full build log)! This
will tell us exactly how you are invoking the linker. Fragments of
makefiles are not helpful, since it does not tell us the actual link
command used - an error in the makefile for example could yield
unexpected results. You are much more likely to get a resolution if you
do this! For a start it will allow me to tell you exactly what options
YOU need to set rather that give you examples of what I am setting,
which may only serve to confuse.
> I am not sure the newlib stuff is in libgcc.a.
It is not; libgcc.a contains support functions for the compiler, it is
normally required since the compiler will generate code that makes calls
to it. That is why I was surprised to see it commented out.
Clifford
here is my build log :-
Assembling crt.s
Compiling D505.c
Compiling interfce.c
Compiling win10.c
Compiling lpcisr.c
Compiling os2.c
Compiling i2c.c
Compiling ind_gmtm.c
Compiling clock.c
Linking d911lpc
C:/WinARM/bin/arm-elf-ld -LC:/WinARM/lib/gcc/arm-elf/4.0.2/interwork
-LC:/WinARM/arm-elf/lib/interwork -nostartfiles --start-group -lc -lm
-lstdc++ -lgcc --end-group -Map d911lpc.map -Tlpc2103_flash.cmd -o
d911lpc.out crt.o D505.o dali15.o interfce.o win10.o lpcisr.o os2.o
i2c.o ind_gmtm.o clock.o
clock.o: In function `get_time_low':C:\Documents and
Settings\SimonE\Eclipse_Workspace\D911LPC/clock.c:299: undefined
reference to `mktime'
clock.o: In function `set_time':C:\Documents and
Settings\SimonE\Eclipse_Workspace\D911LPC/clock.c:319: undefined
reference to `gmtime_r'
make: *** [d911lpc.out] Error 1
make: Target `all' not remade because of errors.
I modified my makefile to show the linker command line. If I had just
sent my normal build log it would have said nothing useful.
I think you will agree it shows that libc.a and libm.a are in there so
assuming they are the correct librarys then they should contain mktime
and gmtime_r. I have already posted my code previously, at least the
module with problems.
The code I posted should build fine on any chip in the range LPC2101 to
LPC2106, I have not looked at others at this time.
You should be able to add the module above to any suitable project and
get the results as I do.
Please note the rest of my code is deeply embedded and so has little use
for any librarys. This time/date convertion is the expception in my
code.
Thank you for your help so far.
Clifford Slocombe wrote:
> Fordp wrote:>> I have established that the library functions I want are implemented in>> newlib.> Yes thay are, newlib is implemented by libc.a and libm.a>>> I am still struggling to get the linker to find libgcc.a.>>> You have not provided the requested information (a full build log)! This> will tell us exactly how you are invoking the linker. Fragments of> makefiles are not helpful, since it does not tell us the actual link> command used - an error in the makefile for example could yield> unexpected results. You are much more likely to get a resolution if you> do this! For a start it will allow me to tell you exactly what options> YOU need to set rather that give you examples of what I am setting,> which may only serve to confuse.>>> I am not sure the newlib stuff is in libgcc.a.> It is not; libgcc.a contains support functions for the compiler, it is> normally required since the compiler will generate code that makes calls> to it. That is why I was surprised to see it commented out.>>> Clifford
Fordp wrote:
> here is my build log :->
Thanks, that is helpful in so far as we no longer just have to take your
word for it. ;-) And it is also good to expose the build commands just
so you can be sure yourself what you are building and how.
I must admit that it all looks correct. The only thing I would be wary
of is spaces in paths (like "Documents and Settings"). I have seen
problems in the past with some GNU tools for Win32 not processing such
paths correctly. But this does not appear to be the problem in this
instance. Even so I'd recommend moving the project files elsewhere.
I just inspected the interwork\libc.a library with teh arm-elf-nm
utility, and it does appear to contain mktime and gmtime_r. - stumped,
sorry.
Clifford
I got back to my code and I have managed to make it build Hurray.
The cause of the problem seems to stem from calling arm-elf-ld directly
to perform the link.
I changed it over to link by calling arm-elf-gcc and a couple of tweaks
later it is building.
Thanks Clifford and Martin for you efforts.
Cheers.
FordP
Come on England ;)
A question of your own?
This thread is over 20 years old.
Ask it in a thread of its own – more people read along there, and it gets answered more often and sooner.