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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T22:36:24+00:00 2026-06-04T22:36:24+00:00

I have a unmanaged third party library (C). I’m trying to write a wrapper

  • 0

I have a unmanaged third party library (C). I’m trying to write a wrapper in C++/CLI, so I can use the library from C#. I have several C examples, but I can’t figure out how to bridge the unmanaged and managed heaps.

One of the functions in the library returns a struct, which I need to keep in my managed wrapper. This struct is then used as a parameter for other functions.

Working C-example:

library.h

typedef struct FOO_BAR_STRUCT* FOO_BAR;
DLLEXPORT FOO_BAR FooBarCreate();

Example.c

#include <library.h>

int main(int argc, char* argv[]) {
char* address = "127.0.0.1"; 
FOO_BAR fb = NULL;

fb = FooBarCreate();

FooBarRegister(fb, address);
}

So in my Wrapper, I try to recreate what the example do. I’ve figured out that the problem is which heap the struct is on, but I haven’t been able to figure out how to solve this.

My C++ code, compiled as a C++/CLI .dll for use in my C# project.

FooBarComm.h

#include <library.h>

ref class FooBarComm
{
public:
    FooBarComm(char* address);
    ~FooBarComm();

private:
    FOO_BAR fb;
};

FooBarComm.cpp

#include "FooBarComm.h"

FooBarComm::FooBarComm(char* address)
{
    fb = FooBarCreate();
    FooBarRegister(fb, address);
}

FooBarComm::~FooBarComm()
{
}

And this fails. How can I get the instance of the FOO_BAR struct from the unmanaged code into the managed class, then use it as a argument in later functions.

Edit:

I fails with a warning LNK4248: unresolved typeref token (0100000D)
error LNK2028: unresolved token (0A00000A) “extern “C” struct FOO_BAR_STRUCT
error LNK2019: unresolved external symbol “extern “C” struct FOO_BAR_STRUCT

I guess the problem is that I don’t have a definition of the FOO_BAR_STRUCT in any header files that came with the library. I’m starting to dislike this library.

Is it sensible to create a unmanaged class that holds the reference to the struct, and then reference this unmanaged class from a managed class?

If I change to a “normal” C++ class, I get a different compile error:

FooBarComm.h

#include <library.h>

#pragma unmanaged    
class FooBarComm {
...

I get the compile error:

error LNK2019: unresolved external symbol _FooBarCreate referenced

Edit 2:

Ofcourse it was a missing link to the .lib file.

  • 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-04T22:36:26+00:00Added an answer on June 4, 2026 at 10:36 pm

    This looks awfully like a linker error caused by the omission of the .lib file for the 3rd party library. I expect that if you add that to your link options then your problems will be solved.

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

Sidebar

Related Questions

We have a situation where we use a set of third-party unmanaged C++ libraries
I have a class library which is called through COM from a Third Party
I have an unmanaged library which I want to use from a managed class.
We have a third party library that internally uses a SafeHandle to an unmanaged
I have to use third party, unmanaged COM dll into my .NET application. I
I have a project in C#, which references unmanaged third-party DLL (which is ChilkatDotNet2.dll
I have a situation where I am using a third party library. On machines
I have an unmanaged C++ library for which I've created a managed C++ wrapper.
In unmanaged C++ I have a function which I'm trying to call from C#.
I have a C# windowed application that needs to make use of a third-party

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.