Linking problem with qcc

bridged with qdn.public.qnxrtp.powerpc
Post Reply
Alexander Popov

Linking problem with qcc

Post by Alexander Popov » Thu Jun 12, 2003 8:15 am

Hi all,

I just got the 6.2.1a Pro version of QNX and I'm trying to port some stuff to ppcbe.
But I constantly get errors from the linker simmilar to this one:

/tmp/AAA946985_cc.o(.text+0x480): undefined reference to `fprintf'
/tmp/AAA946985_cc.o(.text+0x480): relocation truncated to fit: R_PPC_REL24 fprintf

I tryed using qcc with poth -V gcc_ntoppcbe and -V gcc_ntoppcbe_cpp.
Am I missing something?

Regards,
--
Alexander Popov ProSyst Bulgaria Inc.
Team Leader 48 Vladajska Str.
Dept: Real Time OS and Java VM Sofia 1606, Bulgaria
Phone: +359 2 952 35 81/203 http://www.prosyst.com
Mobile: +359 87 663 193 OSGi Technology Leaders

Jay Greig

Re: Linking problem with qcc

Post by Jay Greig » Thu Jun 12, 2003 6:44 pm

What is your host system? What is the whole command you are using?

With the source foo.c:

#include <stdio.h>

int main()
{
fprintf(fdopen(0, "w"), "Hello World\n");
return 0;
}

I compile it as:

# qcc -Vgcc_ntoppcbe -o foo foo.c

And I see:

# foo
Hello World
#

Previously, Alexander Popov wrote in qdn.public.qnxrtp.powerpc:
Hi all,

I just got the 6.2.1a Pro version of QNX and I'm trying to port some stuff to ppcbe.
But I constantly get errors from the linker simmilar to this one:

/tmp/AAA946985_cc.o(.text+0x480): undefined reference to `fprintf'
/tmp/AAA946985_cc.o(.text+0x480): relocation truncated to fit: R_PPC_REL24 fprintf

I tryed using qcc with poth -V gcc_ntoppcbe and -V gcc_ntoppcbe_cpp.
Am I missing something?

Regards,
--
Alexander Popov ProSyst Bulgaria Inc.
Team Leader 48 Vladajska Str.
Dept: Real Time OS and Java VM Sofia 1606, Bulgaria
Phone: +359 2 952 35 81/203 http://www.prosyst.com
Mobile: +359 87 663 193 OSGi Technology Leaders
--
-Jay.

Alexander Popov

Re: Linking problem with qcc

Post by Alexander Popov » Fri Jun 13, 2003 8:47 am

On Thu, 12 Jun 2003 14:44:08 -0400 Jay Greig <greig@qnx.com> wrote:

Ok. Some more info on what I do:

I cross compiled SDL ( current cvs ) with the dinkum libs (there's no libstdc++ in the gcc
toolchain for ppcbe). Since I dind't found way to do it with qcc -V using the --target mechanism
from configure, I set up the proper environment (CC and CXX pointing at qcc -V gcc_ntoppcbe_cpp, LD,
AR, NM and RANLIB to ntoppc-* ) and faked configure that it's using a
cross-compiler (cross_compiling=yes before the check - without setting the ppc target).
The library was built without any problems (as a static lib) - I run nm and file on the packed
object file and everithing seamed fine.

Then I tryed to compile one of the tests with the produced static lib ( libSDL.a ) with the
following options:

qcc -V gcc_ntoppcbe_cpp -static -o testbitmap -I/home/long/target/include/SDL
-L/home/long/target/lib -lSDL -lm -lph testbitmap.c

and the result was:

