How to Present a C Static Library (.lib) through VC++ Class Library Proj

Hi,

I am attempting to present a pretty complicated API (C Static Libraries w/headers) to my C# application. I have found another useful example using C++ Libraries athttp://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=970907&SiteID=1&mode=1 but after getting involved, it appears there may be some important differences.

Firstly (in a VC++ Class Library Project), I have added the .lib files to the Linkers "additional dependencies" and removed the (INHERIT) macro from that directive. I then create my ref class using the convention (for example):

int managedCall(NativeType1 param, NativeType2 param2, unsigned char param3)

{

return __API_NAMESPACE::nativeCall(param, param2, param3;

}

(note that these APIs must accept parameter types I have not defined! I am not sure how I am going to deal with this yet.

When I attempt to compile my project, I get many, many LNK errors, mostly in the exact sample template:

LNK2028: unresolved token *int __cdecl nativeCall(param, param,) etc etc etc.

and

LNK2019: unresolved external symbol *int _cdecl etc etc refernced in function etc etc.

I can give the details of these errors if necessary, but I don't think it will help. Note that the calls are being done with the _cdecl keyword, is this an issue? Any insight into this issue would be greatly appreciated.

Thanks,


Kevin

[1621 byte] By [Lamprey] at [2007-12-27]
# 1

Ok, I seem to have resolved some of the initial issues by adding the " extern "C" " directive to the declarations in the C header files provided to me.

Any further input is appreciated.

-Kevin

Lamprey at 2007-9-4 > top of Msdn Tech,Visual C++,Visual C++ Language...
# 2

Hi Kavin,

R u using any console i/o library functions in ur library ? If u used console i/o functions with windows i/o functions, then there will be a problem.

I got same problem. When i removed console i/o library function calling, half of the errors closed.

Now i am getting some linker errors like : __x is already defined in ..crt0 ..lib

Regards,

Chary.

chary.K at 2007-9-4 > top of Msdn Tech,Visual C++,Visual C++ Language...