Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6769773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:14:00+00:00 2026-05-26T15:14:00+00:00

I am new to Linux programming and am attempting to use the BFD library.

  • 0

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':
/build/buildd/binutils-2.21.53.20110810/builddir-single/bfd/../../bfd/elflink.c:4605:
undefined reference to
objalloc_free_block’
/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): In
function
bfd_elf_size_dynamic_sections’:
/build/buildd/binutils-2.21.53.20110810/builddir-single/bfd/../../bfd/elflink.c:6048:
undefined reference to lbasename'
undefined reference to
_sch_istable’ collect2: ld returned 1 exit
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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:14:00+00:00Added an answer on May 26, 2026 at 3:14 pm

    Do you need to statically link your program?

    It compiles and runs without error if you dynamically link it instead:

    gcc readInfo.c -o readInfo -lbfd
    

    I’ve run into a new problem when trying to make it statically linked:

    $ gcc readInfo.c /usr/lib/libbfd.a /usr/lib/x86_64-linux-gnu/libc.a -o readInfo
    /usr/bin/ld.bfd.real: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer equality
        in `/usr/lib/x86_64-linux-gnu/libc.a(strcmp.o)' can not be used when making
        an executable; recompile with -fPIE and relink with -pie
    collect2: ld returned 1 exit status
    $ gcc -fPIE readInfo.c /usr/lib/libbfd.a /usr/lib/x86_64-linux-gnu/libc.a \
        -o readInfo
    /usr/bin/ld.bfd.real: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer equality
        in `/usr/lib/x86_64-linux-gnu/libc.a(strcmp.o)' can not be used when making
        an executable; recompile with -fPIE and relink with -pie
    collect2: ld returned 1 exit status
    $ gcc -fPIE -pie readInfo.c /usr/lib/libbfd.a /usr/lib/x86_64-linux-gnu/libc.a \
      -o readInfo
    /usr/bin/ld.bfd.real: /usr/lib/libbfd.a(opncls.o): relocation R_X86_64_32S
        against `.rodata' can not be used when making a shared object; recompile with
        -fPIC
    /usr/lib/libbfd.a: could not read symbols: Bad value
    collect2: ld returned 1 exit status
    $ gcc -fPIC -fPIE -pie readInfo.c /usr/lib/libbfd.a \
      /usr/lib/x86_64-linux-gnu/libc.a -o readInfo
    /usr/bin/ld.bfd.real: /usr/lib/libbfd.a(opncls.o): relocation R_X86_64_32S
        against `.rodata' can not be used when making a shared object; recompile with
        -fPIC
    /usr/lib/libbfd.a: could not read symbols: Bad value
    collect2: ld returned 1 exit status
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am new in programming under linux and trying to get working this code:
New to Linux programming in general. I am trying to communicate with a kernel
First off i'm new to Linux programming so apologies if this makes no sense
This example is taken from the Linux System Programming book, page 88. Code: http://pastebin.com/mEfmHbPP
I am pretty new to programming on Linux. I am trying to implement a
I'm pretty new to programming for Linux environments, so I don't exactly know what
I am new to Linux and I am attempting to install the PHP PEAR
I am trying to build a script (I'm pretty new to linux scripting) and
I am a new comer to Linux Kernel Module programming. From the material that
I'm quite new to Android programming but familiar with C/C++ and Linux enough to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.