I copy pasted the code from How would a loaded library function call a symbol in the main application? to help me understand how loaded libraries work. But when I tried to run it, it says it cannot find the file, although the file is right there in the current directory when I do ls
@APG9591:/mnt/c/Users/fried/Desktop/KI3/Game$ gcc -shared -olibdlo.so dlo.c
/usr/bin/ld: /tmp/ccpGxAlo.o: relocation R_X86_64_32 against `.rodata' can not be used when making a shared object; recompile with -fPIC
/tmp/ccpGxAlo.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
@APG9591:/mnt/c/Users/fried/Desktop/KI3/Game$ gcc -shared -fPIC -olibdlo.so dlo.c
@APG9591:/mnt/c/Users/fried/Desktop/KI3/Game$ gcc -ldl -rdynamic main.c
/tmp/ccHtUgDf.o: In function `main':
main.c:(.text+0x2b): undefined reference to `dlopen'
main.c:(.text+0x3b): undefined reference to `dlerror'
main.c:(.text+0x66): undefined reference to `dlerror'
main.c:(.text+0x7b): undefined reference to `dlsym'
main.c:(.text+0x83): undefined reference to `dlerror'
main.c:(.text+0xc7): undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
@APG9591:/mnt/c/Users/fried/Desktop/KI3/Game$ gcc -Wl,--no-as-needed -ldl -rdynamic main.c
@APG9591:/mnt/c/Users/fried/Desktop/KI3/Game$ ls
AI_A.c AI_B.c AI_C.c a.out dlo.c Game.c Game.h libdlo.so main.c runGame.c
@APG9591:/mnt/c/Users/fried/Desktop/KI3/Game$ ./a.out
libdlo.so: cannot open shared object file: No such file or directory
@APG9591:/mnt/c/Users/fried/Desktop/KI3/Game$
libdlo.so: cannot open shared object file: No such file or directory
why couldn't the program find the file libdlo.so? How do I fix this issue? Thanks!