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

  • Home
  • SEARCH
  • 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 6070529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:56:38+00:00 2026-05-23T09:56:38+00:00

I am trying to understand how native code can interact with .NET code and

  • 0

I am trying to understand how native code can interact with .NET code and am basically trying to implement the example in the answer to this topic. The example code has two parts, one that goes into a .dll compiled with the /clr option:

__declspec(dllexport) bool toUpper(void)
{
    return true;
}

and the code that is supposed to call this function goes into a win32 application, which is compiled natively:

bool toUpper(void);

int _tmain(int argc, _TCHAR* argv[])
{
    bool b = toUpper();
    return 0;
}

However vs2010 gives the following linker error:

error LNK2019: unresolved external
symbol “bool __cdecl toUpper(void)”
(?toUpper@@YA_NXZ) referenced in
function _wmain

As soon as I turn off the /clr option on the dll project, everything works, so I assume that I have all the dependencies between the projects set up correctly. Any suggestions on what I did 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-23T09:56:38+00:00Added an answer on May 23, 2026 at 9:56 am

    You must have used Project + Project Dependencies to get this to work without /clr. Yes, this doesn’t work if the project is compiled with /clr. Using a .lib for managed code is quite unusual. You have to explicitly tell the linker to link the .lib of your managed project.

    Right-click the EXE project, Properties, Linker, Input, Additional Dependencies setting. Assuming both projects are in one solution, enter this:

    ..\$(ConfigurationName)\mumble.lib
    

    Where mumble is the name of your managed project. Repeat for the Release configuration.

    Beware that using managed code this way does not scale well. The C++/CLI compiler automatically generates a thunk for the exported function that makes sure that the CLR is loaded and initialized before calling the managed function. That however does come at a cost, I clocked it at 640 nanoseconds per call on my laptop, not counting the overhead of initializing the CLR. Using COM is an effective way to avoid that cost. Or you can host the CLR yourself, look up CorBindToRuntimeEx().

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

Sidebar

Related Questions

I was trying to understand something with pointers, so I wrote this code: #include
I trying to understand this piece of code Function.prototype.method = function (name, fn) {
After trying to understand why client code is not rendered in a page (injected
I'm trying to understand someone else's Perl code without knowing much Perl myself. I
I'm trying to understand a particular Perl code from vcake . Usually I find
Trying to understand What is IConnectionPoint and how this is connected to IConnectionPointContainer,IEnumConnectionPoints,IEnumConnections and
Trying to understand why you can't use sql_variant for the value type when using
been trying to understand how to implement a timeout detection to a ruby TCP
I am trying to understand Double-Array Trie implementation from http://linux.thai.net/~thep/datrie/datrie.html But I do not
I am trying to understand PrimeFaces' AjaxStatus indicator. There are two facets - start

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.