cannot find -lX11
Solution 1
as you can see in the compilation command itself:
gcc -O2 -pipe -Wl,--export-dynamic tkAppInit.o -L/home/dimitriv/ns-allinone-2.35/tk8.5.10/unix -ltk8.5 \
-L/home/dimitriv/ns-allinone-2.35/tcl8.5.10/unix -ltcl8.5 -lX11 -ldl -lieee -lm -Wl,-rpath,/home/dimitriv/ns-allinone-2.35/lib -o wish
the path
-L/home/dimitriv/local/lib
is not added.Add it in your make file and then check.
Solution 2
The LD_LIBRARY_PATH
contains paths to shared libraries which are used by the loader (ld
program) to get the program to execute.
During compilation, include directories are used. During linking, object libraries are needed. The last one is the kind you are missing.
You might have to install a package to get the X11 development libraries. On Linux, the package is called libX11-devel
. To install,
sudo yum install libX11-devel # for Redhat, Fedora, etc.
or
sudo apt-get install libX11-devel # for Ubuntu, etc.
Solution 3
Solution: Install the missing packages using
sudo apt-get install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
user000001
Updated on June 04, 2022Comments
-
user000001 almost 2 years
I am trying to compile a program, and the linking fails with the following message:
gcc -O2 -pipe -Wl,--export-dynamic tkAppInit.o -L/home/dimitriv/ns-allinone-2.35/tk8.5.10/unix -ltk8.5 \
-L/home/dimitriv/ns-allinone-2.35/tcl8.5.10/unix -ltcl8.5 -lX11 -ldl -lieee -lm -Wl,-rpath,/home/dimitriv/ns-allinone-2.35/lib -o wish /usr/bin/ld: cannot find -lX11
collect2: error: ld returned 1 exit statushowever, my
$LD_LIBRARY_PATH
contains the directory where X11 has been installed:echo $LD_LIBRARY_PATH
/share/apps/cim/lib:/opt/ns2/otcl-1.13:/opt/ns2/lib:/home/dimitriv/local/lib:and the libraries seem to be correctly installed.
ls /home/dimitriv/local/lib | grep X11
libX11.a
libX11.la
libX11.so
libX11.so.6
libX11.so.6.3.0
libX11-xcb.a
libX11-xcb.la
libX11-xcb.so
libX11-xcb.so.1
libX11-xcb.so.1.0.0
X11Why can't make locate the libraries and do the linking?
-
user000001 over 11 yearsok I will check. But shouldn't it check in the LD_LIBRARY_PATH anyway?
-
Yann Droneaud over 11 yearsThe devel packages are needed to provide the
libX11.so
whichld
is looking for. (note: thelibX11.so
is usually a symbolic link tolibX11.so.6
, which is in turn a symbolic link to the current version of the librarylibX11.so.6.3.0
). Seeldconfig
-
Yann Droneaud over 11 years@user828193 only at runtime. The
LD_LIBRARY_PATH
variable is only used by the dynamic linker when running the program. -
user000001 over 11 yearsI couldn't figure out where to change the Makefile, but I added the flag, ran it from the command line and seemed to work. I will report back to see it has any side effects.
-
user000001 over 11 yearsUnfortunately I can't install anything with yum, because I am not a sudoer. I have installed
libX11-1.5.0
from source. I can only find libX11-dev in a package, could you point out where I could locate the source for it? Also @ydroneaud, as you can seelibX11.so
exists in the above directory... MaybelibX11-dev
is not needed after all? -
user000001 over 5 yearsThis answer is the best in cases where you have
sudo
permission and can install packages. The reason I wanted to compile the package though was precisely the missing permission.