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 9273543
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:08:35+00:00 2026-06-18T16:08:35+00:00

I am trying to link a library to my c program so that my

  • 0

I am trying to link a library to my c program so that my main program can use functions inside the library I am creating, however I am getting errors.

This is some of my library code (well call this file lib.c):

#include <bfd.h>
#include <stdio.h>

static void doDump ( bfd *abfd )
{
    printf (_("\n%s:     file format %s\n"), bfd_get_filename (abfd), abfd->xvec->name);
    doHeaders ( abfd );
}

This is my main program (well call this file main.c):

#include "bfd.h"

static void getFile ( char *filename, char *target )
{
    bfd *file;
    file = bfd_openr (filename, target);
    doDump (file);
    bfd_close (file);
}

int main (int argc, char **argv)
{
    char *target = NULL;
    bfd_init ();
    getFile ("a.out", target);
}

These are the commands I run to link the libraries:

cc -Wall -c lib.c

ar -cvq libdata.a lib.o

cc -o mainprog main.c lib.a -lbfd

However, I am getting this error:

undefined reference to doDump

Which is pointing to the line:

doDump (file);

What am I doing wrong?

Thanks

  • 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-06-18T16:08:36+00:00Added an answer on June 18, 2026 at 4:08 pm

    You have defined doDump in lib.c as static. This means it is invisible outside that file. Remove the static keyword and the problem should go away.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to link a static library while creating my program executable using
Im trying to link my program to the shared library. Im using a makefile
I'm trying to link my mac application to the wonderful libancillary library. However, I
Background I am trying to build a Java program that make use of an
I have a C program that link the ssl library( md5.h ) : #if
I am trying to link a .a library that was built with gcc to
Based on this link: http://msdn.microsoft.com/en-us/library/windowsazure/ee336243.aspx I'm trying this code to connect to SQL Azure
Using glew, I'm trying to link the simple program #include </usr/include/GL/glew.h> int main (int
I am trying to use this code to define the APIs that are needed
I am trying to use an external library called iniparser in my C program.

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.