mike632t/x11-calc

Problem on building on Ubuntu 20.04

ecsfang opened this issue · 3 comments

Hi,

When building with make I get a lot of link-errors, and the problems seems to be the order of libraries on the command line.
By default, the libraries comes first, but if I change the order, then it works fine and compiles without any problems.

"make hp35 --trace" shows (lot of outputs removed):

...
cc -lX11 -lm -no-pie x11-calc.o x11-calc-cpu.o x11-calc-display.o x11-calc-segment.o x11-calc-button.o x11-calc-switch.o x11-calc-label.o x11-calc-colour.o x11-keyboard.o x11-calc-messages.o gcc-wait.o x11-calc-35.o -o ../bin/../bin/x11-calc-35
/usr/bin/ld: x11-calc.o: in function `v_set_blank_cursor':
x11-calc.c:(.text+0x327): undefined reference to `XCreateBitmapFromData'
/usr/bin/ld: x11-calc.c:(.text+0x356): undefined reference to `XCreatePixmapCursor'
/usr/bin/ld: x11-calc.c:(.text+0x374): undefined reference to `XFreePixmap'
/usr/bin/ld: x11-calc.o: in function `main':
...
/usr/bin/ld: x11-keyboard.c:(.text+0x2ab): undefined reference to `XKeycodeToKeysym'
/usr/bin/ld: x11-keyboard.c:(.text+0x2d7): undefined reference to `XKeycodeToKeysym'
collect2: error: ld returned 1 exit status
make[1]: *** [makefile:99: ../bin/x11-calc-35] Error 1
make: *** [makefile:54: hp35] Error 2

Note that eg "-lX11" comes first on the line directly after "cc"

Changing the order in the makefile (./src/makefile line 97)
from:
@$(CC) $(LIBS) $(OBJECTS) -o ../bin/$@
to:
@$(CC) $(OBJECTS) $(LIBS) -o ../bin/$@
then make works fine (make all --trace) :

...
cc x11-calc.o x11-calc-cpu.o x11-calc-display.o x11-calc-segment.o x11-calc-button.o x11-calc-switch.o x11-calc-label.o x11-calc-colour.o x11-keyboard.o x11-calc-messages.o gcc-wait.o x11-calc-35.o -lX11 -lm -no-pie  -o ../bin/../bin/x11-calc-35
...
makefile:97: update target '../bin/x11-calc-16c' due to: x11-calc.o x11-calc-cpu.o x11-calc-display.o x11-calc-segment.o x11-calc-button.o x11-calc-switch.o x11-calc-label.o x11-calc-colour.o x11-keyboard.o x11-calc-messages.o gcc-wait.o x11-calc-16c.o
cc x11-calc.o x11-calc-cpu.o x11-calc-display.o x11-calc-segment.o x11-calc-button.o x11-calc-switch.o x11-calc-label.o x11-calc-colour.o x11-keyboard.o x11-calc-messages.o gcc-wait.o x11-calc-16c.o -lX11 -lm -no-pie  -o ../bin/../bin/x11-calc-16c

Only difference is that the reference to the libraries are at the end of the command line.
I have not built on other systems, so I don't know how this affects there ...

The version of the compiler I use is:

$ cc --version
cc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Copyright (C) 2019 Free Software Foundation, Inc.

Cheers,
Thomas

Thank you - I was able to reproduce the problem on Debian GNU/Linux 11 (bullseye).

It should be resolved now !

Tested with:

$ cc --version cc 
(Debian 10.2.1-6) 10.2.1 20210110  
Copyright (C) 2020 Free Software Foundation, Inc. 
This is free software; see the source for copying conditions.  There is NO 
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Latest stable commit should have fixed the problem. Can you confirm?

Thanks.

Hi!

Thanks for the update!
Yes, I can confirm that it works fine in my environment now!

Cheers,
Thomas