gug-bg-herd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Проблем при компилир ане на l-m-a 3.0


From: Yavor Doganov
Subject: Проблем при компилир ане на l-m-a 3.0
Date: Fri, 04 Apr 2008 16:52:40 +0300
User-agent: Wanderlust/2.15.6 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Gojō) APEL/10.7 Emacs/22.1 (i486-pc-linux-gnu) MULE/5.0 (SAKAKI)

Срещам известни затруднения при компилирането на link-monitor-applet [1],
версия 3.0.  В тази версия GNU Build System е заменена с нова, далеч
по-съвършена система, наречена JB (Jean-Yves Lefort's build system).

За да компилираш програмата, трябва първо да компилираш JB (това е
програма на Си).  Става лесно, но не ми се мисли какво се случва при
някои екзотични системи.
След това обаче очевидно конфигурацията пропада при определена (желана
от мен) стойност на LDFLAGS:

$ ./jb configure ldflags="-Wl,--as-needed"
checking for ngettext(), dgettext(), bind_textdomain_codeset() in libc... yes
checking for msgfmt... /usr/bin/msgfmt
checking for perl... /usr/bin/perl
checking for XML::Parser... yes
checking for gconftool-2... /usr/bin/gconftool-2
checking for scrollkeeper-preinstall... /usr/bin/scrollkeeper-preinstall
checking for scrollkeeper-update... /usr/bin/scrollkeeper-update
checking for scrollkeeper-config... /usr/bin/scrollkeeper-config
checking for the OMF directory... /usr/share/omf
checking for the ScrollKeeper database directory... /var/lib/scrollkeeper
checking for gob2... not found
checking the C compiler dependency style... GCC
checking for the GNU C library... yes
checking for clock_gettime() in -lrt... no
checking for clock_gettime() in libc... no
ERROR: clock_gettime() found neither in librt nor in libc

build/configure.log показва:

checking for clock_gettime() in -lrt
attempting to link program build/test.c:
   1 char clock_gettime ();
   2 int main () { clock_gettime(); }
===============================================================================
command "cc -O2    -Wl,--as-needed -lrt -o build/test build/test.c" failed with 
status 1
standard error output:
/tmp/cc0s9LlL.o: In function `main':test.c:(.text+0xe): undefined reference to `
clock_gettime'
collect2: ld returned 1 exit status
===============================================================================
result: no

checking for clock_gettime() in libc
attempting to link program build/test.c:
   1 char clock_gettime ();
   2 int main () { clock_gettime(); }
===============================================================================
command "cc -O2    -Wl,--as-needed  -o build/test build/test.c" failed with stat
us 1
standard error output:
/tmp/cctxEBkw.o: In function `main':test.c:(.text+0xe): undefined reference to `
clock_gettime'
collect2: ld returned 1 exit status
===============================================================================
result: no

Хмм...  Я да видим с така омразните от Жан-Ив Лефор GNU autotools:

cat > configure.ac<<'EOF'
AC_INIT

AC_CHECK_LIB([rt], [clock_gettime], [],
             [AC_MSG_ERROR([cannot find the `clock_gettime' function.])])
EOF

autoreconf
./configure LDFLAGS="-Wl,-z,defs -Wl,--as-needed"
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for clock_gettime in -lrt... yes

$ grep -A3 "for clock_gettime" config.log
configure:2550: checking for clock_gettime in -lrt
configure:2585: gcc -o conftest -g -O2  -Wl,-z,defs -Wl,--as-needed conftest.c 
-lrt   >&5
configure:2591: $? = 0
configure:2609: result: yes

Опалянкаа...  Нашто glibc май си е наред.  Добре, тогава ще
конфигурираме без LDFLAGS и ще ги подадем на make (ъъъ, на ./jb
build), както всеки нормален човек би очаквал да е възможно.

$ ./jb configure
(провал при gNS, иска GTK+ 2.12, а имаме 2.8)
(успех при Debian)
$ ./jb build ldflags="--Wl,--as-needed"
ERROR: unknown group "ldflags=-Wl,--as-needed"

Въх.  Май JB не е чак толкова über, иновационна, усъвършенствана и
опростена система...

Но все пак да видим как може да заобиколим проблема.  След кратко
чудене и мъдене, установяваме, че командата за компилиране извлича
всички необходими флагове и опции (установени при конфигурирането) от
файла build/config, който има леко странен формат.  Внасяме
необходимата корекция на съответния ред:

ldflags|string|1|-Wl,--as-needed

и пробваме пак.  Успешна компилация, но уви, двоичният файл все още е
свързан с един милион ненужни библиотеки.  Що така?  build/build.log
ни казва:

command "cc -std=c99 -D_BSD_SOURCE -D_POSIX_C_SOURCE=199309L -pthread
-DORBIT2=1 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include
-I/usr/include/gtk-2.0 -I/usr/lib/gtk-2.0/include
-I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/pango-1.0
-I/usr/include/freetype2 -I/usr/include/libpng12
-I/usr/include/libgnomeui-2.0 -I/usr/include/libart-2.0
-I/usr/include/gconf/2 -I/usr/include/gnome-keyring-1
-I/usr/include/libgnome-2.0 -I/usr/include/libbonoboui-2.0
-I/usr/include/libgnomecanvas-2.0 -I/usr/include/gnome-vfs-2.0
-I/usr/lib/gnome-vfs-2.0/include -I/usr/include/orbit-2.0
-I/usr/include/libbonobo-2.0 -I/usr/include/bonobo-activation-2.0
-I/usr/include/libxml2 -I/usr/include/gail-1.0
-I/usr/include/panel-2.0 -I/usr/include/libglade-2.0 -O2
-Wl,--export-dynamic -lm -lbsd-compat -lrt -pthread -lpanel-applet-2
-lgnomeui-2 -lSM -lICE -lbonoboui-2 -lgnomevfs-2 -lgconf-2
-lgnomecanvas-2 -lgnome-2 -lpopt -lart_lgpl_2 -lbonobo-2
-lbonobo-activation -lORBit-2 -lgthread-2.0 -lrt -lglade-2.0
-lgtk-x11-2.0 -lxml2 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lm
-lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -ldl
-lglib-2.0 -lGeoIP --Wl,--as-needed -o build/src/link-monitor-applet
                   ^^^^^^^^^^^^^^^^
build/src/link-monitor-applet-lm-about-dialog.o
build/src/link-monitor-applet-lm-applet.o
build/src/link-monitor-applet-lm-bar-graph.o
build/src/link-monitor-applet-lm-cell-renderer-color.o
build/src/link-monitor-applet-lm-data-set.o
build/src/link-monitor-applet-lm-dialog.o
build/src/link-monitor-applet-lm-framed-image.o
build/src/link-monitor-applet-lm-host.o
build/src/link-monitor-applet-lm-host-frontend.o
build/src/link-monitor-applet-lm-host-view.o
build/src/link-monitor-applet-lm-line-graph.o
build/src/link-monitor-applet-lm-line-graph-icon.o
build/src/link-monitor-applet-lm-preferences-dialog.o
build/src/link-monitor-applet-lm-shell.o
build/src/link-monitor-applet-lm-tooltips.o
build/src/link-monitor-applet-lm-color-generator.o
build/src/link-monitor-applet-lm-icmp.o
build/src/link-monitor-applet-lm-main.o
build/src/link-monitor-applet-lm-non-linear-range.o
build/src/link-monitor-applet-lm-util.o" succeeded

Е, няма как да стане работата, --as-needed се подава точно там, където
е абсолютно ненужно.  Почваме да изучаваме тази хипер удобна система,
за да разберем как се изграждат опциите и как можем да променим реда.
Леееееко неприятно занимание за обикновен потребител, който просто
иска да си компилира програмата или пък да си направи пакетче (в моя
случай да си обновя пакетчето).

Все пак, някои хора трудно се отказват.  Откриваме причината в
jbsrc/lib/jb-resource.c:

jb_action_exec("$cc $package-cflags $group-cflags $object-cflags $cflags"
                     " $package-ldflags $group-ldflags $object-ldflags 
$stock-ldflags $ldflags"
                     " -o $outfile $object-files",
                     "package-cflags", jb_compile_options.cflags->str,
                     "group-cflags", gres->group->compile_options.cflags->str,
                     "object-cflags", self->compile_options.cflags->str,
                     "package-ldflags", jb_compile_options.ldflags->str,
                     "group-ldflags", gres->group->compile_options.ldflags->str,
                     "object-ldflags", self->compile_options.ldflags->str,
                     "stock-ldflags", object_class->stock_ldflags,
                     "outfile", outfile,
                     "object-files", object_files,
                     NULL);

Разменяме местата и прекомпилираме jb, за да можем с неговата
неоценима помощ да компилираме l-m-a.  Този път всичко е наред, и
нашите ldflags се подават преди останалите.  Само дето не се
компилира:

[...]
build/src/link-monitor-applet-lm-util.o: In function `show_error_dialog_real':
lm-util.c:(.text+0x158c): undefined reference to `gtk_widget_destroy'
lm-util.c:(.text+0x15c7): undefined reference to `gtk_widget_show'
build/src/link-monitor-applet-lm-util.o: In function 
`lm_g_slist_free_deep_custom':
lm-util.c:(.text+0x1eb9): undefined reference to `g_slist_free'
collect2: ld returned 1 exit status
ERROR: command failed

Е, как да не го заблъскаш?

[1] http://www.nongnu.org/link-monitor/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]