How to tell link.exe to use wmain as an entry point. LNK2019: Unresolved external symbolic main link in __tmainCRTStartup function

I have a project that builds and links a visual studio, but not with our build system.

From what I can tell, tchar.h contains a macro to convert _tmain to wmain if UNICODE is defined. I checked the preprocessor output, and indeed _tmain was replaced with wmain. The file containing wmain then compiles just fine, but the linker complains that main is undefined.

LNK2019: Unresolved external symbolic main link in __tmainCRTStartup function

Converted wmain to main using another set of macros that I incorrectly turn on (due to the lack of -D parameters, etc.), or there is a special flag for link.exe that indicates the entry point.

Thanks.

Manual point / write: mainCRTStartup fixed it.

Edit: I just checked the main.obj file. wmain is definitely defined.

+4
source share
1 answer

MSVC uses a kind of run-time run that calls the expected entry point wmain() , WinMain() , etc.

There is nothing magical about these names. If you do not have the MSVC launcher source code, use your own launcher to meet your needs:

 int main (int argc, char **argv, char **envp) { wchar_t **w_argv = some_conversion_function (argc, argv); wchar_t **w_envp = some_conversion_function (some_count_function (envp), envp); return wmain (argc, w_argv, w_envp); } 

where I leave you with the implementation of some_conversion_function() and some_count_function() .

-1
source

Source: https://habr.com/ru/post/1389732/


All Articles