Share via


error LNK2019: unresolved external symbol "int __cdecl subMain(unsigned char *)"

Question

Tuesday, March 24, 2020 5:55 AM

I has a subMain() function at sub.c, which was added by me to VC++2019 MFC project. It's from Linux. I called subMain() from an action routine of a button. I built it and got the below error message. CmqtestDlg::OnBnClickedOk(void) is the action routine of the button defined at VC++2019.

In the beginning of , I added one line "extern int subMain(unsigned char* ip);"

1> Build started: Project: mqtest, Configuration: Debug x64
1>sub.c
1>mqtestDlg.obj : error LNK2019: unresolved external symbol "int __cdecl subMain(unsigned char *)" (?subMain@@YAHPEAE@Z) referenced in function "public: void __cdecl CmqtestDlg::OnBnClickedOk(void)" (?OnBnClickedOk@CmqtestDlg@@QEAAXXZ)
1>  Hint on symbols that are defined and could potentially match:
1>    subMain
1>D:\programs\mqtest\mqtest\x64\Debug\mqtest.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "mqtest.vcxproj" -- FAILED.

All replies (3)

Tuesday, March 24, 2020 8:16 AM ✅Answered | 1 vote

Try this declaration:

extern "C" int subMain( unsigned char* ip );

 


Tuesday, March 24, 2020 8:33 AM ✅Answered | 1 vote

Check these explanations:


Tuesday, March 24, 2020 8:31 AM

Could you provide link to document to explain it in detail?