Click here to Skip to main content
15,879,613 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've got a main program starting with:

int main(int argc, char**argv)
{
.....
}


It is compiled successfully, but when I built it, I got message as below. It means that my main program is an unresolved symbol to be referenced by exe_main() object. I got confused.


1>------ Rebuild All started: Project: dsim, Configuration: Debug Win32 ------
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(368,5): warning MSB8004: Output Directory does not end with a trailing slash.  This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.
1>  dsim.cpp
1>MSVCRTD.lib(exe_main.obj) : error LNK2019: unresolved external symbol _main referenced in function "int __cdecl invoke_main(void)" (?invoke_main@@YAHXZ)
1>.\Debug\dsim.exe : fatal error LNK1120: 1 unresolved externals


What I have tried:

I googled it by "
LNK2019
" but all cases are different from mine.
Posted
Updated 10-Jul-23 20:02pm
v2

There may be many reasons probably buried somewhere in your project settings. But finding the wrong setting is a task that can be only done by you.

The simplest solution would be creating a new project choosing the appropriate application type (I guess it is a non Unicode console application) and using the created file templates which contain a main function. Then copy and paste the existing code into the created files and add other existing source and header files as necessary.
 
Share this answer
 
Comments
Stan Huang 3-May-17 5:49am    
Sorry, it is my mistake. There is a definition at the beginning of the file containing main(): #ifdef TARGET_SIMU. I forgot to add "#define TARGET_SIMU" before it so the whole file is virtually empty. That's the reason why the main() is seen as unresolved symbol.
Jochen Arndt 3-May-17 5:51am    
Fine to see that the problem is solved and thank you for your feedback.
I recently encountered the same problem and i solved it by re-saving file in UTF-8 using notepad.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900