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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:01:45+00:00 2026-05-31T07:01:45+00:00

I am working on getting a library to build in linux. This builds and

  • 0

I am working on getting a library to build in linux. This builds and works in Windows, but on Linux I am getting an unresolved symbol in our library when consuming the static lib. The code appears as follows:

class MyClass : public AnotherClassRefCounded
{
public:
  static bool queryInstance(MyClass **ppmyClass);
};

Inside the .cpp file for this class I have:

#include "stdafx.h"
#include "MyClass.h"

MyClass* MyClass::m_pInstance = NULL;

bool MyClass::queryInstance(MyClass **myClass)
{
  if(m_pInstance == NULL)
  {
    m_pInstance = new MyClass();
    m_pInstance->incRef(); 
  }

  m_pInstance->incRef();
  *myClass = m_pInstance;
  return true;
}

Now when running nm -Cu on libMyLib.a I get the following output:

[matt6809@hogganz400 libDebug]$ nm -Cu libMappingd.a | grep queryInstance
                 U AFewMoreScopes::MyClass::queryInstance(AFewMoreScopes::MyClass**)

My system info is:

[matt6809@hogganz400 libDebug]$ cat /etc/redhat-release ; gcc --version
Red Hat Enterprise Linux Server release 6.1 (Santiago)
gcc (GCC) 4.4.5 20110214 (Red Hat 4.4.5-6)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

For copyright reasons I cannot post the identical code. I have reproduced the code to the best of my abilities. If you feel I am missing any info please don’t hesitate to ask for it.


UPDATE

Example of build:

…

g++ -c -include Mappingd -pipe -w -g -fPIC -Wall -W <DEFINE FLAGS> <INCLUDE FLAGS> -o MyClass.o MyClass.cpp

…

ar cqs libMappingd.a <all object files>

UPDATE 0

This is very interesting. Inside the object file for “MyClass” the symbol is not undefied:

MyClass.o:
                 <My Symbol Not Undefined>

However if you go to another one of the object files:

<Other Object>.o:
                 ...
                 U Scope::MyClass::queryInstance(Socpe::MyClass**)

UPDATE1

g++ -c -include Mappingd -pipe -w -g -fPIC -Wall -W -DLINUXx86 <DEFINE FLAGS> <INCLUDE FLAGS> -o MyClass.o MyClass.cpp
g++ -c -include Mappingd -pipe -w -g -fPIC -Wall -W -DLINUXx86 <DEFINE FLAGS> <INCLUDE FLAGS> -o OtherClass.o OtherClass.cpp
rm -f libMappingd.a
ar cqs libMappingd.a <Other Objects> MyClass.o OtherClass.o

and

g++ -c -include Mappingd -pipe -w -g -fPIC -Wall -W -DLINUXx86 <DEFINE FLAGS> <INCLUDE FLAGS> -o OtherClass.o OtherClass.cpp
g++ -c -include Mappingd -pipe -w -g -fPIC -Wall -W -DLINUXx86 <DEFINE FLAGS> <INCLUDE FLAGS> -o MyClass.o MyClass.cpp
rm -f libMappingd.a
ar cqs libMappingd.a <Other Objects> OtherClass.o MyClass.o

Make no difference I still get undefined symbol in the other library.

  • 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-31T07:01:49+00:00Added an answer on May 31, 2026 at 7:01 am

    After much research, I discovered that the archiver on RHEL 6.1 has a bug in it. I stopped trying to pull in the static libs directly into the shared dynamic library, and instead I unpacked the static libs, and pulled the corresponding object files directly into the .so file. I now have 0 undefined symbols in our library apart from the ones that I am not statically linking against.

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

Sidebar

Related Questions

In my just-completed project, I was working getting distributed transactions working. We implemented this
Ok I'm working on getting better with python, so I'm not sure this is
What's the secret to getting ClaimsResponse working with DotNetOpenId ? For example, in this
I'm currently working on getting the C# Source for the 7-Zip compression library to
I'm working on getting an Introduction to Groovy presentation ready for my local Java
I've been working on getting a 2.5 module ported to 3.0, mostly for my
I am working on getting familiar with the Android SDK and I have having
I am working on getting parameter from a function string. For example, my function
On the web side we are working on getting source control. Now, I want
I'm just getting started working with foreign keys for the first time and I'm

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.