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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:53:56+00:00 2026-06-08T08:53:56+00:00

I cannot explain the behaviour I am seeing when linking my code. Maybe someone

  • 0

I cannot explain the behaviour I am seeing when linking my code. Maybe someone has an idea what’s going on…

I have a multiple file C++ project which uses GNU automake tools as its build system (all on Linux).

After adding a source and header file (lets call them util.cc and util.h) to the project and having an already existing source file (calc.cc) calling a function from the newly added files I get a linking error depending on where the include statement appears. I repeat: The error occurs in the linking step, compilation runs fine!!

Example:

I get an error when putting the new include statement at the end of the preexisting statements, like:

calc.cc:

#include "file1.h"
#include "file2.h"
#include "file3.h"
#include "file4.h"
#include "util.h"   // new header

This version compiles fine. But linking produces an error (symbol not found)!!

Now, when changing this to

#include "util.h"   // new header
#include "file1.h"
#include "file2.h"
#include "file3.h"
#include "file4.h"

then compilation and linking runs fine!

Since the linker only reads the .o files, this must mean that different content is produced depending on where the include statement appears. How can this be?

Compiler is g++ (GCC) 4.4.6

  • 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-08T08:53:58+00:00Added an answer on June 8, 2026 at 8:53 am

    Chances are that util.h has a #define that changes the behaviour of one of the other files.

    Your best chance of working out exactly what is going on would involve examining those header files for the name of the missing symbol and getting the pre-processor output from compiling calc.cc both ‘working’ and ‘non working’ way, and comparing the two files.

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

Sidebar

Related Questions

Can someone explain to me why I cannot use document.getElementById('id').value inside of a function?
Cannot dump Stack Overflow XML file into SQL Server 2008. Could you please explain
Can someone please explain why I'm getting this error Type mismatch: cannot convert from
Can someone please explain how Read/Show works.. I cannot find any tutorials on it.
I would like someone to explain me what _forward is exactly doing, I cannot
Can someone explain the following behaviour (I'm using Visual Studio 2010). header: #pragma once
I have different behaviour of compiler, when building project from IDE and from command-line,
I have discovered a strange behavior in postgres's crosstab function that I cannot explain,
I am observing behavior in the below code which I cannot readily explain and
In this commit there is a change I cannot explain deferred.done.apply( deferred, arguments ).fail.apply(

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.