views:

104

answers:

2

I am trying to run a simple program on an powerpc embedded system without any operating system. I am using GNU compiler-linker tools and PSIM as simulator. I've written my own very simple Linker Directive file.

I've used a global variable in my static library and want to use that variable in my sample program. But while linking the sample program GNU ld gives an error and stops. It says that it cannot find rela.dyn in linker directive file. Actually I do not want to use dynamically relocatable library, because I dont have a dynamic loader. What am I doing wrong?

A: 

Hard to say without more info. If you don't have an underlying OS, did you use -ffreestanding to avoid linking in the platform runtime?

Edit: -ffreestanding requires -shared? -ffreestanding means to compile to a non-hosted environment. How can such an environment support shared libraries?

DevSolar
Actually it does, I've tried and did see the result...
Caner Altinbasak
Funny. I drop out at this point (-ffreestanding should not do that, but I've not worked on your particular platform so I can't really judge); perhaps following James Molloy's advice (ld -v) gets you further.
DevSolar
There should be a rule against voting down without leaving a comment as to what in the answer is considered not useful. :-/
DevSolar
A: 

-ffreestanding, as Solar says. If that fails, run ld with the --verbose option to see exactly what it is trying to link in: that will enable you to debug further.