I have a name mangling issue with a C++ static library that was created using VS 6.0. I'm trying to write a wrapper DLL using this static library, but i'm having trouble accessing the functions of this library due to name mangling. My compiler (VS 2005) shows this for a function i'm trying to use:

"?start_api@@YACH@Z",

and dumbin shows this for the reference to the function:

"?start_api@@YA_DH@Z"


As you can see my compiler says its returning signed char and looking for an int (CH). Where in dumpbin it says its returning a __int8 and looking for an int (_DH).

The static library is a 3rd party library that i don't have the source for and can't rewrite, so how do I get it working in my compiler?

Looks like the function is prototyped incorrectly. Change the prototype in the header file to match the library.

When importing a static library in visual studio, you don't have to declare it in your source. You just have the reference the library, include the header files (which i can't modify), and call the function.

Its prototyped correctly in the header, as returning a __int8 and returning and int. But my compiler refuses to see it that way. It sees it as a signed char even though dumpbin says its a __int8 like the header shows.

why can't you change the header file? If its on your computer than you can change it. Save a copy somewhere else and if changing the header file doesn't work then change it back.

Of course you can always just call the people who wrote the library and ask them.

I changed the header file and it gave me the same unresolved external error. I changed the prototype to be a signed char like my compiler is seeing, and it still didn't like it. Here's the error:

Error 3 error LNK2019: unresolved external symbol "signed char __cdecl start_api(int)" (?start_api@@YACH@Z) referenced in function "bool __cdecl start_core(int)" (?start_core@@YA_NH@Z) CoreWrapper.obj

The error message has not changed. It appears you did not change it correctly, there may be more than one occurrence of the prototype, or there may be multiple copies of the header file.

Unfortunately, there is only one occurrence of the prototype, and thats in the header of the static library.

I'm really at a loss at this point...

Unfortunately, there is only one occurrence of the prototype, and thats in the header of the static library.

I'm really at a loss at this point...

You might try posting on the MSDN's Visual C++ General forum.

Thanks, i'll try there.

after changing the header file did you re-compile everything?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.