I am new to Linux programming and am attempting to use the BFD library. This is the current code I’m trying to compile:
#include <bfd.h>
#include <stdlib.h>
bfd *abfd;
int main() {
bfd_init();
abfd = bfd_openr("/home/mike/Desktop/testFunc/testProg", NULL);
return 0;
}
I am using the following command line for compiling:
gcc readInfo.c /usr/lib/libbfd.a -o readInfo
And am getting the following errors:
gcc readInfo.c /usr/lib/libbfd.a -o readInfo
/usr/lib/libbfd.a(elflink.o): In function
elf_link_add_object_symbols':objalloc_free_block’
/build/buildd/binutils-2.21.53.20110810/builddir-single/bfd/../../bfd/elflink.c:4605:
undefined reference to
/build/buildd/binutils-2.21.53.20110810/builddir-single/bfd/../../bfd/elflink.c:4892:
undefined reference to_sch_istable' /usr/lib/libbfd.a(elflink.o): Inbfd_elf_size_dynamic_sections’:
function
/build/buildd/binutils-2.21.53.20110810/builddir-single/bfd/../../bfd/elflink.c:6048:
undefined reference tolbasename'_sch_istable’ collect2: ld returned 1 exit
undefined reference to
status make: * [all] Error 1
There are a lot more lines of errors, which you can view here. I’m sure there is a simple explanation for this but it has got me stumped for a while.
To summarise what I have done so far:
- Installed clean build of Ubuntu
- Installed binutils-dev package
Do you need to statically link your program?
It compiles and runs without error if you dynamically link it instead:
I’ve run into a new problem when trying to make it statically linked: