Skip to contentSkip to conversation

newlib, malloc missing, I must be missing something

OpenRISC Dan 3 participants 3 messages Aug 25, 2016

lore
Share & tools
lore

Dan

author
#0 lore raw

Hello!

I just built the or1k tool suite according to the directions on openrisk.io/newlib/building.html. However, when trying to build my first file, I'm getting:

% or1k-elf-gcc -O3 -o dhry.o -c dhry.c
% or1k-elf-ld -o dhry dhry.o
% or1k-elf-ld: warning: cannot find entry symbol _start; defaulting to 0000000000000000
dhry.o: In function `Func_2':
dhry.c:(.text+0x444): undefined reference to strcmp' dhry.o: In function main':
dhry.c:(.text.startup+0x34): undefined reference to malloc' dhry.c:(.text.startup+0x48): undefined reference to malloc' dhry.c:(.text.startup+0x1e8): undefined reference to strcmp' dhry.c:(.text.startup+0x390): undefined reference to exit'

However, if I just do the linking with GCC alone, I get:

% or1k-elf-gcc dhry.o -o dhry
% (No errors)

Any thoughts?

Thanks!

Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.librecores.org/pipermail/openrisc/attachments/20160825/68ef21c5/attachment.html>

#1 lore raw
Quoted 10 lines · Dan

Hello!

I just built the or1k tool suite according to the directions on openrisk.io/newlib/building.html. However, when trying to build my first file, I'm getting:

% or1k-elf-gcc -O3 -o dhry.o -c dhry.c
% or1k-elf-ld -o dhry dhry.o
% or1k-elf-ld: warning: cannot find entry symbol _start; defaulting to

Hi,

can you try:

or1k-elf-gcc -o dhry dhry.o

Cheers,
Stefan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.librecores.org/pipermail/openrisc/attachments/20160825/4f9a9f23/attachment.sig>

#2 lore raw
In reply to Dan
Quoted 19 lines · Dan

Hello!

I just built the or1k tool suite according to the directions on openrisk.io/newlib/building.html. However, when trying to build my first file, I'm getting:

% or1k-elf-gcc -O3 -o dhry.o -c dhry.c
% or1k-elf-ld -o dhry dhry.o
% or1k-elf-ld: warning: cannot find entry symbol _start; defaulting to 0000000000000000
dhry.o: In function `Func_2':
dhry.c:(.text+0x444): undefined reference to strcmp' dhry.o: In function main':
dhry.c:(.text.startup+0x34): undefined reference to malloc' dhry.c:(.text.startup+0x48): undefined reference to malloc' dhry.c:(.text.startup+0x1e8): undefined reference to strcmp' dhry.c:(.text.startup+0x390): undefined reference to exit'

Quoted 6 lines

However, if I just do the linking with GCC alone, I get:

% or1k-elf-gcc dhry.o -o dhry
% (No errors)

Any thoughts?

Hi Dan,

The C compiler is a driver for the linker, putting in all the libraries you need. You should always link C code using gcc, not ld.

To see the link line used try gcc -v. It will show you all the sub-commands used.

Jeremy

Quoted 11 lines

Thanks!

Dan

_______________________________________________
OpenRISC mailing list
OpenRISC at lists.librecores.org
https://lists.librecores.org/listinfo/openrisc

Signature · 15 lines
Tel:     +44 (1590) 610184
Cell:    +44 (7970) 676050
SkypeID: jeremybennett
Twitter: @jeremypbennett
Email:   jeremy.bennett at embecosm.com
Web:     www.embecosm.com
PGP key: 1024D/BEF58172FB4754E1 2009-03-20

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: OpenPGP digital signature
URL: <http://lists.librecores.org/pipermail/openrisc/attachments/20160825/d355cc76/attachment.sig>