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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:24:13+00:00 2026-05-26T03:24:13+00:00

I have a library, libfoo which is made of the following files: base.hpp #ifndef

  • 0

I have a library, libfoo which is made of the following files:

base.hpp

#ifndef BASE_HPP
#define BASE_HPP

class base
{
        public:

        virtual ~base();

        virtual void foo() = 0;
};

inline base::~base() {}

#endif /* BASE_HPP */

derived.hpp

#ifndef DERIVED_HPP
#define DERIVED_HPP

#include "base.hpp"

class derived : public base
{
        public:

        void foo();
};

#endif /* DERIVED_HPP */

base.cpp

#include "base.hpp"

derived.cpp

#include "derived.hpp"

void derived::foo()
{
}

When I try to use it in a simple program:

main.cpp

#include <derived.hpp>

int main()
{
        derived d;

        return 0;
}

I get the following linker error:

scons -Q -C libfoo
scons: Entering directory `/home/ereon/git_work/box/libfoo'
g++ -o base.os -c -fPIC base.cpp
g++ -o derived.os -c -fPIC derived.cpp
g++ -o libfoo.so -shared base.os derived.os
scons -Q -C bar
scons: Entering directory `/home/ereon/git_work/box/bar'
g++ -o main.o -c -I/home/ereon/git_work/box/libfoo main.cpp
g++ -o bar main.o
main.o: In function `derived::derived()':
main.cpp:(.text._ZN7derivedC2Ev[_ZN7derivedC5Ev]+0x1f): undefined reference to `vtable for derived'
main.o: In function `derived::~derived()':
main.cpp:(.text._ZN7derivedD2Ev[_ZN7derivedD5Ev]+0x13): undefined reference to `vtable for derived'
collect2: ld returned 1
scons: *** [bar] Error 1
make: *** [all] Erreur 2

Now the funny thing is that I only get this error on my Debian Wheezy x86_64 machines (I tried on two different computers).

I also tried on a Debian Wheezy amd64 with the exact same compiler version: gcc (Debian 4.6.1-4) 4.6.1 and there it links fine.

What could be wrong ?

  • 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-26T03:24:14+00:00Added an answer on May 26, 2026 at 3:24 am

    You neglected to include the shared lib in the linker inputs when linking?

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

Sidebar

Related Questions

Say I had a library called libfoo which contained a class, a few static
Say I have a library libfoo.so.1 , which depends (according to ldd ) on
I have a library, foo, for which I've produced a static object (libfoo.a). I
I have a library with an Interface. Public Interface Progress { int ProgressValue{get;set;}, string
I have a library made in C++/GDI that I am trying to port to
I have a library project that should be the base for several web applications.
I have gdata library install on my ArchLinux, and a simple application which imports
I have a shared library with soname: libfoo.so How do I link my binary
i have a 2.6 python script and library in the following directory structure: +
I have library project and regular android project which uses it. Library project: src

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.