I have a C static library that I need to link to a new DLL i'm creating. I'm using Visual Studio 2005, and created a console application that outputs a DLL. But when I try to compile I get unresolved external linker errors:

Error 2 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 DLL/LIB and header file for this static library are located in specific folders on the hard drive and i've linked them to the current project thru my project settings, so it should know where to look for them. Does it matter that this is C code and my project is a C++ DLL? I'm new to linking to DLL's so any help would be useful.

Recommended Answers

All 5 Replies

I've found that the problem may rely in the fact that the static library functions all return "signed __int8". I don't know what that is or how it affects my C++ library but it won't link because of it, it seems.

Anyone know why?

bump

commented: Bumping like that is bad, very very bad. Read the forum rules -1

I've already wrapped the declaration of my C headers in extern "C". and that doesn't make a difference. I still get unresolved external linking errors. Any other ideas?

The problem apparently is a form of name mangling by two different compilers:

So the original symbol that the compiler couldn't find was "?start_api@@YACH@Z", and dumbin shows "?start_api@@YA_DH@Z"

?start_api@@YACH@Z
?start_api@@YA_DH@Z

The "YA" part says "function with __cdecl calling convention".

The "CH" part says "returns signed char and takes an int".

The "_DH" part says "returns __int8 and takes an int".

So the problem seems to be that each project is evaluating "API_RETURN_TYPE" differently.

API_RETURN_TYPE is typedef'd in the header file as a signed __int8.

So why is my compiler looking for a signed char? What can i do to fix it? Its declared in the header, and just called in my source. I'm not sure what i can do to fix it on my end.

Also, the static library was compiled using Visual Studio 6, whereas i'm using VS 2005. Think this might be the issue? Is there a way i can overcome this?

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.