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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:27:45+00:00 2026-06-01T19:27:45+00:00

Update 2 : Found the forward declare bug that caused this Update : Compiled

  • 0

Update 2: Found the forward declare bug that caused this

Update: Compiled using Visual Studio 2010 stock compiler, with c++0x enabled.

I have a class with a member function which is behaving strangely.

When I define the method in the cpp file the linker falls over with an “unresolved external symbol” error. When I move the definition to the header it compiles fine.

1) This is not a templated method
2) The cpp file is definitely being compiled
3) I’m stumped

Any thoughts?

header file

// THIS IS THE ERROR HERE: I forward declare TPA as a class, when it is actually a struct
class TollingPathAttributes; // forward declare the TollingPathAttributes struct as a class (doh!)

class TollingPathAttributesOutput
{
public:
    TollingPathAttributesOutput(HighwayCommand* command);
    ~TollingPathAttributesOutput();

    void foo();
    void AddPathAttributes(boost::shared_ptr<TollingPathAttributes> attributes);

protected:
    string                                      m_outputFilename;
    vector<shared_ptr<TollingPathAttributes>>   m_data;
    queuing_mutex                               m_dataMutex;
};

cpp file

void TollingPathAttributesOutput::foo() {}

void TollingPathAttributesOutput::AddPathAttributes(boost::shared_ptr<TollingPathAttributes> attributes)
{
    queuing_mutex::scoped_lock lock(m_dataMutex);
    m_data.push_back(attributes);
}

invoking call

m_output->foo();  // compiles and links no problem
boost::shared_ptr<TollingPathAttributes> attr = 
    boost::make_shared<TollingPathAttributes>(origin, dest, UNTOLLED_OPTION, vector<int>(), 0.0, 0.0);
m_output->AddPathAttributes(attr); // compiles fine, but only links correctly if I move the definition to the header

link error

1>OtCustomZenith_logic.lib(TollingPathAttributesRecorder.obj) : error LNK2019: unresolved external symbol "public: void __thiscall TollingPathAttributesOutput::AddPathAttributes(class boost::shared_ptr<class TollingPathAttributes>)" (?AddPathAttributes@TollingPathAttributesOutput@@QAEXV?$shared_ptr@VTollingPathAttributes@@@boost@@@Z) referenced in function "public: virtual void __thiscall TollingPathAttributesRecorder::Record(class TolledPath &,class boost::shared_ptr<class Path>,int)" (?Record@TollingPathAttributesRecorder@@UAEXAAVTolledPath@@V?$shared_ptr@VPath@@@boost@@H@Z)     
1>..\..\..\OT\OtCustomZenith_test.exe : fatal error LNK1120: 1 unresolved externals
  • 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-01T19:27:47+00:00Added an answer on June 1, 2026 at 7:27 pm

    Thanks to every one who tried to help – unfortunately this error was about 1 foot behind the keyboard. The problem here came down to the use of forward declarations to speed up my compile time. Because I wrongly forward declared the type of TollingPathAttributes as a class instead of a struct.

    This meant that the definition of the header was slightly different from the definition in the cpp as I actually included the full definition of TollingPathAttributes in the cpp file. The big thing that confused this issue was that the error messages I received were not what I was expecting to receive – as @MarkRansom says, normally if there is a mismatch between the cpp and header it will be a compile error not a link error so I have to conclude that:

    1) the compiler has simply pushed ahead with the incorrect ‘class’ (rather than ‘struct’) based definition even though it knows better once it has the full definition available to it. Leading to a lib file that has a signature that is almost but not quite what the linker is looking for.

    2) Some other weirdness

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

Sidebar

Related Questions

using Microsoft.SqlServer.Management.SqlStudio.Explorer; unable to find this pls assist [update] found the dll's in this
All the documentation I've found so far is to update keys that are already
I found something that works with updating one field at here: http://www.karlrixon.co.uk/articles/sql/update-multiple-rows-with-different-values-and-a-single-sql-query/ UPDATE person
Right guys, all autocomplete plugins and functions that I've found, they only update upon
Update Solution Found See Bottom of post if interested Seems simple enough and for
12:18:55,541 INFO [UpdateChecker] New update(s) found: 2.0.0 [ http://ehcache.org/news.html] How do I suppress ehcache
[Update: I've found the API reference. The method used is below] <?php wp_delete_post( $postid,
I found some problem. When i running apc_store and more times update a page
UPDATE - A comprehensive comparison, updated as of February 2015, can be found here:
just ran gem update on a light use server machine that hadn't been updated

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.