Phenomenon
For a C project, there is no problem when compiling in 64 bit mode. If you switch to 32-bit mode, you will report an error
undefined reference to [‘ WinMain@16 ‘](mailto:’ WinMain@16 ‘)
Why
First, add the original code:
#include <windows.h>
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
ShellExecute(NULL,"open","taskkill"," /F /IM nginx.exe",NULL,SW_HIDE);
ShellExecute(NULL,"open","taskkill"," /F /IM php-cgi.exe",NULL,SW_HIDE);
ShellExecute(NULL,"open","taskkill"," /F /IM php.exe",NULL,SW_HIDE);
ShellExecute(NULL,"open","taskkill"," /F /IM BeyondClass.exe",NULL,SW_HIDE);
return 0;
}
According to the error prompt and the information found on the Internet, it is said that this code does not have the main() function
Solution
Add a main function to the code:
#include <windows.h>
int main()
{
ShellExecute(NULL,"open","taskkill"," /F /IM nginx.exe",NULL,SW_HIDE);
ShellExecute(NULL,"open","taskkill"," /F /IM php-cgi.exe",NULL,SW_HIDE);
ShellExecute(NULL,"open","taskkill"," /F /IM php.exe",NULL,SW_HIDE);
ShellExecute(NULL,"open","taskkill"," /F /IM BeyondClass.exe",NULL,SW_HIDE);
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
main();
return 0;
}
Compile again, OK, the problem is solved
Similar Posts:
- C1189 #error: “No Target Architecture”
- error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
- Using SQLite to show undefined reference to ` SQLite3_ open’…
- Error LNK2019: unresolved external symbol WinMain (vs2019)
- Wnmp environment configuration (Windows + nginx + MySQL + PHP)
- C write and read file via FILE and open method in a+ or r mode
- [Solved] Nginx Log Error: open() “/opt/Nginx/nginx/nginx.pid” failed (2: No such file or directory)
- [Solved] codeblocks Error: ‘to_string’ was not declared in this scope
- Nginx normal user startup configuration error: && springboot-swagger & Unable to infer base url
- [Solved] Nginx restart error: nginx: [error] open() “/run/nginx.pid” failed (2: No such file or directory)