LNK errors while using an "extern "C"" function
-
I am implementing a C++.Net Class Library.(I want to use it in C#.Net later) I am using an MFC C++ header file and its corresponding lib file in that class library. I set the path for header file and lib file in the project properties. In that header file there is a class which I have no problem using it. But there is an "extern "C"" function which I have some problem with it. When I call it in my code, there are two link errors while compiling: error LNK2028 error LNK2019 Please help me to use this function. I'd appreciate it. Thanks in advance
-
I am implementing a C++.Net Class Library.(I want to use it in C#.Net later) I am using an MFC C++ header file and its corresponding lib file in that class library. I set the path for header file and lib file in the project properties. In that header file there is a class which I have no problem using it. But there is an "extern "C"" function which I have some problem with it. When I call it in my code, there are two link errors while compiling: error LNK2028 error LNK2019 Please help me to use this function. I'd appreciate it. Thanks in advance
You have to specify the calling convention of the exported function because the default is different in managed and native compilation. You could declare it as __stdcall.
«_Superman_» I love work. It gives me something to do between weekends.
-
You have to specify the calling convention of the exported function because the default is different in managed and native compilation. You could declare it as __stdcall.
«_Superman_» I love work. It gives me something to do between weekends.
would you please elaborate a little bit more or send me an article with examples? Thanks a lot
-
would you please elaborate a little bit more or send me an article with examples? Thanks a lot
The function must be declared as -
extern "C" int __stdcall foo();
«_Superman_» I love work. It gives me something to do between weekends.
-
would you please elaborate a little bit more or send me an article with examples? Thanks a lot
Here[^] is a great article about calling conventions. It will help you to understand the concept.
Cédric Moonen Software developer
Charting control [v2.0] OpenGL game tutorial in C++