Results 1 to 5 of 5

Thread: "Undefined Reference to" using make

  1. #1
    Join Date
    Mar 2009
    Beans
    23
    Distro
    Ubuntu Jaunty Jackalope (testing)

    "Undefined Reference to" using make

    Hi - I was trying to install software (dfu-programmer) from source to fix my arduino:http://arduino.cc/forum/index.php/to...html#msg692355. It is from source so that I can change it for my 16u2 instead of 8u2.

    THE PROBLEM: I think I modified the source OK, but after I
    Code:
    ./boostrap.sh
    and
    Code:
    ./configure
    , and then try to
    Code:
    make
    I get errors:

    Code:
    ...
    ...
    ...
    dfu.o: In function `dfu_device_init':
    /home/paul/Desktop/dfu-programmer-0.5.4/src/dfu.c:419: undefined reference to `libusb_claim_interface'
    /home/paul/Desktop/dfu-programmer-0.5.4/src/dfu.c:436: undefined reference to `libusb_release_interface'
    /home/paul/Desktop/dfu-programmer-0.5.4/src/dfu.c:426: undefined reference to `libusb_free_device_list'
    dfu.o: In function `dfu_make_idle':
    /home/paul/Desktop/dfu-programmer-0.5.4/src/dfu.c:814: undefined reference to `libusb_reset_device'
    dfu.o: In function `dfu_device_init':
    /home/paul/Desktop/dfu-programmer-0.5.4/src/dfu.c:431: undefined reference to `libusb_free_device_list'
    collect2: ld returned 1 exit status
    make[2]: *** [dfu-programmer] Error 1
    make[2]: Leaving directory `/home/paul/Desktop/dfu-programmer-0.5.4/src'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/home/paul/Desktop/dfu-programmer-0.5.4'
    make: *** [all] Error 2
    When searching online for an answer I think it might have something to do with headers or linking or pkg-config. I don't have much experience with C (if it's even the issue- the file extensions in the folder have .c and .h). In case this helps you help me:
    Code:
    paul@paul-laptop:~/Desktop/dfu-programmer-0.5.4$ pkg-config --cflags libusb-1.0
    -I/usr/include/libusb-1.0  
    paul@paul-laptop:~/Desktop/dfu-programmer-0.5.4$ pkg-config --libs libusb-1.0
    
    -lusb-1.0

    I spent hours try to get my board working yesterday. I even tried using Windows. Does anyone know what's going on with the
    Code:
    make
    ?

    Thank you.

  2. #2
    Join Date
    Apr 2009
    Location
    Germany
    Beans
    2,134
    Distro
    Ubuntu Development Release

    Re: "Undefined Reference to" using make

    move -lusb-1.0 from LDFLAGS to LIBS in src/Makefile and it should work

    or replace LDFLAGS occurrences in configure.ac with LIBS and running bootstrap again
    Last edited by MadCow108; April 28th, 2012 at 10:24 PM.

  3. #3
    Join Date
    Mar 2009
    Beans
    23
    Distro
    Ubuntu Jaunty Jackalope (testing)

    Re: "Undefined Reference to" using make

    Thank you.

    I didn't get it to work, though. This is from src/Makefile.in

    Code:
    INSTALL_PROGRAM = @INSTALL_PROGRAM@
    INSTALL_SCRIPT = @INSTALL_SCRIPT@
    INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
    LDFLAGS = @LDFLAGS@
    LIBOBJS = @LIBOBJS@
    LIBS = @LIBS@
    LIBUSB_1_0_CFLAGS = @LIBUSB_1_0_CFLAGS@
    I changed @LIBS@ to -lusb-1.0

    I also tried changing it in the main folder (not src) Makefile(no file extension)
    Code:
    INSTALL_SCRIPT = ${INSTALL}
    INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
    LDFLAGS =  -lusb-1.0  
    LIBOBJS = 
    LIBS = <-----THIS IS WHERE I MOVED -LUSB-1.0>
    LIBUSB_1_0_CFLAGS = -I/usr/include/libusb-1.0  
    LIBUSB_1_0_LIBS = -lusb-1.0  
    LTLIBOBJS =
    I'll try the "or replace LDFLAGS occurrences in configure.ac with LIBS and running bootstrap again"

  4. #4
    Join Date
    Mar 2009
    Beans
    23
    Distro
    Ubuntu Jaunty Jackalope (testing)

    Re: "Undefined Reference to" using make

    In the main folder (not src)/configure.ac I did a Find and Replace "LDFLAGS" --> "LIBS" in all cases and I think I got it installed.

    Thank you for your help MadCow108. If you don't mind, I'd appreciate it if you told me what that did or what that fixed. Can you refer me to a subject that it was about? Is it a C program language thing, or a general linux thing?

    If it's over my head or would take to long to explain that's fine to.

    Thanks again for your help. (hopefully now I can use the software to fix my arduino board)
    Last edited by enabulator; April 28th, 2012 at 10:58 PM.

  5. #5
    Join Date
    Apr 2009
    Location
    Germany
    Beans
    2,134
    Distro
    Ubuntu Development Release

    Re: "Undefined Reference to" using make

    its a bug in the configure.ac, it uses the LDFLAGS variable to tell the compiler which libraries it should link.
    This is wrong, for that the LIBS variable should be used (in this case)
    LDFLAGS is for other linker flags (like symbolic-functions, as-needed, no-dt-needed etc.)

    the makefile outputs something like this:
    gcc $CFLAGS $LDFLAGS $OBJECTS $LIBS

    ubuntus gcc/ld requires libraries to be placed behind objects needing else it will ignore them (see man ld, there look for --as-needed).

    the configure.ac creates a configure and a Makefile.in after you run bootstrap.
    the configure creates a Makefile from the Makefile.in when you run it.
    make then executes the Makefile
    google autotools/automake/autoconf for more information

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •