Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#12 [PATCH] compilation fix

closed-duplicate
nobody
None
5
2012-12-20
2012-12-19
Igor Vlasenko
No

As -l<lib> should always be after *.o files, they should be added not in LDFLAGS, but in LIBS
as in proposed patch below.

--- dfu-programmer-0.5.4/configure.ac 2011-01-17 06:58:54.000000000 +0000
+++ dfu-programmer-0.5.4/configure.ac 2012-12-19 20:16:52.413341487 +0000
@@ -27,7 +27,7 @@
PKG_CHECK_MODULES(LIBUSB_1_0, [ libusb-1.0 >= 1.0.0 ], have_libusb_1_0=yes, have_libusb_1_0=no)
if test "$have_libusb_1_0" = "yes"; then
CFLAGS="$CFLAGS $LIBUSB_1_0_CFLAGS"
- LDFLAGS="$LDFLAGS $LIBUSB_1_0_LIBS"
+ LIBS="$LIBS $LIBUSB_1_0_LIBS"
HAVE_USB=yes
fi
fi
@@ -37,7 +37,7 @@
dnl libusb >= 0.1.8 is required, as we need usb_interrupt_read()
AC_CHECK_HEADER(usb.h,
AC_CHECK_LIB(usb, usb_interrupt_read,
- [LDFLAGS="$LDFLAGS -lusb"
+ [LIBS="$LIBS -lusb"
HAVE_USB=yes]))
fi

In some of the compiler configurations order of arguments does not matter (like default gcc configuration in Fedora)
but in some it does, like when compiling with -Wl,as-needed.

Without the proposed patch the compilation will fail on many distributions,. like
ALT Linux or PLD Linux, where -Wl,as-needed is enabled by default.

see peace of log below:
[...]
x86_64-alt-linux-gcc -Wall -pipe -Wall -g -O2 -I/usr/include/libusb-1.0 -lusb-1.0 -o dfu-programmer main.o arguments.o atmel.o commands.o dfu.o intel_hex.o util.o
main.o: In function `main':
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/main.c:58: undefined reference to `libusb_init'
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/main.c:108: undefined reference to `libusb_release_interface'
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/main.c:121: undefined reference to `libusb_close'
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/main.c:131: undefined reference to `libusb_exit'
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/main.c:79: undefined reference to `libusb_set_debug'
dfu.o: In function `dfu_transfer_out':
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/dfu.c:836: undefined reference to `libusb_control_transfer'
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/dfu.c:836: undefined reference to `libusb_control_transfer'
dfu.o: In function `dfu_transfer_in':
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/dfu.c:863: undefined reference to `libusb_control_transfer'
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/dfu.c:863: undefined reference to `libusb_control_transfer'
dfu.o: In function `dfu_transfer_out':
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/dfu.c:836: undefined reference to `libusb_control_transfer'
dfu.o:/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/dfu.c:863: more undefined references to `libusb_control_transfer' follow
dfu.o: In function `dfu_device_init':
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/dfu.c:388: undefined reference to `libusb_get_device_list'
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/dfu.c:394: undefined reference to `libusb_get_device_descriptor'
dfu.o: In function `dfu_find_interface':
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/dfu.c:677: undefined reference to `libusb_get_config_descriptor'
dfu.o: In function `dfu_device_init':
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/dfu.c:415: undefined reference to `libusb_open'
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/dfu.c:417: undefined reference to `libusb_set_configuration'
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/dfu.c:445: undefined reference to `libusb_close'
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/dfu.c:451: undefined reference to `libusb_free_device_list'
dfu.o: In function `dfu_find_interface':
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/dfu.c:716: undefined reference to `libusb_free_config_descriptor'
dfu.o: In function `dfu_device_init':
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/dfu.c:419: undefined reference to `libusb_claim_interface'
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/dfu.c:436: undefined reference to `libusb_release_interface'
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/dfu.c:426: undefined reference to `libusb_free_device_list'
dfu.o: In function `dfu_make_idle':
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/dfu.c:814: undefined reference to `libusb_reset_device'
dfu.o: In function `dfu_device_init':
/usr/src/RPM/BUILD/dfu-programmer-0.5.4/src/dfu.c:431: undefined reference to `libusb_free_device_list'
collect2: error: ld returned 1 exit status
make[2]: *** [dfu-programmer] Error 1

Discussion

  • Simon Large
    Simon Large
    2012-12-20

    • status: open --> closed-duplicate
     
  • Simon Large
    Simon Large
    2012-12-20

    Duplicate of 3521662.
    But using this patch because the otherwise identical patch supplied with the earlier issue is in git format :-)