bugGNU Robots - Bugs: bug #57036, build fails with undefined...

 
 

bug #57036: build fails with undefined symbols, should use LDADD instead of LDFLAGS

Submitter:  Mike Miller <mtmiller>
Submitted:  Thu 10 Oct 2019 06:44:10 PM UTC
   
 
Severity:  3 - Normal Status:  Fixed
Privacy:  Public Assigned to:  rozzin
Open/Closed:  Closed Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 08 Feb 2021 06:49:42 AM UTC, comment #3: 

Committed and pushed to master! Sorry for the incredibly long wait....

Joshua Judson Rosen <rozzin>
Group administrator
Mon 28 Oct 2019 05:35:33 PM UTC, comment #2: 

Debian testing here, all dependencies are installed from Debian as well.

  • GTHREAD2_LIBS = -pthread -lgthread-2.0 -lglib-2.0
  • GUILE_LDFLAGS = -lguile-2.2 -lgc
  • GUILE_LIBS = -lguile-2.2 -lgc


These values are fine, of course, it's their relative position on the command line that needs to be fixed. Here is the full link command line on my system, broken out and -I and -D elided for clarity:


gcc -Wall -pthread
  -I... (dozens of -I options)
  -D... (handful of -D options)
  -g -O2
  -lguile-2.2 -lgc
  -pthread -lgthread-2.0 -lglib-2.0
  -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo
  -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0
  -lglib-2.0 -lfontconfig -lfreetype -lvte -lgtk-x11-2.0 -lgdk-x11-2.0
  -lpangocairo-1.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangoft2-1.0 -lpango-1.0
  -lfontconfig -lfreetype -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lcairo -lX11
  -lXext -lutil
  -o gnurobots
  main.o api.o map.o grobot.o ui-window.o ui-cmdwin.o ui-arena.o
  -lguile-2.2 -lutil


The only library arguments after the object files "main.o api.o" and so on, are the ones that are used by the linker to resolve external symbols. The problem is that all of the Gtk and GLib libraries come before main.o in the command line, so they are effectively ignored.

Mike Miller <mtmiller>
Mon 28 Oct 2019 04:35:41 AM UTC, comment #1: 

Good catch!

Interestingly it doesn't cause problems here on Debian 9/Stretch with their prepackaged libs so I didn't notice it, but I can certainly see how it could cause problems.

Can you say what OS/distribution you're building on, and what your GUILE_LDFLAGS / GUILE_LIBS / GTHREAD2_LIBS values look like?

Joshua Judson Rosen <rozzin>
Group administrator
Thu 10 Oct 2019 06:44:10 PM UTC, original submission:  

Building gnurobots master fails for me due to undefined symbols from the glib and gtk libraries, for example


/usr/bin/ld: main.o: in function `callback_scm':
/src/gnurobots/src/main.c:272: undefined reference to `g_printf'
/usr/bin/ld: /src/gnurobots/src/main.c:273: undefined reference to `g_printf'
/usr/bin/ld: /src/gnurobots/src/main.c:274: undefined reference to `g_printf'
/usr/bin/ld: /src/gnurobots/src/main.c:275: undefined reference to `g_printf'
/usr/bin/ld: /src/gnurobots/src/main.c:277: undefined reference to `g_printf'


This is because the "-l" options are in the automake LDFLAGS variable, but they should be in the LDADD variable (see https://www.gnu.org/software/automake/manual/html_node/Linking.html).

The attached patch fixes this for me. The GUILE_LDFLAGS variable is appropriate to include in gnurobots_LDFLAGS, because it may include -L or -Wl options, for example. The GUILE_LIBS variable is intended for use in LDADD, because it only contains -l library arguments.

Mike Miller <mtmiller>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #47645:  gnurobots-ldadd.patch added by mtmiller (1KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by rozzin (Posted a comment)
  • -email is unavailable- added by mtmiller (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2021-02-08 rozzin Open/ClosedOpen Closed
    2021-02-08 rozzin StatusIn Progress Fixed
    2019-10-28 rozzin StatusNone In Progress
        Assigned toNone rozzin
    2019-10-10 mtmiller Attached File- Added gnurobots-ldadd.patch, #47645

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code