问题:
在/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;"