Calling C Function in Dll Causing Problem
-
Hello there. I am trying to call a C function in my newly created Dll project's code. But doing so produces
Unresolved External Symbol
error. Here is the what I am tryingHeader.h
int call_main(int argc, char** argv);
Header.cpp
int call_main(int argc, char** argv)
{
// all the code here .....
return 0;
}Now I include this
Header.h
in my Dll's main file and try to callcall_main
. Building the project produces the said error.#include "Header.h"
class Functions
{
public:
static __declspec(dllexport) int Call_MyMain(char **argv);
};int Functions::Call_MyMain(char **argv)
{
return call_main(8, argv); // HERE I AM CALLING FROM ABOVE HEADER FILE
}What could be wrong? What am I missing? Thanks for any input.
-
Hello there. I am trying to call a C function in my newly created Dll project's code. But doing so produces
Unresolved External Symbol
error. Here is the what I am tryingHeader.h
int call_main(int argc, char** argv);
Header.cpp
int call_main(int argc, char** argv)
{
// all the code here .....
return 0;
}Now I include this
Header.h
in my Dll's main file and try to callcall_main
. Building the project produces the said error.#include "Header.h"
class Functions
{
public:
static __declspec(dllexport) int Call_MyMain(char **argv);
};int Functions::Call_MyMain(char **argv)
{
return call_main(8, argv); // HERE I AM CALLING FROM ABOVE HEADER FILE
}What could be wrong? What am I missing? Thanks for any input.
-
I don't know what does this mean? How do I do that?
-
I don't know what does this mean? How do I do that?
...means your dll project should be building header.cpp... which produces an object file.
-
I don't know what does this mean? How do I do that?
-
...means your dll project should be building header.cpp... which produces an object file.
It is building header.cpp and it also produces an object file
-
It is building header.cpp and it also produces an object file
If you actually compiled one as C and the other as C++ (or the other way around), you'll also have to deal with name mangling... Standard C++[^] If they're both C++, it's actually still possible to screw up the mangling, I believe Studio allows you to set the mangling mode to each file independently (haven't used Studio in a while though). Decorated Names[^]
-
If you actually compiled one as C and the other as C++ (or the other way around), you'll also have to deal with name mangling... Standard C++[^] If they're both C++, it's actually still possible to screw up the mangling, I believe Studio allows you to set the mangling mode to each file independently (haven't used Studio in a while though). Decorated Names[^]
i think You need to include the object module of header.cpp inside the build of your dll.