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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:37:27+00:00 2026-05-24T10:37:27+00:00

I have a native C++ library (let’s call it CoreLib.dll) and it exposes two

  • 0

I have a native C++ library (let’s call it CoreLib.dll) and it exposes two classes:

  • Core.h
  • Atom.h

I have a CLI/C++ wrapper (let’s call it CoreWrapper.dll) that allows .NET projects to instantiate Core and Atom objects:

  • CoreDotNet.h
  • AtomDotNet.h (includes Atom.h and CoreDotNet.h)

When I compile the CoreWrapper, only CoreDotNet.h gets compiled and AtomDotNet.h gets ignored. If I want to compile AtomDotNet.h, then I must include it in CoreDotNet.h, but that causes a compiler error in CoreDotNet.h:

error C2011: 'CoreWrapperNS::CoreDotNet' : 'class' type redefinition

Here is some basic code that represents what I’m doing:

#pragma once // <-- should protect from class type redefinition
#include "Core.h"
//#include "AtomDotNet.h" // uncommenting causes compiler error C2011

using namespace CoreNS;

namespace CoreWrapperNS
{
    public ref class CoreDotNet
    {
    public:
        // Allows users to instantiate a core object
        CoreDotNet();
        CoreDotnet(Core* core);
        //... destructor follows
    };
}

Here is the AtomDotNet.h file:

#pragma once // <-- should protect from class type redefinition
#include "Atom.h"
#include "CoreDotNet.h"

namespace CoreWrapperNS
{
    public ref class AtomDotNet
    {
    private:
        Atom*       _atom;
        CoreDotNet^ _core;
    public:
        AtomDotNet()
        {
            // The atom allows users to instantiate an atom with a core
            // and to get a reference to the core of the given atom.
            Core* core = new Core();
            _atom = new Atom(core);
            _core = gcnew CoreDotNet(core);
        }

        inline CoreDotNet^ GetCore(){return _core;}
        //... destructor follows
    };
}

The CoreWrapper project has a reference to the CoreLib project. I’ve seen some posts around the “Internets” about CLI/C++ wrappers getting the above mentioned compiler error because they reference the C++ project AND they include the header file, but I didn’t have that problem until I added a second class (i.e. the AtomDotNet class) to the wrapper library and I tried to compile it. Any ideas on what might be happening here?

  • 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-24T10:37:28+00:00Added an answer on May 24, 2026 at 10:37 am

    Merely writing your code in header files doesn’t cause it to be included in the project.

    You need to add .cpp files to the project, and #include the headers.

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

Sidebar

Related Questions

I have a managed dll that calls into a native library. This native library
I have an existing library (JPhysX) that is a Java wrapper for a native
In a managed wrapper over a native library, I have to accomplish certain operations
Let's say I have written a Class Library (dll) in .Net and now I
I have a native/unmanaged C++ library with a number of classes that I would
I have a manager wrapper for a native library -- the native library is
I have a native VC++ project that uses a dll (which is not in
I have a function in a native DLL defined as follows: #include <string> void
I have an native C++ library which makes use of a large static buffer
I have a native dynamic link library written in VC++6 and I do not

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.