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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:58:52+00:00 2026-05-25T12:58:52+00:00

I have a mixed C/C++ library. On the outside it provides a C interface

  • 0

I have a mixed C/C++ library.

On the outside it provides a C interface using extern C. Internally there are templates and classes. Creating the library with “ar” posed no problems. The file is called libo-client.a.

However, when linking the .a file using gcc (not g++) I get lots of errors that look like this:

libo-client.a(mysocket.o):(.rodata._ZTV7mStream[vtable for mStream]+0x10): undefined reference to `__cxa_pure_virtual'
...
mysocket.cpp:(.text+0x15ad): undefined reference to `operator new[](unsigned long)'
mysocket.cpp:(.text+0x15c1): undefined reference to `operator delete(void*)'
mysocket.cpp:(.text+0x167a): undefined reference to `__cxa_allocate_exception'
mysocket.cpp:(.text+0x16a6): undefined reference to `__cxa_throw'
...

My compile/link line looks like this:

gcc $(CFLAGS) $(INCLUDES) test2.c libo-client.a -o test2 

Where test2 is my test harness.

This problem does not occur when I’m using g++. However, I’m going to interface this library into C project which is compiled with gcc. How do I get around this? What’s the cause of it?

EDIT:

Even though I’m not using the standard C++ library it’s obviously needing some things like operator new/delete etc. and there are exceptions internally.

I’m linking this thing against the Xen hypervisor so I’m not sure what options i have but to totally rewrite this thing or perhaps try compiling Xen with G++ instead?

  • 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-25T12:58:52+00:00Added an answer on May 25, 2026 at 12:58 pm

    The simplest way around your problem it is to link with g++; this gets the correct libraries in place.

    The problem is that C++ has a lot of requirements that C does not, and does more work before calling main() to ensure that things are properly initialized.

    If you insist on linking with the C compiler, at the very least you’d have to include the C++ support library in with your link command.

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

Sidebar

Related Questions

we have a mixed development environment using ASP.NET MVC and Ruby on Rails. We
I have a solution of mixed VB.NET and C++ projects. When using Visual Studio
I have a library written in C mixed mixed with some assembly for ARM.
I have a java program using an external library. The main program uses log4j
I have an XCode 4.2 workspace containing a Cocos Touch Static Library (mixed Objective
In a Mixed 3.2.5 iOS/MacOS project, there is an existing iOS static library target,
I have a C++/CLI (VS 2008) mixed mode library that creates native objects and
I have mixed data i nvarchar column (words and numbers). Which is fastest way
I have an application where I would like to have mixed Java and Scala
I have heard mixed opinions over the amount of memory that a byte takes

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.