Linux 用非标准路径编译 glib
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12494072/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
compiling glib with non-standard paths
提问by Oz123
I am trying to compile glib-2.32.1
, therefore I installed libffi-3.0.1
into the following path:
我正在尝试编译glib-2.32.1
,因此我安装libffi-3.0.1
到以下路径:
~/localroot/lib/
and the header files are in:
头文件在:
~/localroot/lib/libffi-3.0.11/include/
However, when I do configure:
但是,当我进行配置时:
~/tmp/build_alot/glib-2.32.1 $ ./configure --prefix=~/localroot
I see the following error:
我看到以下错误:
checking whether to cache iconv descriptors... no
checking for ZLIB... yes
checking for LIBFFI... no
configure: error: Package requirements (libffi >= 3.0.0) were not met:
No package 'libffi' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
Alternatively, you may set the environment variables LIBFFI_CFLAGS
and LIBFFI_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.
What are the correct values that I need to set for LIBFFI_LIBS
and LIBFFI_CFLAGS
in order to successfully compile glib?
什么是正确的价值观,我需要设置 LIBFFI_LIBS
并LIBFFI_CFLAGS
以成功编译油嘴?
tiny bit of extra info:
一点点额外的信息:
When I compiled libffi I got the following helpful info:
当我编译 libffi 时,我得到了以下有用的信息:
Libraries have been installed in: /home/nahum/localroot/lib
库已安装在:/home/nahum/localroot/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
test -z "/home/user/localroot/share/info" || /bin/mkdir -p "/home/user/localroot/share/info"
/usr/bin/install -c -m 644 ../doc/libffi.info '/home/nahum/localroot/share/info'
install-info --info-dir='/home/user/localroot/share/info' '/home/user/localroot/share/info/libffi.info'
test -z "/home/user/localroot/lib/pkgconfig" || /bin/mkdir -p "/home/user/localroot/lib/pkgconfig"
/usr/bin/install -c -m 644 libffi.pc '/home/user/localroot/lib/pkgconfig'
make[3]: Leaving directory `/home/user/tmp/build_alot/libffi-3.0.11/x86_64-unknown-linux-gnu'
make[2]: Leaving directory `/home/user/tmp/build_alot/libffi-3.0.11/x86_64-unknown-linux-gnu'
make[1]: Leaving directory `/home/user/tmp/build_alot/libffi-3.0.11/x86_64-unknown-linux-gnu'
Setting PKG_CONFIG_PATH
to /home/user/localroot/lib/pkgconfig
still does not bring success.
设置PKG_CONFIG_PATH
为/home/user/localroot/lib/pkgconfig
仍然不会带来成功。
采纳答案by Oz123
on the way to enlightenment...
在启蒙的路上……
I managed to compile glib with:
我设法编译 glib :
export LIBFFI_CFLAGS=-I/home/user/localroot/lib/libffi-3.0.11/include
export LIBFFI_LIBS="-L/home/user/localroot/lib -lffi"
Now I have to see if the dependencies down the road are all happy with how I compiled it.
现在我必须看看接下来的依赖项是否都对我编译它的方式感到满意。
回答by jakeyeung
For those like me who were wondering where the -I
and -L
and -lffi
flags came from (Oz123's answer), I found out that they can be found in:
对于像我这样想知道-I
and-L
和-lffi
标志来自哪里的人(Oz123 的回答),我发现它们可以在以下位置找到:
/home/user/local-software/libffi-3.1/lib/pkgconfig/libffi.pc
Reading the file gives:
读取文件给出:
...
...
Libs: -L${toolexeclibdir} -lffi
Cflags: -I${includedir}
Use the Libs
and Cflags
location to set the LIBFFI_LIBS
and LIBFFI_CFLAGS
variable, respectively. Now if you run ./configure
then make && make install
, things should work (at least they did for me).
使用Libs
和Cflags
位置分别设置LIBFFI_LIBS
和LIBFFI_CFLAGS
变量。现在,如果您运行./configure
then make && make install
,事情应该会起作用(至少它们对我有用)。