Skip to contentSkip to conversation

Build fails due to wrong placement of -llibrary options

DISCUSSION Christian Franke 2 participants 4 messages Aug 28, 2010 Kbuild

lore
Share & tools
lore
#0 lore raw

I'm trying to fix the build on Cygwin after the recent move to the new autogen/automake build system.

There is one Cygwin independent issue found so far:

$ make
[...]
gcc [...] -lintl -o grub-bin2h.exe util/grub_bin2h-bin2h.o libgrub.a
libgrub.a(...): undefined reference to `_libintl_gettext'
[...]

Workaround:

$ make LIBS=-lintl
[...]
gcc [...] -lintl -o grub-bin2h.exe util/grub_bin2h-bin2h.o libgrub.a -lintl

The placement of -llibrary options matter because the linker searches libraries and objects in the order specified.

$ grep ^grub_bin2h_LD Makefile
grub_bin2h_LDADD = libgrub.a
grub_bin2h_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_PROGRAM) $(LIBINTL) $(LIBDEVMAPPER)

The above should be:
grub_bin2h_LDADD = libgrub.a $(LIBINTL) $(LIBDEVMAPPER) grub_bin2h_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_PROGRAM)

Same for all other utils. This likely needs to be fixed in gentpl.py.

Signature · 2 lines
Regards,
Christian Franke
#1 lore raw
Quoted 6 lines · Christian Franke
$ grep ^grub_bin2h_LD Makefile
grub_bin2h_LDADD = libgrub.a
grub_bin2h_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_PROGRAM) $(LIBINTL)
$(LIBDEVMAPPER)
Quoted 6 lines

The above should be:
grub_bin2h_LDADD = libgrub.a $(LIBINTL) $(LIBDEVMAPPER) grub_bin2h_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_PROGRAM)

Same for all other utils. This likely needs to be fixed in gentpl.py.

It is not necessary to modify gentpl.py, fixing in Makefile.util.def should be sufficient. Attached patch fixes all these AFAICS.

thanks,

Signature · 1 line
bvk.chaitanya

=== modified file 'Makefile.util.def'

Makefile.util.def +14 -14
@@ -99,7 +99,7 @@
   name = grub-bin2h;
   common = util/bin2h.c;
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
   mansection = 1;
 };
 
@@ -112,7 +112,7 @@
   extra_dist = util/grub-mkimagexx.c;
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
   cppflags = '-DGRUB_PKGLIBROOTDIR=\"$(pkglibrootdir)\"';
 };
 
@@ -123,7 +123,7 @@
   common = util/grub-mkrelpath.c;
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
 };
 
 program = {
@@ -133,7 +133,7 @@
   common = util/grub-script-check.c;
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
 };
 
 program = {
@@ -143,7 +143,7 @@
   common = util/grub-editenv.c;
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
 };
 
 program = {
@@ -153,7 +153,7 @@
   common = util/grub-mkpasswd-pbkdf2.c;
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
   cflags = '$(CFLAGS_GCRY)';
   cppflags = '$(CPPFLAGS_GCRY)';
 };
@@ -171,7 +171,7 @@
   common = util/grub-pe2elf.c;
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL)';
+  ldadd = '$(LIBINTL)';
   condition = COND_GRUB_PE2ELF;
 };
 
@@ -181,7 +181,7 @@
   common = util/grub-fstest.c;
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
   condition = COND_GRUB_FSTEST;
 };
 
@@ -194,8 +194,8 @@
   cflags = '$(freetype_cflags)';
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
-  ldflags = '$(freetype_libs)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
+  ldadd = '$(freetype_libs)';
   condition = COND_GRUB_MKFONT;
 };
 
@@ -212,7 +212,7 @@
   sparc64_ieee1275 = util/ieee1275/devicemap.c;
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
 };
 
 program = {
@@ -222,7 +222,7 @@
   common = util/grub-probe.c;
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
 };
 
 program = {
@@ -239,7 +239,7 @@
   sparc64_ieee1275 = util/lvm.c;
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
 
   enable = i386_pc;
   enable = sparc64_ieee1275;
@@ -506,5 +506,5 @@
   common = grub-core/tests/lib/test.c;
   cflags = -Wno-format;
   ldadd = libgrub.a;
-  ldflags = '$(LIBDEVMAPPER)';
+  ldadd = '$(LIBDEVMAPPER)';
 };
#2 lore raw
In reply to Christian Franke
Quoted 6 lines · Christian Franke
$ grep ^grub_bin2h_LD Makefile
grub_bin2h_LDADD = libgrub.a
grub_bin2h_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_PROGRAM) $(LIBINTL)
$(LIBDEVMAPPER)
Quoted 6 lines

The above should be:
grub_bin2h_LDADD = libgrub.a $(LIBINTL) $(LIBDEVMAPPER) grub_bin2h_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_PROGRAM)

Same for all other utils. This likely needs to be fixed in gentpl.py.

It is not necessary to modify gentpl.py, fixing in Makefile.util.def should be sufficient. Attached patch fixes all these AFAICS.

thanks,

Signature · 1 line
bvk.chaitanya

=== modified file 'Makefile.util.def'

Makefile.util.def +14 -14
@@ -99,7 +99,7 @@
   name = grub-bin2h;
   common = util/bin2h.c;
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
   mansection = 1;
 };
 
@@ -112,7 +112,7 @@
   extra_dist = util/grub-mkimagexx.c;
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
   cppflags = '-DGRUB_PKGLIBROOTDIR=\"$(pkglibrootdir)\"';
 };
 
@@ -123,7 +123,7 @@
   common = util/grub-mkrelpath.c;
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
 };
 
 program = {
@@ -133,7 +133,7 @@
   common = util/grub-script-check.c;
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
 };
 
 program = {
@@ -143,7 +143,7 @@
   common = util/grub-editenv.c;
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
 };
 
 program = {
@@ -153,7 +153,7 @@
   common = util/grub-mkpasswd-pbkdf2.c;
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
   cflags = '$(CFLAGS_GCRY)';
   cppflags = '$(CPPFLAGS_GCRY)';
 };
@@ -171,7 +171,7 @@
   common = util/grub-pe2elf.c;
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL)';
+  ldadd = '$(LIBINTL)';
   condition = COND_GRUB_PE2ELF;
 };
 
@@ -181,7 +181,7 @@
   common = util/grub-fstest.c;
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
   condition = COND_GRUB_FSTEST;
 };
 
@@ -194,8 +194,8 @@
   cflags = '$(freetype_cflags)';
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER)';
-  ldflags = '$(freetype_libs)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER)';
+  ldadd = '$(freetype_libs)';
   condition = COND_GRUB_MKFONT;
 };
 
@@ -212,7 +212,7 @@
   sparc64_ieee1275 = util/ieee1275/devicemap.c;
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
 };
 
 program = {
@@ -222,7 +222,7 @@
   common = util/grub-probe.c;
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
 };
 
 program = {
@@ -239,7 +239,7 @@
   sparc64_ieee1275 = util/lvm.c;
 
   ldadd = libgrub.a;
-  ldflags = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
+  ldadd = '$(LIBINTL) $(LIBDEVMAPPER) $(LIBUTIL)';
 
   enable = i386_pc;
   enable = sparc64_ieee1275;
@@ -506,5 +506,5 @@
   common = grub-core/tests/lib/test.c;
   cflags = -Wno-format;
   ldadd = libgrub.a;
-  ldflags = '$(LIBDEVMAPPER)';
+  ldadd = '$(LIBDEVMAPPER)';
 };
#3 lore raw
Quoted 12 lines · BVK Chaitanya
Quoted 9 lines · Christian Franke
$ grep ^grub_bin2h_LD Makefile
grub_bin2h_LDADD = libgrub.a
grub_bin2h_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_PROGRAM) $(LIBINTL)
$(LIBDEVMAPPER)

The above should be:
grub_bin2h_LDADD = libgrub.a $(LIBINTL) $(LIBDEVMAPPER) grub_bin2h_LDFLAGS = $(AM_LDFLAGS) $(LDFLAGS_PROGRAM)

Quoted 7 lines
Quoted 3 lines

Same for all other utils. This likely needs to be fixed in gentpl.py.

It is not necessary to modify gentpl.py, fixing in Makefile.util.def should be sufficient. Attached patch fixes all these AFAICS.

With the patch it works, thanks! Please apply.

Signature · 2 lines
Regards,
Christian Franke