Compiling DWMBlocks

Need help with C, C++, perl, python, etc?

Compiling DWMBlocks

Postby cds60601 » 2020-09-13 14:24

I'm hoping this sub-board is appropriate for this question.
I'm having errors when doing a make for dwmblocks and I'm hoping this might find its way to a DWM user.

Code: Select all
chris@mars:~/dwmblocks$ make
cp blocks.def.h blocks.h
cc `pkg-config --cflags x11 --libs x11` dwmblocks.c -o dwmblocks
/usr/bin/ld: /tmp/cc2DtK0H.o: in function `setroot':
dwmblocks.c:(.text+0x3d7): undefined reference to `XStoreName'
/usr/bin/ld: dwmblocks.c:(.text+0x3e6): undefined reference to `XFlush'
/usr/bin/ld: /tmp/cc2DtK0H.o: in function `setupX':
dwmblocks.c:(.text+0x3f9): undefined reference to `XOpenDisplay'
/usr/bin/ld: /tmp/cc2DtK0H.o: in function `main':
dwmblocks.c:(.text+0x6b9): undefined reference to `XCloseDisplay'
collect2: error: ld returned 1 exit status
make: *** [Makefile:5: output] Error 1


I appear to have all the bits in place since I don't have an issue compiling dwm.
Any help would be nice please.
Server: Debian 10 (Pi), Workstation: Debian Sid (BSPWM)
Laptop: Debian Sid (BSPWM)
----------------------------------------------------------------------------------
Don't Break Debian: https://wiki.debian.org/DontBreakDebian
User avatar
cds60601
 
Posts: 196
Joined: 2017-11-25 05:58
Location: Tampa, Florida

Re: Compiling DWMBlocks

Postby stevepusser » 2020-09-14 03:38

It seems to be a compiler error. What compiler and version are you using?
MX Linux packager and developer
User avatar
stevepusser
 
Posts: 11983
Joined: 2009-10-06 05:53

Re: Compiling DWMBlocks

Postby LE_746F6D617A7A69 » 2020-09-14 05:00

All the functions which have produced linker errors are provided by the Xlib, what means that:
a) there's a problem with pkg-config: execute the following cmd in the terminal:
Code: Select all
$>pkg-config --cflags x11 --libs x11
It should output a string containing "-lX11" (without quotes) - if not, You may try to change the makefile's output rule:
Code: Select all
output: dwmblocks.c blocks.def.h blocks.h
   ${CC} -lX11 dwmblocks.c -o dwmblocks

b) there's a problem with Xlib installation, check the output of:
Code: Select all
sudo ldconfig -v | grep X11 #update the caches and show the version of libX11 currently used by the linker.
sudo find / -name libX11.so* #find the location of the libX11
The location of X11 can be used to instruct the compiler and the linker where to search for the libs, f.e. -L/usr/lib/x86_64-linux-gnu/
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed
LE_746F6D617A7A69
 
Posts: 342
Joined: 2020-05-03 14:16

Re: Compiling DWMBlocks

Postby Head_on_a_Stick » 2020-09-14 16:29

Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 12488
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Compiling DWMBlocks

Postby LE_746F6D617A7A69 » 2020-09-14 19:46

^ This

It means that the problem is with pkgconfig metadata in Sid/Ubuntu and *not* with the project -> it should be reported as a bug in Sid. (I'm assuming that it's Sid, judging by the cds60601's signature)

But anyway it's really strange - Xlib is one of the most fundamental libs - it's unbelievable that than someone have managed to break it ...
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed
LE_746F6D617A7A69
 
Posts: 342
Joined: 2020-05-03 14:16

Re: Compiling DWMBlocks

Postby cds60601 » 2020-09-15 22:26

Here ya go fellas - sorry for the late responce...

Code: Select all
chris@mars:~$ pkg-config --cflags x11 --libs x11
-lX11
chris@mars:~$ sudo ldconfig -v | grep X11 #update the caches and show the version of libX11 currently used by the linker.
[sudo] password for chris:
ldconfig: Can't stat /usr/local/lib/x86_64-linux-gnu: No such file or directory
ldconfig: Path `/usr/lib/x86_64-linux-gnu' given more than once
ldconfig: Path `/lib/x86_64-linux-gnu' given more than once
ldconfig: Path `/usr/lib/x86_64-linux-gnu' given more than once
ldconfig: Path `/usr/lib' given more than once
   libQt5X11Extras.so.5 -> libQt5X11Extras.so.5.14.2
   libX11.so.6 -> libX11.so.6.3.0
ldconfig: /lib/x86_64-linux-gnu/ld-2.31.so is the dynamic linker, ignoring

   libX11-xcb.so.1 -> libX11-xcb.so.1.0.0
chris@mars:~$ sudo find / -name libX11.so* #find the location of the libX11
/usr/lib/x86_64-linux-gnu/libX11.so
/usr/lib/x86_64-linux-gnu/libX11.so.6.3.0
/usr/lib/x86_64-linux-gnu/libX11.so.6
chris@mars:~$
Server: Debian 10 (Pi), Workstation: Debian Sid (BSPWM)
Laptop: Debian Sid (BSPWM)
----------------------------------------------------------------------------------
Don't Break Debian: https://wiki.debian.org/DontBreakDebian
User avatar
cds60601
 
Posts: 196
Joined: 2017-11-25 05:58
Location: Tampa, Florida

Re: Compiling DWMBlocks

Postby LE_746F6D617A7A69 » 2020-09-16 04:54

What happens if You replace the "pkg-config --cflags x11 --libs x11" with just "-lX11" in the makefile? (no quotes ofc.)

Can You check the pkg-config metadata?
Code: Select all
cat /usr/lib/x86_64-linux-gnu/pkgconfig/x11.pc
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed
LE_746F6D617A7A69
 
Posts: 342
Joined: 2020-05-03 14:16

Re: Compiling DWMBlocks

Postby Head_on_a_Stick » 2020-09-16 13:20

And perhaps also try Clang instead of GCC:
Code: Select all
CC=clang make
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Head_on_a_Stick
 
Posts: 12488
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Compiling DWMBlocks

Postby LE_746F6D617A7A69 » 2020-09-16 19:40

That's interesting, because this is *NOT* a compiler error - it's the linker which is failing...

I was wrong - the problem is with the project, namely with the makefile - incorrect syntax for gcc: (but it would work in older versions)
Replace the "output" rule in the makefile with the following snippet:
Code: Select all
output: dwmblocks.c blocks.def.h blocks.h
   ${CC} -c dwmblocks.c -o dwmblocks.o
   ${CC} -o dwmblocks dwmblocks.o `pkg-config --cflags x11 --libs x11`
This will work with both gcc and clang.

The trick is that the order of arguments for GCC determines which options are passed to the linker (ld) ;)

.
Bill Gates: "(...) In my case, I went to the garbage cans at the Computer Science Center and I fished out listings of their operating system."
The_full_story and Nothing_have_changed
LE_746F6D617A7A69
 
Posts: 342
Joined: 2020-05-03 14:16


Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

fashionable