编译 /usr/bin/ld 命令行中缺少对 XMapSubwindows 和 DSO 的未定义引用
compiling /usr/bin/ld undefined reference to XMapSubwindows and DSO missing from command line
我正在尝试在 Debian 上编译我打过补丁的 dwm。
这是我的 config.mk 文件,它主要来自 apt source dwm
,但补丁添加了一些额外的库,我不得不自己添加两个 -Ifreetype2 链接:
# dwm version
VERSION = 6.1
# Customize below to fit your system
# paths
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man
# Xinerama, comment if you don't want it
XINERAMALIBS = -lXinerama
XINERAMAFLAGS = -DXINERAMA
# freetype
FREETYPELIBS = -lfontconfig -lXft
FREETYPEINC = /usr/include/freetype2
# OpenBSD (uncomment)
#FREETYPEINC = ${X11INC}/freetype2
# includes and libs
INCS = -I${X11INC} -I${FREETYPEINC} -I/usr/include/freetype2 -I/usr/include/libpng16
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender -lX11-xcb -lxcb -lxcb-res
# flags
CPPFLAGS += -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
CFLAGS += -std=c99 -pedantic -Wall -Wno-deprecated-declarations ${INCS} ${CPPFLAGS}
LDFLAGS += -s ${LIBS}
# Solaris
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
#LDFLAGS = ${LIBS}
# compiler and linker
CC = cc
这是我在 运行 make clean install
时得到的错误
cc -o dwm drw.o dwm.o util.o -s -L -lX11 -lXinerama -lfontconfig -lXft -lXrender -lX11-xcb -lxcb -lxcb-res
/usr/bin/ld: dwm.o: undefined reference to symbol 'XMapSubwindows'
/usr/bin/ld: //lib/x86_64-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [Makefile:29: dwm] Error 1
但我不知道如何解决这个问题。我需要安装库吗?我需要向 libs 变量添加一些东西吗?请帮忙!
我试过查看 this,但我不知道 "DSO" 是什么,也不知道如何修复链接。
不确定这是否是唯一的问题,但您的 link 行...
cc -o dwm drw.o dwm.o util.o -s -L -lX11 -lXinerama -lfontconfig -lXft -lXrender -lX11-xcb -lxcb -lxcb-res
似乎有一个没有参数的 -L
选项。或者,更准确地说,它会假定其参数为 -lX11
。我假设这是因为变量 X11LIB
在您的 makefile 中未指定。不确定 X11LIB
应该如何用您正在使用的 makefile 指定,但您可以尝试明确设置它...
X11LIB := /usr/lib64 # Assumes the path to libX11.so is /usr/lib64/libX11.so
-L -lX11
这意味着 "add a directory named -lX11
to the library search path"。这不太可能有任何影响,因为这样的目录可能不存在。
删除 -L
或在其后添加一个非空目录参数。
我正在尝试在 Debian 上编译我打过补丁的 dwm。
这是我的 config.mk 文件,它主要来自 apt source dwm
,但补丁添加了一些额外的库,我不得不自己添加两个 -Ifreetype2 链接:
# dwm version
VERSION = 6.1
# Customize below to fit your system
# paths
PREFIX = /usr/local
MANPREFIX = ${PREFIX}/share/man
# Xinerama, comment if you don't want it
XINERAMALIBS = -lXinerama
XINERAMAFLAGS = -DXINERAMA
# freetype
FREETYPELIBS = -lfontconfig -lXft
FREETYPEINC = /usr/include/freetype2
# OpenBSD (uncomment)
#FREETYPEINC = ${X11INC}/freetype2
# includes and libs
INCS = -I${X11INC} -I${FREETYPEINC} -I/usr/include/freetype2 -I/usr/include/libpng16
LIBS = -L${X11LIB} -lX11 ${XINERAMALIBS} ${FREETYPELIBS} -lXrender -lX11-xcb -lxcb -lxcb-res
# flags
CPPFLAGS += -D_BSD_SOURCE -D_POSIX_C_SOURCE=2 -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
#CFLAGS = -g -std=c99 -pedantic -Wall -O0 ${INCS} ${CPPFLAGS}
CFLAGS += -std=c99 -pedantic -Wall -Wno-deprecated-declarations ${INCS} ${CPPFLAGS}
LDFLAGS += -s ${LIBS}
# Solaris
#CFLAGS = -fast ${INCS} -DVERSION=\"${VERSION}\"
#LDFLAGS = ${LIBS}
# compiler and linker
CC = cc
这是我在 运行 make clean install
cc -o dwm drw.o dwm.o util.o -s -L -lX11 -lXinerama -lfontconfig -lXft -lXrender -lX11-xcb -lxcb -lxcb-res
/usr/bin/ld: dwm.o: undefined reference to symbol 'XMapSubwindows'
/usr/bin/ld: //lib/x86_64-linux-gnu/libX11.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
make: *** [Makefile:29: dwm] Error 1
但我不知道如何解决这个问题。我需要安装库吗?我需要向 libs 变量添加一些东西吗?请帮忙!
我试过查看 this,但我不知道 "DSO" 是什么,也不知道如何修复链接。
不确定这是否是唯一的问题,但您的 link 行...
cc -o dwm drw.o dwm.o util.o -s -L -lX11 -lXinerama -lfontconfig -lXft -lXrender -lX11-xcb -lxcb -lxcb-res
似乎有一个没有参数的 -L
选项。或者,更准确地说,它会假定其参数为 -lX11
。我假设这是因为变量 X11LIB
在您的 makefile 中未指定。不确定 X11LIB
应该如何用您正在使用的 makefile 指定,但您可以尝试明确设置它...
X11LIB := /usr/lib64 # Assumes the path to libX11.so is /usr/lib64/libX11.so
-L -lX11
这意味着 "add a directory named -lX11
to the library search path"。这不太可能有任何影响,因为这样的目录可能不存在。
删除 -L
或在其后添加一个非空目录参数。