LLD
LLD copied to clipboard
Can't use shared object Library
I decided to have some fun and code along with the videos in the OS development using the Linux kernel
playlist. I had issues after compiling the mylib
library & moving the shared object to /mnt/myos/lib/
. I tried compiling the init
using the makefile, and I just get this output:
cc -nostdlib -I../include -c init.c -o init_c.o
cc -lmy -L/mnt/myos/lib -nostdlib -I../include -o init init_c.o ../crt0_s.o
/usr/bin/ld: init_c.o: in function `main':
init.c:(.text+0x20): undefined reference to `sleep_sec'
/usr/bin/ld: init.c:(.text+0x2c): undefined reference to `str_print'
/usr/bin/ld: init.c:(.text+0x36): undefined reference to `sleep_sec'
/usr/bin/ld: init.c:(.text+0x4d): undefined reference to `str_print'
/usr/bin/ld: init.c:(.text+0x59): undefined reference to `str_print'
/usr/bin/ld: init.c:(.text+0x65): undefined reference to `str_print'
/usr/bin/ld: init.c:(.text+0x76): undefined reference to `sys_open'
/usr/bin/ld: init.c:(.text+0x95): undefined reference to `sys_read'
/usr/bin/ld: init.c:(.text+0xa4): undefined reference to `str_print'
/usr/bin/ld: init.c:(.text+0xb7): undefined reference to `sleep_sec'
/usr/bin/ld: init.c:(.text+0xc3): undefined reference to `str_print'
/usr/bin/ld: init.c:(.text+0xd7): undefined reference to `sys_reboot'
collect2: error: ld returned 1 exit status
make: *** [Makefile:11: init] Error 1
Any chance I am doing something wrong?
looks correct to me, my only guess is maybe the libmy.so wasn't copied to /mnt/myos/lib? If you use the same makefile it should work properly, if you aren't using the makefile make sure that you have the name of the so file as libmy.so
Edit: Also you can try copying the libmy.so to /usr/lib on your host machine to see if it picks it up from there.
Change the command "cc -lmy -L/mnt/myos/lib -nostdlib -I../include -o init init_c.o ../crt0_s.o" to "cc -nostdlib -I../include -o init init_c.o ../crt0_s.o -lmy -L/mnt/myos/lib"