/tmp/AAA356377_cc.o: In function `LoadXBM':
/tmp/AAA356377_cc.o(.text+0x44): undefined reference to `SDL_CreateRGBSurface'
/tmp/AAA356377_cc.o(.text+0x44): relocation truncated to fit: R_PPC_REL24 SDL_CreateRGBSurface
/tmp/AAA356377_cc.o(.text+0x5c): undefined reference to `SDL_GetError'
/tmp/AAA356377_cc.o(.text+0x5c): relocation truncated to fit: R_PPC_REL24 SDL_GetError
/tmp/AAA356377_cc.o: In function `main':
/tmp/AAA356377_cc.o(.text+0x218): undefined reference to `SDL_Init'
/tmp/AAA356377_cc.o(.text+0x218): relocation truncated to fit: R_PPC_REL24 SDL_Init
/tmp/AAA356377_cc.o(.text+0x228): undefined reference to `SDL_GetError'
/tmp/AAA356377_cc.o(.text+0x228): relocation truncated to fit: R_PPC_REL24 SDL_GetError
/tmp/AAA356377_cc.o(.text+0x256): undefined reference to `SDL_Quit'
/tmp/AAA356377_cc.o(.text+0x25a): undefined reference to `SDL_Quit'
/tmp/AAA356377_cc.o(.text+0x3fc): undefined reference to `SDL_SetVideoMode'
/tmp/AAA356377_cc.o(.text+0x3fc): relocation truncated to fit: R_PPC_REL24 SDL_SetVideoMode
/tmp/AAA356377_cc.o(.text+0x41c): undefined reference to `SDL_GetError'
/tmp/AAA356377_cc.o(.text+0x41c): relocation truncated to fit: R_PPC_REL24 SDL_GetError
/tmp/AAA356377_cc.o(.text+0x450): undefined reference to `SDL_LockSurface'
/tmp/AAA356377_cc.o(.text+0x450): relocation truncated to fit: R_PPC_REL24 SDL_LockSurface
/tmp/AAA356377_cc.o(.text+0x460): undefined reference to `SDL_GetError'
/tmp/AAA356377_cc.o(.text+0x460): relocation truncated to fit: R_PPC_REL24 SDL_GetError
/tmp/AAA356377_cc.o(.text+0x51c): undefined reference to `SDL_UnlockSurface'
/tmp/AAA356377_cc.o(.text+0x51c): relocation truncated to fit: R_PPC_REL24 SDL_UnlockSurface
/tmp/AAA356377_cc.o(.text+0x534): undefined reference to `SDL_UpdateRect'
/tmp/AAA356377_cc.o(.text+0x534): relocation truncated to fit: R_PPC_REL24 SDL_UpdateRect
/tmp/AAA356377_cc.o(.text+0x58c): undefined reference to `SDL_PollEvent'
/tmp/AAA356377_cc.o(.text+0x58c): relocation truncated to fit: R_PPC_REL24 SDL_PollEvent
/tmp/AAA356377_cc.o(.text+0x64c): undefined reference to `SDL_UpperBlit'
/tmp/AAA356377_cc.o(.text+0x64c): relocation truncated to fit: R_PPC_REL24 SDL_UpperBlit
/tmp/AAA356377_cc.o(.text+0x660): undefined reference to `SDL_UpdateRects'
/tmp/AAA356377_cc.o(.text+0x660): relocation truncated to fit: R_PPC_REL24 SDL_UpdateRects
/tmp/AAA356377_cc.o(.text+0x690): undefined reference to `SDL_FreeSurface'
/tmp/AAA356377_cc.o(.text+0x690): relocation truncated to fit: R_PPC_REL24 SDL_FreeSurface
cc: /usr/bin/ntoppc-ld error 1

I can provide you with the sources and the build scripts that I used if you wish.


Best Regards,
Alexander
What is your host system? What is the whole command you are using?

With the source foo.c:

#include <stdio.h

int main()
{
fprintf(fdopen(0, "w"), "Hello World\n");
return 0;
}

I compile it as:

# qcc -Vgcc_ntoppcbe -o foo foo.c

And I see:

# foo
Hello World
#

Previously, Alexander Popov wrote in qdn.public.qnxrtp.powerpc:
Hi all,

I just got the 6.2.1a Pro version of QNX and I'm trying to port some stuff to ppcbe.
But I constantly get errors from the linker simmilar to this one:

