简体   繁体   English

使用“gcc $(pkg-config --cflags --libs glib-2.0) context.c”编译时出错-&gt;<galloca.h> 未找到</galloca.h>

[英]Error when compiling with “gcc $(pkg-config --cflags --libs glib-2.0) context.c” -> <galloca.h> not found

I tried to compile my context.c file with "gcc $(pkg-config --cflags --libs glib-2.0)" context.c.我尝试使用“gcc $(pkg-config --cflags --libs glib-2.0)”context.c 编译我的 context.c 文件。

But it doesn't work because it does not find galloca header file:但它不起作用,因为它没有找到galloca header 文件:

context.c:3:10: fatal error: galloca.h: file or directory not found #include <galloca.h> context.c:3:10:致命错误:galloca.h:找不到文件或目录#include <galloca.h>

I tried "gcc $(pkg-config --cflags --libs glib-2.0 glib)" where galloca.h is located /usr/include/glib-2.0/glib.我尝试了“gcc $(pkg-config --cflags --libs glib-2.0 glib)”,其中galloca.h位于/usr/include/glib-2.0/glib。 But after adding glib to the compile command, it does not even find glib.h anymore, which is in /usr/include/glib-2.0.但是在编译命令中加入glib之后,它甚至找不到glib.h,它在/usr/include/glib-2.0中。

I tried to add the all necessary paths to PKG_CONFIG_PATH with "export PKG_CONFIG_PATH=/usr/include/glib-2.0/gio/pkgconfig" and so on.... without success.我尝试使用“export PKG_CONFIG_PATH=/usr/include/glib-2.0/gio/pkgconfig”等将所有必要的路径添加到 PKG_CONFIG_PATH 等等....没有成功。

I also added all necessary library paths to /etc/ld.so.conf and sudo ldconfig -v, also without success.我还将所有必要的库路径添加到 /etc/ld.so.conf 和 sudo ldconfig -v,也没有成功。

It is not the first time i face the problem, that necessary libraries can't be found on this system while compiling, but as we in germany say: "i am at the end of my latin", so i have no more clue how to solve this issue and would be gratfull for any help.这不是我第一次遇到这个问题,编译时在这个系统上找不到必要的库,但正如我们在德国所说:“我在我的拉丁语末尾”,所以我不知道如何来解决这个问题,并会感谢任何帮助。

Thanks in advance.提前致谢。

PS: I use a raspberry pi 4B 8GB and raspbian linux. PS:我使用树莓派 4B 8GB 和树莓派 linux。

Your library path will not help it to find include file.您的库路径不会帮助它找到包含文件。

Maybe you want -I/usr/include/glib-2.0 -I/usr/include/glib-2.0/glib也许你想要-I/usr/include/glib-2.0 -I/usr/include/glib-2.0/glib

Maybe your build script accept CFLAGS environment variable where you can put this option.也许您的构建脚本接受CFLAGS环境变量,您可以在其中放置此选项。

Or maybe you change (edit) source code,或者也许你改变(编辑)源代码,

#include <galloca.h>

become变得

#include <glib/galloca.h>

because already it looks correctly in /usr/include/glib-2.0 , only the subdirectory is wrong因为它已经在/usr/include/glib-2.0中看起来正确,只有子目录是错误的

Afterwards you discover if you must set some path also for libraries.之后您会发现是否还必须为库设置一些路径。 But one thing by one, first compile, then worry about the link.但是一件一件的,先编译,再担心链接。 You talk about ld.so.conf .你谈论ld.so.conf Really this is for runtime, but OK, at build it is last option after trying everything else (see at man ld and search ld.so.conf ).确实这是针对运行时的,但是好的,在构建时它是尝试其他所有方法之后的最后一个选项(参见man ld并搜索ld.so.conf )。 Really for build time library path you want -L option maybe with LDFLAGS environment variable.对于您想要的构建时间库路径, -L选项可能带有LDFLAGS环境变量。 But as I say, first try compile and then discover if link problem.但正如我所说,首先尝试编译然后发现链接问题。

Wer mit seinem Latein am Ende ist, muss Griechisch sprechen. Wer mit seinem Latein am Ende ist, muss Griechisch sprechen。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM