Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Compiling DWMBlocks

Programming languages, Coding, Executables, Package Creation, and Scripting.
Post Reply
Message
Author
User avatar
cds60601
df -h | participant
df -h | participant
Posts: 706
Joined: 2017-11-25 05:58
Location: Florida
Has thanked: 129 times
Been thanked: 60 times

Compiling DWMBlocks

#1 Post by cds60601 »

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.
Supercalifragilisticexpialidocious

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Compiling DWMBlocks

#2 Post by stevepusser »

It seems to be a compiler error. What compiler and version are you using?
MX Linux packager and developer

LE_746F6D617A7A69
Posts: 932
Joined: 2020-05-03 14:16
Has thanked: 7 times
Been thanked: 65 times

Re: Compiling DWMBlocks

#3 Post by LE_746F6D617A7A69 »

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

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Compiling DWMBlocks

#4 Post by Head_on_a_Stick »

deadbang

LE_746F6D617A7A69
Posts: 932
Joined: 2020-05-03 14:16
Has thanked: 7 times
Been thanked: 65 times

Re: Compiling DWMBlocks

#5 Post by LE_746F6D617A7A69 »

^ 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

User avatar
cds60601
df -h | participant
df -h | participant
Posts: 706
Joined: 2017-11-25 05:58
Location: Florida
Has thanked: 129 times
Been thanked: 60 times

Re: Compiling DWMBlocks

#6 Post by cds60601 »

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:~$ 
Supercalifragilisticexpialidocious

LE_746F6D617A7A69
Posts: 932
Joined: 2020-05-03 14:16
Has thanked: 7 times
Been thanked: 65 times

Re: Compiling DWMBlocks

#7 Post by LE_746F6D617A7A69 »

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

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Compiling DWMBlocks

#8 Post by Head_on_a_Stick »

And perhaps also try Clang instead of GCC:

Code: Select all

CC=clang make
deadbang

LE_746F6D617A7A69
Posts: 932
Joined: 2020-05-03 14:16
Has thanked: 7 times
Been thanked: 65 times

Re: Compiling DWMBlocks

#9 Post by LE_746F6D617A7A69 »

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

Post Reply