问题:
在/etc/profile中配置了
export PKG_CONFIG_PATH=/usr/lib64/pkgconfig
但是在ssh root@192.168.0.168 "cd /root/my_proj; make;"时,总是提示
Package glib-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `glib-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'glib-2.0' found
/usr/include/glib-2.0/glib.h:30:10: fatal error: glib/galloca.h: No such file or directory
#include <glib/galloca.h>
^~~~~~~~~~~~~~~~
compilation terminated.
而直接通过SSH登录打开控制台窗口进行编译,就没有这个问题。
最终发现原因:ssh root@192.168.0.168 "执行的命令“ 这种方式不引导/etc/profile文件
解决方法:在 ~/.bashrc中添加export PKG_CONFIG_PATH=/usr/lib64/pkgconfig
快速验证:(注意$符号前面需要转义字符 \ )
ssh root@192.168.0.168 "echo \$PKG_CONFIG_PATH;"
文章讲述了用户在使用SSH远程连接时遇到glib-2.0包找不到的问题,原因是shell启动时不加载/etc/profile中的环境变量。解决方案是在~/.bashrc中设置PKG_CONFIG_PATH。验证方法是通过SSH检查环境变量值。
1017

被折叠的 条评论
为什么被折叠?



