LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   ld is missing files... (https://www.linuxquestions.org/questions/linux-software-2/ld-is-missing-files-4175593829/)

niteshadw 11-18-2016 09:03 PM

ld is missing files...
 
Hello,

I'm trying to compile efitools on CentOS but I am running into an issue. This is what the error I get during make:

Code:

# make
make -C lib lib-efi.a
make[1]: Entering directory `/root/efitools/lib'
make[1]: `lib-efi.a' is up to date.
make[1]: Leaving directory `/root/efitools/lib'
cc -I/root/efitools/include/ -I/usr/include/efi -I/usr/include/efi/x86_64 -I/usr/include/efi/protocol -O2  -fpic -Wall -fshort-wchar -fno-strict-aliasing -fno-merge-constants -fno-stack-protector -ffreestanding -fno-stack-check -DGNU_EFI_USE_MS_ABI -DEFI_FUNCTION_WRAPPER -mno-red-zone -DCONFIG_x86_64 -c HelloWorld.c -o HelloWorld.o
ld -nostdlib -shared -Bsymbolic /usr/lib64/gnuefi/crt0-efi-x86_64.o -L /usr/lib64/gnuefi -T elf_x86_64_efi.lds HelloWorld.o lib/lib-efi.a -o HelloWorld.so -lefi -lgnuefi /usr/lib/gcc/x86_64-redhat-linux/4.8.5/libgcc.a
ld: cannot find -lefi
ld: cannot find -lgnuefi
make: *** [HelloWorld.so] Error 1
rm HelloWorld.o

However it seems I have libefi and libgnuefi:

Code:

# locate libefi
/usr/lib64/libefi.a
/usr/lib64/libefivar.so.0
# locate libgnuefi
/usr/lib64/libgnuefi.a

I'm not sure what I am missing? I installed the gnu-efi-devel package and based on my searches, ld searches for *.a but maybe the files need to be *.so?

Any suggestions would be much appreciated.

hazel 11-19-2016 05:44 AM

You are right. For normal dynamic linking you would need .so files. The .a files are for static linking only.

Devel packages do not contain the actual dynamic libraries. You will need to install them separately. Actually I'm surprised that they didn't come over as dependencies of their headers.

niteshadw 11-19-2016 09:05 AM

Quote:

Originally Posted by hazel (Post 5632295)
You are right. For normal dynamic linking you would need .so files. The .a files are for static linking only.

Devel packages do not contain the actual dynamic libraries. You will need to install them separately. Actually I'm surprised that they didn't come over as dependencies of their headers.

Thank you for your reply, but I'm not sure what I'm missing...

I have the efi and gnuefi packages installed:

Code:

# rpm -qa | grep -i efi
efibootmgr-0.8.0-7.el7.x86_64
gnu-efi-3.0.2-2.el7.x86_64
gnu-efi-devel-3.0.2-2.el7.x86_64
efivar-libs-0.11-1.el7.x86_64
grub2-efi-2.02-0.29.el7.centos.x86_64


# rpm -ql gnu-efi-3.0.2-2.el7.x86_64
/usr/lib64/gnuefi
/usr/lib64/gnuefi/crt0-efi-x86_64.o
/usr/lib64/gnuefi/elf_x86_64_efi.lds
/usr/lib64/libefi.a
/usr/lib64/libgnuefi.a


# rpm -ql gnu-efi-devel-3.0.2-2.el7.x86_64
/usr/include/efi
/usr/include/efi/efi.h
/usr/include/efi/efi_nii.h
/usr/include/efi/efi_pxe.h
/usr/include/efi/efiapi.h
/usr/include/efi/eficon.h
/usr/include/efi/efidebug.h
/usr/include/efi/efidef.h
/usr/include/efi/efidevp.h
/usr/include/efi/efierr.h
/usr/include/efi/efifs.h
/usr/include/efi/efigpt.h
/usr/include/efi/efiip.h
/usr/include/efi/efilib.h
/usr/include/efi/efilink.h
/usr/include/efi/efinet.h
/usr/include/efi/efipart.h
/usr/include/efi/efipciio.h
/usr/include/efi/efipoint.h
/usr/include/efi/efiprot.h
/usr/include/efi/efipxebc.h
/usr/include/efi/efirtlib.h
/usr/include/efi/efiser.h
/usr/include/efi/efishellintf.h
/usr/include/efi/efishellparm.h
/usr/include/efi/efistdarg.h
/usr/include/efi/efitcp.h
/usr/include/efi/efiudp.h
/usr/include/efi/efiui.h
/usr/include/efi/libsmbios.h
/usr/include/efi/pci22.h
/usr/include/efi/protocol
/usr/include/efi/protocol/adapterdebug.h
/usr/include/efi/protocol/eficonsplit.h
/usr/include/efi/protocol/efidbg.h
/usr/include/efi/protocol/efivar.h
/usr/include/efi/protocol/intload.h
/usr/include/efi/protocol/legacyboot.h
/usr/include/efi/protocol/piflash64.h
/usr/include/efi/protocol/vgaclass.h
/usr/include/efi/romload.h
/usr/include/efi/x86_64
/usr/include/efi/x86_64/efibind.h
/usr/include/efi/x86_64/efilibplat.h
/usr/include/efi/x86_64/pe.h
/usr/share/doc/gnu-efi-devel-3.0.2
/usr/share/doc/gnu-efi-devel-3.0.2/ChangeLog
/usr/share/doc/gnu-efi-devel-3.0.2/README.efilib
/usr/share/doc/gnu-efi-devel-3.0.2/README.elilo
/usr/share/doc/gnu-efi-devel-3.0.2/README.git
/usr/share/doc/gnu-efi-devel-3.0.2/README.gnuefi


hazel 11-19-2016 11:15 AM

I was wrong. I've been browsing around and it seems that efi programs are statically linked after all, which is why no dynamic library objects are provided. I've looked at examples of Hello World programs being built for efi and they seem to use the same ld flags as you do, so I don't know why your static libraries weren't found. I hope someone else picks this up as I seem to have done you a bad turn by taking away your "zero reply" flag.

norobro 11-20-2016 05:00 PM

Try the following:
Code:

/usr/lib64# ln -s gnuefi/crt0-efi-x86_64.o
/usr/lib64# ln -s gnuefi/elf_x86_64_efi.lds

On my Debian box those two files are in the same directory as the static libs.


All times are GMT -5. The time now is 02:09 AM.