Portál AbcLinuxu, 9. května 2025 02:57
g++ -lGL -lglut -lGLU -L /usr/local/lib/ -lglm projekt.cpp -o projektA při kompilování projektu dostanu následující chybu:
/tmp/cc4jj253.o: In function `init()': projekt.cpp:(.text+0x7ef): undefined reference to `glmReadOBJ' projekt.cpp:(.text+0x81b): undefined reference to `glmUnitize' projekt.cpp:(.text+0x837): undefined reference to `glmVertexNormals' collect2: error: ld returned 1 exit statusld asi nemůže najít mou novou knihovnu, ale i kdyby v řádku pro kompilaci nebyla napsaná cesta, je v souboru /etc/ld.so.conf.d/libc.conf určitě. Proč mi tedy nelze najít knihovnu pro kompilaci, která vypadá v pořádku nainstalovaná a i include hlavičkového souboru je bez problémů?
Řešení dotazu:
glm
to zjevně najde, jinak by si linker stěžoval. Takže buď se ti linkuje s jinou knihovnou téhož názvu nebo bych zkusil ten parametr -lglm
posunout až na konec, tedy nějak takhle:
g++ -lGL -lglut -lGLU -L /usr/local/lib/ projekt.cpp -o projekt -lglm
/usr/local/lib//libglm.a(libglm_la-glmimg_jpg.o): In function `glmReadJPG': /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_jpg.c:112: undefined reference to `jpeg_std_error' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_jpg.c:126: undefined reference to `jpeg_CreateDecompress' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_jpg.c:130: undefined reference to `jpeg_stdio_src' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_jpg.c:134: undefined reference to `jpeg_read_header' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_jpg.c:156: undefined reference to `jpeg_start_decompress' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_jpg.c:193: undefined reference to `jpeg_read_scanlines' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_jpg.c:200: undefined reference to `jpeg_finish_decompress' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_jpg.c:208: undefined reference to `jpeg_destroy_decompress' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_jpg.c:200: undefined reference to `jpeg_finish_decompress' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_jpg.c:208: undefined reference to `jpeg_destroy_decompress' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_jpg.c:120: undefined reference to `jpeg_destroy_decompress' /usr/local/lib//libglm.a(libglm_la-glmimg_png.o): In function `glmReadPNG': /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_png.c:77: undefined reference to `png_create_read_struct' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_png.c:87: undefined reference to `png_create_info_struct' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_png.c:114: undefined reference to `png_init_io' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_png.c:119: undefined reference to `png_read_info' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_png.c:121: undefined reference to `png_get_IHDR' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_png.c:131: undefined reference to `png_set_strip_16' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_png.c:156: undefined reference to `png_get_valid' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_png.c:162: undefined reference to `png_read_update_info' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_png.c:164: undefined reference to `png_get_channels' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_png.c:168: undefined reference to `png_get_rowbytes' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_png.c:180: undefined reference to `png_read_image' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_png.c:181: undefined reference to `png_read_end' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_png.c:186: undefined reference to `png_destroy_read_struct' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_png.c:152: undefined reference to `png_set_expand' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_png.c:157: undefined reference to `png_set_expand' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_png.c:148: undefined reference to `png_set_expand' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_png.c:105: undefined reference to `png_destroy_read_struct' /home/balhar/Dropbox/Skola/PGII/glm/glm/glmimg_png.c:91: undefined reference to `png_destroy_read_struct' collect2: error: ld returned 1 exit status
g++ -lGL -lglut -lGLU -ljpeg -lpng -L /usr/local/lib/ projekt.cpp -o projekt -lglm
glm
závisí ještě na další knihovně nebo na dalších knihovnách. To bys měl dokázat zjistit z dokumentace k té knihovně glm
.
extern "C" { #include <glm.h> }
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.