usr/bin/ld: cannot find -lexpat - c++

I am trying compile a software with Scons I get an error saying,
usr/bin/ld: cannot find -lexpat
Can you please tell me how can I fix it? Thank you very much. Here's the full error message:
scons: Reading SConscript files ...
We're on a 64-bit machine
use 32-bit libs & executables even on 64 bit system
OSNAME = Linux-x86_64-32
No installation being done
scons: done reading SConscript files.
scons: Building targets ...
g++ -o src/examples/.Linux-x86_64-32/dana -m32 src/examples/.Linux-x86_64-32/dana.o -Lsrc/libsrc/.Linux-x86_64-32 -Lsrc/libsrc -Lsrc/libsrc++/.Linux-x86_64-32 -Lsrc/libsrc++ -levioxx -levio -lpthread -lexpat -lz -ldl -lm
/usr/bin/ld: cannot find -lexpat
collect2: error: ld returned 1 exit status
scons: *** [src/examples/.Linux-x86_64-32/dana] Error 1
scons: building terminated because of errors.

Below solution worked with me on Ubuntu 20.04:
sudo apt install libexpat-dev

I have had this same problem in Fedora 34. Doing
sudo yum install expat-devel
will solve the problem.

Related

Build curl lib with Mingw compiler

I want to use the curl lib in my project (c++ QT creator on windows), I download the zip lib file from the website https://curl.se/download.html (Version 7.82.0)
and I wanted to build it using the Makefile with this commend
mingw32-make mingw32 as described in the documentation https://curl.se/docs/install.html
but unfortunately, I am getting an error
mingw32-make mingw32
[....]
gcc -s -m32 -static -o curl.exe curl.res slist_wc.o tool_binmode.o tool_bname.o
tool_cb_dbg.o tool_cb_hdr.o tool_cb_prg.o tool_cb_rea.o tool_cb_see.o tool_cb_wrt.o
tool_cfgable.o tool_dirhie.o tool_doswin.o tool_easysrc.o tool_filetime.o tool_findfile.o
tool_formparse.o tool_getparam.o tool_getpass.o tool_help.o tool_helpers.o tool_hugehelp.o
tool_libinfo.o tool_listhelp.o tool_main.o tool_msgs.o tool_operate.o tool_operhlp.o
tool_panykey.o tool_paramhlp.o tool_parsecfg.o tool_progress.o tool_strdup.o tool_setopt.o
tool_sleep.o tool_urlglob.o tool_util.o tool_vms.o tool_writeout.o tool_writeout_json.o
tool_xattr.o strtoofft.o nonblock.o warnless.o curl_ctype.o curl_multibyte.o version_win32.o
dynbuf.o -L../lib -lcurl -lwldap32 -lws2_32
../lib\libcurl.a: error adding symbols: Archive has no index; run ranlib to add one
collect2.exe: error: ld returned 1 exit status
make[1]: *** [curl.exe] Fehler 1
make[1]: Leaving directory `D:/Dev/API/curl-7.82.0/src'
make: *** [mingw32] Fehler 2
I tried to run ranlib lib\libcurl.a but the issue is still there,
does anyone have an idea about it?
One more question: is it possible also to build it with mingw64?

How to build Shim from source

I'm trying to build shim from source but i'm getting the following error.
ld -o shimx64.so --hash-style=sysv -nostdlib -znocombreloc -T /home/john/git/shim/elf_x86_64_efi.lds -shared -Bsymbolic -L/usr/lib64/gnuefi -L/usr/lib64 -LCryptlib -LCryptlib/OpenSSL /usr/lib64/gnuefi/crt0-efi-x86_64.o --build-id=sha1 --no-undefined shim.o mok.o netboot.o cert.o replacements.o tpm.o version.o errlog.o Cryptlib/libcryptlib.a Cryptlib/OpenSSL/libopenssl.a lib/lib.a -lefi -lgnuefi --start-group Cryptlib/libcryptlib.a Cryptlib/OpenSSL/libopenssl.a --end-group /usr/lib/gcc/x86_64-linux-gnu/9/libgcc.a
ld: cannot find /usr/lib64/gnuefi/crt0-efi-x86_64.o: No such file or directory
ld: cannot find -lefi
ld: cannot find -lgnuefi
make: *** [Makefile:92: shimx64.so] Error 1
Any help would be much appreciated, thanks.
My environment
System
Ubuntu 20.04.1 LTS
Packages
build-essential
make
gnu-efi
Update
Thomas answer helped me build but when running
make EFIDIR=/boot/efi install
I get the following error
gcc -Og -g3 -Wall -Werror -Wextra -o buildid /home/john/git/shim/buildid.c -lelf
/home/john/git/shim/buildid.c:15:10: fatal error: libelf.h: No such file or directory
15 | #include <libelf.h>
| ^~~~~~~~~~
compilation terminated.
make: *** [Makefile:117: buildid] Error 1
Tried adding the same variables as per Thomas answer but did not work.
Looking at the file list of the gnu-efi package, I see:
/usr/lib/crt0-efi-x86_64.o (not /usr/lib64/gnuefi/crt0-efi-x86_64.o)
/usr/lib/libefi.a (not in /usr/lib64)
/usr/lib/libgnuefi.a (not in /usr/lib64)
I think you need to set LIBDIR=/usr/lib and EFI_PATH=/usr/lib during make, rather than the defaults which are /usr/lib64 (set here) and /usr/lib64/gnuefi (set here).

errors during link when building glfw in fedora 27

When i try to make the project i get :
[pepe#localhost glfw-3.2.1]$ make
....
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/7/../../../libXinerama.so when searching for -lXinerama
/usr/bin/ld: skipping incompatible //lib/libXinerama.so when searching for -lXinerama
/usr/bin/ld: skipping incompatible //usr/lib/libXinerama.so when searching for -lXinerama
/usr/bin/ld: cannot find -lXinerama
collect2: error: ld returned 1 exit status
make[2]: *** [examples/CMakeFiles/wave.dir/build.make:129: examples/wave] Error 1
make[1]: *** [CMakeFiles/Makefile2:185: examples/CMakeFiles/wave.dir/all] Error 2
make: *** [Makefile:130: all] Error 2
I have xinerama installed but aparently there is no way to link it with make.
See all of those "skipping incompatible" messages? That is because those libraries have the wrong instruction set.
It looks to me as if it is trying to build 32 bit code against 64-bit libraries. Or vice versa.
Here is what I get on my Fedora system for a library search. You need to install the right "*-devel" package for your build type. You can't have both the i686 and x86_64 devel packages installed at the same time.
$ sudo dnf list 'libXine*'
Installed Packages
libXinerama.i686 1.1.3-9.fc27 #fedora
libXinerama.x86_64 1.1.3-9.fc27 #fedora
Available Packages
libXinerama-devel.i686 1.1.3-9.fc27 fedora
libXinerama-devel.x86_64 1.1.3-9.fc27 fedora
This will do for glfw-3.2.1 :
dnf install mesa-libGL-devel.x86_64 libXi-devel.x86_64 libXcursor-devel.x86_64 doxygen libXrandr-devel.x86_64 libXmu-devel libXinerama-devel.x86_64
cd glfw-3.2.1/
mkdir build
cd build/
cmake ../
make

linking things in c++ using object file

PROBLEM SOLVED:::
I am using LEDA library in c++.
command used to make object file.
g++ -I$LEDAROOT/incl -c mult.cpp
this command runs fine
I am getting eroor while linking step.
HERE IS THE EROOR
varun#Kinley:~/Documents/LEDA/test/numbers$ g++ -L$LEDAROOT mult.o -lleda -lX11 -lm
/usr/bin/ld: cannot find -lX11
collect2: error: ld returned 1 exit status
I think I need to install some package,because when I googled this error the most of problems are solved by installing some package .
I didn't find lx11 error
some of the eroor messages that I googled.
error 1
/usr/bin/ld: cannot find -lfreetype collect2: ld returned 1 exit
status
error 2
/usr/bin/ld: cannot find -lz collect2: ld returned 1 exit status
Links where I find these posts
http://www.qtcentre.org/threads/21069-collect2-ld-returned-1-exit-status
http://www.cyberciti.biz/faq/centos-rhel-redhat-usrbinld-cannot-findlc-error/
Do I need to install some package or there is some other problem
Could be two things
1) The X11 library is installed in a non-standard path. Use the search command to see if libX11.a or libX11.so is available on your system. If yes add the directory path to the -L option.
2) You are missing the libX11 library.
In this case, login as admin and use yum (assuming linux) to install this library.
Eg:
"yum install libX11.i386" or "yum install libX11.x86_64", depending on your architecture (32 bit or 64 bit).

Cannot find lffi - Error linking with llvm libraries

I am trying to use LLVM as backend for my compiler, and while linking with the llvm libraries, I get this error
g++ obj/*.o `llvm-config --ldflags core jit native` `llvm-config --libs core jit native` -lfl -o Icarus
/usr/bin/ld: cannot find -lffi
collect2: ld returned 1 exit status
I have installed llvm on my system and my cpp files compile fine. Its during linking that the library its searching can't be found.
If on a deb system try installing the dev libs, they solved the problem for me:
sudo apt-get install libffi-dev
Hmm. Did you install libffi too?
ftp://sourceware.org/pub/libffi/libffi-3.0.10.tar.gz
I know that installing libffi into /usr prefix helped me, when ld complained about being unable to find -ffi