Allt från Computex 2023

Problem att hitta delade bibliotek...

Permalänk
Inaktiv

Problem att hitta delade bibliotek...

Jag lägger den här då jag tror att den mest handlar om hur mitt unix-system hanterar länkning, dvs det är inte programmerings tekniskt.

Jag sitter på ett ELF system och kan för mitt liv inte få länkningen av ett program att fungera. Jag använder gcc och skall länka mot /usr/pkg/lib/libxosd.so. Man kan sätta sökväg i /etc/ld.so.conf och köra ldconfig, men det skall inte behövas med ELF. Jag har sökt som en galning och det mesta jag hittar handlar om hur man skapar bibliotek, inte hur man länkar mot dem.

Om någon ängel skulle kunna med några enkla steg beskriva hur det hela fungerar så blir jag riktigt lycklig!

Jag har kört(bland annat):

$ gcc -Wall -I /usr/pkg/include -Wl, -rpath /usr/pkg/lib -o test main.c ld: : No such file: No such file or directory

main.c är ett enkelt program:

#include <stdio.h> #include <stdlib.h> #include <xosd.h> int main(int, char *[]); int main(int argc, char *argv[]) { xosd *osd; char *display_str="Testing"; if ((osd = xosd_create(1)) == NULL) { fprintf(stderr, "%s", xosd_error); exit(EXIT_FAILURE); } xosd_set_font(osd, "fixed"); xosd_set_colour(osd, "Black"); xosd_set_timeout(osd, 3); xosd_set_shadow_offset(osd, 1); xosd_display(osd, 1, XOSD_string, display_str); xosd_wait_until_no_display(osd); xosd_destroy(osd); return EXIT_SUCCESS; }

Enlighten me!

Permalänk
Medlem

lägg till -lxosd så borde det funka

Visa signatur

flippy @ Quakenet

Permalänk
Inaktiv
Citat:

Ursprungligen inskrivet av ante84
lägg till -lxosd så borde det funka

Jag har redan testat det med samma resultat som ovan, men tack ändå. Jag blir tokig...

Saxxat från http://www.netbsd.org/Documentation/elf.html#elf-rpath :

Citat:

An ELF program needs to know the directory and the filename required to mmap(2) its shared libraries. Encoded within the file name is version information. There are one set of mechanisms for the directories and a different mechanism for the file names.
Directories

...

The primary directory locating mechanism is the ``rpath'' search list contained within the executable image. This search list is set with the -R directive to ld(1). The POSIX syntax for passing ld(1) options through the compiler front end is:

-Wl, option,option,...

For example: -Wl,-R/usr/something/lib. Multiple -R directives can be given to a single application to create a shared library search path.