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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T18:21:32+00:00 2026-05-15T18:21:32+00:00

I made a static library with GCC. Building of the library was OK. When

  • 0

I made a static library with GCC. Building of the library was OK.

When I use it the linker throws undefined reference errors on some functions. But nm says the functions are defined and exported in the static library (marked with T). I know about the linking order that I need to put the libraries after that module that needs them so this can not be a problem.

The static library was built from 3 C files. A.c B.c and D.c The D module depend on A and B (includes their headers).

No problem when I use functions from A and B but when I try to use any function from D I get undefined reference errors on them.

If I move these functions in A or B it works. But not if they are in the D module.

I’m completely run out of ideas what’s going on or what is I’m overlooked.

I’m using Code::Blocks and working with plain C files.

  • 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-15T18:21:33+00:00Added an answer on May 15, 2026 at 6:21 pm

    I found out that I added A .cpp file to my project and I just renamed it to .c. I chose C language instead of C++ when I created the project. I did’t think this could cause problems

    I thought the file extension decides when the IDE chooses between gcc and g++. But not. In Code::Blocks if you add a file with a .cpp extension it will use g++. If you add a file with a .c extension it will use gcc. But if you rename the file it will use the same compiler. You have to change it explicitly in the project options.

    That D module was built using g++ instead of gcc.

    I realized this when I set the IDE to show me the entire command line when building not just “Compiling foo.c”.

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

Sidebar

Related Questions

Possible Duplicate: GCC C++ Linker errors: Undefined reference to 'vtable for XXX', Undefined reference
I am using Eclicpse to develop a static library made of functions that I
I made a custom Static Library that I use in an iOS project. When
i have made my custom Static Library (.a) successfully. i have tested it in
I made a dll in c# but i need to export the functions. Is
I would like to trace calls to some 3rd party library which are made
I've got an application that's using a static library I made. One .cpp file
I'm attempting to use the EGOPhotoViewer as a static library in my project, such
I made a static library that was coded using ARC. I plan to distribute
I have a static library that i made for encryption an XML serialization with

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.