Add .c file
-
Hi Experts, I have 2 files ( .h and .c) I added in MFC dialog based application but I am getting linker error. Is there any special thing to add .c file.
john5632 wrote:
but I am getting linker error.
Are you certain the file is compiled as C++ ? What link errors ? Are you referencing an external library ?
Watched code never compiles.
-
Hi Experts, I have 2 files ( .h and .c) I added in MFC dialog based application but I am getting linker error. Is there any special thing to add .c file.
john5632 wrote:
...but I am getting linker error.
Care to share?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
-
john5632 wrote:
but I am getting linker error.
Are you certain the file is compiled as C++ ? What link errors ? Are you referencing an external library ?
Watched code never compiles.
yes, I am getting linker error 2019, 2001. error LNK2019: unresolved external symbol "void __cdecl Unload(void)" (?Unload@@YAXXZ) referenced in function "public: void __thiscall CTestDlg::OnBnClickedButton2(void)" (?OnBnClickedButton2@CTestprotDlg@@QAEXXZ) TestprotDlg.obj
-
yes, I am getting linker error 2019, 2001. error LNK2019: unresolved external symbol "void __cdecl Unload(void)" (?Unload@@YAXXZ) referenced in function "public: void __thiscall CTestDlg::OnBnClickedButton2(void)" (?OnBnClickedButton2@CTestprotDlg@@QAEXXZ) TestprotDlg.obj
So, in function
CTestDlg::OnBnClickedButton2()
you have a call to functionUnload()
, but the linker cannot find it. Where is functionUnload()
declared? [edit]I suspect that your source file should have the exctension .cpp rather than .c if this is an MFC project.[/edit]Unrequited desire is character building. OriginalGriff
-
yes, I am getting linker error 2019, 2001. error LNK2019: unresolved external symbol "void __cdecl Unload(void)" (?Unload@@YAXXZ) referenced in function "public: void __thiscall CTestDlg::OnBnClickedButton2(void)" (?OnBnClickedButton2@CTestprotDlg@@QAEXXZ) TestprotDlg.obj
Where is the "Unload" function? Is it in the file you added ? are you certain the file is compiled ?
Watched code never compiles.
-
yes, I am getting linker error 2019, 2001. error LNK2019: unresolved external symbol "void __cdecl Unload(void)" (?Unload@@YAXXZ) referenced in function "public: void __thiscall CTestDlg::OnBnClickedButton2(void)" (?OnBnClickedButton2@CTestprotDlg@@QAEXXZ) TestprotDlg.obj
I'm assuming certain things since you're haven't shared any code with us. I assume that the
Unload
function is written in the .c file and its declaration is available in the corresponding .h file. Now I believe that you're calling theUnload
function from a routine in a .cpp file. Since C++ compilers do name mangling, theUnload
function name will be internally changed. To prevent this from happening you must include the header file within anextern "C"
block.extern "C"
{
#include "my_c_header.h"
}«_Superman_» _I love work. It gives me something to do between weekends.
-
Hi Experts, I have 2 files ( .h and .c) I added in MFC dialog based application but I am getting linker error. Is there any special thing to add .c file.
Post the code.
John Nawrocki Chief Technical Advisor Custom Molded Products