I am trying to link a C program into some assembly code. I am using gcc as and ld as required and they appear to generate the required file. In detail I do the following:-
as -g -o forth.o forth.s
gcc -c -o ccalls.o calls.c
ld -o forth forth.o calls.o -lncurses
However when I try to run it I get:-
pi@raspberrypi:~ $ ./forth
bash: ./forth: No such file or directory
pi@raspberrypi:~ $ ls -l forth
-rwxr-xr-x 1 pi pi 22924 Nov 18 22.16 forth
As can be seen the file is made and has execute permission but will not run.
If I do:-
as -g -o forth.o forth.s
ld -o forth forth.o
Then the program runs ( the program does not actually call the C function yet so no errors are created).
However If I do:-
as -g -o forth.o forth.s
ld -o forth forth.o calls.o
then the file is not found. I wrote a c wrapper to call and test ccalls which worked as expected so I don't think it is the actual code at fault.
I conclude that it is linking the ncurses library into assembler code which is causing the problem but I have no idea why.
Regards Roger