/tmp/AAA946985_cc.o(.text+0x480): undefined reference to `fprintf'
/tmp/AAA946985_cc.o(.text+0x480): relocation truncated to fit: R_PPC_REL24 fprintf

I tryed using qcc with poth -V gcc_ntoppcbe and -V gcc_ntoppcbe_cpp.
Am I missing something?

Regards,
--
Alexander Popov ProSyst Bulgaria Inc.
Team Leader 48 Vladajska Str.
Dept: Real Time OS and Java VM Sofia 1606, Bulgaria
Phone: +359 2 952 35 81/203 http://www.prosyst.com
Mobile: +359 87 663 193 OSGi Technology Leaders


--
-Jay.
--
Alexander Popov ProSyst Bulgaria Inc.
Team Leader 48 Vladajska Str.
Dept: Real Time OS and Java VM Sofia 1606, Bulgaria
Phone: +359 2 952 35 81/203 http://www.prosyst.com
Mobile: +359 87 663 193 OSGi Technology Leaders

Adam Mallory

Re: Linking problem with qcc

Post by Adam Mallory » Fri Jun 13, 2003 1:22 pm

Alexander Popov <s_popov@prosyst.bg> wrote in message
news:20030613114749.418510b6.s_popov@prosyst.bg...
Then I tryed to compile one of the tests with the produced static lib (
libSDL.a ) with the
following options:

qcc -V gcc_ntoppcbe_cpp -static -o
testbitmap -I/home/long/target/include/SDL
-L/home/long/target/lib -lSDL -lm -lph testbitmap.c
Change the order of your options, so that the testbitmap.c file which
depends on the libs comes first, rather than after the libs have been
specified. So:

qcc -Vgcc_ntoppcbe_cpp -static -o testbitmap -I/home/long/target/include/SDL
testbitmap.c
-L/home/long/target/lib -lSDL -lm -lph

-Adam

Alexander Popov

Re: Linking problem with qcc

Post by Alexander Popov » Fri Jun 13, 2003 3:00 pm

On Fri, 13 Jun 2003 09:22:45 -0400 "Adam Mallory" <amallory@qnx.com> wrote:

Thanks Adam,

That worked.

Best Regards,
Alexander
Alexander Popov <s_popov@prosyst.bg> wrote in message
news:20030613114749.418510b6.s_popov@prosyst.bg...

Then I tryed to compile one of the tests with the produced static lib (
libSDL.a ) with the
following options:

qcc -V gcc_ntoppcbe_cpp -static -o
testbitmap -I/home/long/target/include/SDL
-L/home/long/target/lib -lSDL -lm -lph testbitmap.c

Change the order of your options, so that the testbitmap.c file which
depends on the libs comes first, rather than after the libs have been
specified. So:

qcc -Vgcc_ntoppcbe_cpp -static -o testbitmap -I/home/long/target/include/SDL
testbitmap.c
-L/home/long/target/lib -lSDL -lm -lph

-Adam

--
Alexander Popov ProSyst Bulgaria Inc.
Team Leader 48 Vladajska Str.
Dept: Real Time OS and Java VM Sofia 1606, Bulgaria
Phone: +359 2 952 35 81/203 http://www.prosyst.com
Mobile: +359 87 663 193 OSGi Technology Leaders

Adam Mallory

Re: Linking problem with qcc

Post by Adam Mallory » Fri Jun 13, 2003 3:02 pm

Alexander Popov <s_popov@prosyst.bg> wrote in message
news:20030613180053.0dc1b0f1.s_popov@prosyst.bg...
On Fri, 13 Jun 2003 09:22:45 -0400 "Adam Mallory" <amallory@qnx.com
wrote:

Thanks Adam,

That worked.
The linker does the resoloving from left to right, if you specify libs
before you have symbols needing to resolve against them (ie. your source
file), then the link will fail.

As a general rule, link all object together, then specify libs at the end to
resolve any outstanding symbols.

-Adam

Post Reply

Return to “qdn.public.qnxrtp.powerpc”