I was installing a library called libelf from sourceforge https://sourceforge.net/projects/elftoolchain/files/Sources/ I installed all the packages listed under the INSTALL file, it seems like the library installed successfully. I attached some of the output below
I used the two lines below to install the library
% pmake% sudo pmake installinstall ===> commoninstall ===> libelfinstall -c -o root -g root -m 600 libelf.a /usr/lib/x86_64-linux-gnu/libelf.aranlib -t /usr/lib/x86_64-linux-gnu/libelf.achmod 644 /usr/lib/x86_64-linux-gnu/libelf.ainstall -c -o root -g root -m 600 libelf_p.a /usr/lib/x86_64-linux-gnu/libelf_p.aranlib -t /usr/lib/x86_64-linux-gnu/libelf_p.achmod 644 /usr/lib/x86_64-linux-gnu/libelf_p.agzip -9cf elf.3 > /usr/share/man/man3/elf.3.gzgzip -9cf elf_begin.3 > /usr/share/man/man3/elf_begin.3.gzgzip -9cf elf_cntl.3 > /usr/share/man/man3/elf_cntl.3.gzgzip -9cf elf_end.3 > /usr/share/man/man3/elf_end.3.gzgzip -9cf elf_errmsg.3 > /usr/share/man/man3/elf_errmsg.3.gzgzip -9cf elf_fill.3 > /usr/share/man/man3/elf_fill.3.gzgzip -9cf elf_flagdata.3 > /usr/share/man/man3/elf_flagdata.3.gzgzip -9cf elf_getarhdr.3 > /usr/share/man/man3/elf_getarhdr.3.gzgzip -9cf elf_getarsym.3 > /usr/share/man/man3/elf_getarsym.3.gzgzip -9cf elf_getbase.3 > /usr/share/man/man3/elf_getbase.3.gzgzip -9cf elf_getdata.3 > /usr/share/man/man3/elf_getdata.3.gzgzip -9cf elf_getident.3 > /usr/share/man/man3/elf_getident.3.gzgzip -9cf elf_getscn.3 > /usr/share/man/man3/elf_getscn.3.gzgzip -9cf elf_getphdrnum.3 > /usr/share/man/man3/elf_getphdrnum.3.gzgzip -9cf elf_getphnum.3 > /usr/share/man/man3/elf_getphnum.3.gzgzip -9cf elf_getshdrnum.3 > /usr/share/man/man3/elf_getshdrnum.3.gzgzip -9cf elf_getshnum.3 > /usr/share/man/man3/elf_getshnum.3.gzgzip -9cf elf_getshdrstrndx.3 > /usr/share/man/man3/elf_getshdrstrndx.3.gzgzip -9cf elf_getshstrndx.3 > /usr/share/man/man3/elf_getshstrndx.3.gzgzip -9cf elf_hash.3 > /usr/share/man/man3/elf_hash.3.gzgzip -9cf elf_kind.3 > /usr/share/man/man3/elf_kind.3.gzgzip -9cf elf_memory.3 > /usr/share/man/man3/elf_memory.3.gzgzip -9cf elf_next.3 > /usr/share/man/man3/elf_next.3.gzgzip -9cf elf_open.3 > /usr/share/man/man3/elf_open.3.gzgzip -9cf elf_rawfile.3 > /usr/share/man/man3/elf_rawfile.3.gzgzip -9cf elf_rand.3 > /usr/share/man/man3/elf_rand.3.gzgzip -9cf elf_strptr.3 > /usr/share/man/man3/elf_strptr.3.gz...more stuff...install ===> libdwarf...more stuff...install ===> testNothing to install.install ===> documentationinstall ===> documentation/libelf-by-exampleinstall -g root -o root libelf-by-example.pdf //usr/share/doc/elftoolchain
I tried to do one of the examples from the documentation, I tried cc -o prog1 prog1.c -lelfand it gave this message
ld: unrecognized option -pcollect2: error: ld returned 1 exit status
In fact, any c project that try to compile gives me the same message, for example a basic hello world.c that I compile with gcc -o hello hello.c gives me
ld: unrecognized option -pcollect2: error: ld returned 1 exit status
#include <err.h>#include <fcntl.h>#include <libelf.h> #include <stdio.h>#include <stdlib.h>#include <unistd.h>intmain(int argc, char **argv){int fd;Elf *e; char *k;Elf_Kind ek; if (argc != 2) errx(EXIT_FAILURE, "usage: %s file-name", argv[0]);if (elf_version(EV_CURRENT) == EV_NONE) errx(EXIT_FAILURE, "ELF library initialization ""failed: %s", elf_errmsg(-1));if ((fd = open(argv[1], O_RDONLY, 0)) < 0) err(EXIT_FAILURE, "open \%s\" failed", argv[1]);if ((e = elf_begin(fd, ELF_C_READ@\co{5}@, NULL)) == NULL) errx(EXIT_FAILURE, "elf_begin() failed: %s.", elf_errmsg(-1)); ek = elf_kind(e); switch (ek) {case ELF_K_AR: k = "ar(1) archive"; break;case ELF_K_ELF: k = "elf object"; break;case ELF_K_NONE: k = "data"; break;default: k = "unrecognized";}(void) printf("%s: %s\n", argv[1], k);(void) elf_end(e); (void) close(fd);exit(EXIT_SUCCESS);}
I'm using ubuntu 16.04, the install file mentions the library was intended for ubuntu 14.04 wonder if that's the problem... I'll appreciate any help, thanks