简体   繁体   中英

unresolved external symbol main (no underscore)

I'm trying to compile a C program (specifically, the Python interpreter) as a plain statically linked 64-bit Windows binary. My command line looks like this:

cl /DPy_BUILD_CORE ... /link Advapi32.lib Shell32.lib User32.lib

where ... is the long list of source files and include directory specifications, and the library specifications I added as necessary to fix unresolved symbol errors. I'm now getting this error:

LIBCMT.lib(crt0.obj) : error LNK2019: unresolved external symbol main referenced in function __tmainCRTStartup

You might think this question has been asked before, but in this case main is spelled without a leading _ - something that doesn't happen in any of the other occurrences I could find with a Google search. Just to be sure, I tried writing a minimal main() function and throwing it in, and that still gave the above error plus a duplicate symbol warning, so that's not what's missing.

Any idea what's wrong here?

您尝试像使用入口点(不是静态链接库)的应用程序一样对其进行编译。

From Jeremy Kloth on the python-win32 mailing list:

The list of files also needs "..\\Modules\\python.c" to create an executable. (tested with VS2008 for x64).

That lack of leading underscore comes from how symbols are exported in 64-bit PEs vs. 32-bit PEs. That is, 64-bit PEs do not prepend an underscore to exported symbols.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM