Entry point for C++/CLI x64 WindowsForms App (VS 2

2019-01-29 05:24发布

问题:

I have the same problem as the user in Visual Studio 2015 c++/CLI boost::thread : If I use boost, Windows Forms and C++/Cli together, my app crashes on startup.

The proposed solution works for me (change Subsystem to Console); the only small disadvantage is that the console is started alongside the GUI.

There is another solution I've found (see https://bytes.com/topic/net/answers/642179-c-cli-winforms-app-native-static-library-singletons-cra) : Changing the entry point to "?mainCRTStartupStrArray@@$$FYMHP$01AP$AAVString@System@@@Z".

However this only works when compiling for 32 bit; for 64 bit the symbol cannot be resolved. My questions:

  • Is there a similar symbol that works for x64 as well?
  • How could one find these kind of symbols? I tried to locate them via dumpbin but with no success!

回答1:

Ah, light at the end of the tunnel for this nasty ignored problem. You can find the correct mangled name by grepping the .lib files in vc/lib/amd64. Out pops msvcmrt.lib, the name is:

?mainCRTStartupStrArray@@$$FYMHP$01EAPE$AAVString@System@@@Z

Bit of a bug in the mangling algorithm btw, it shouldn't have added the extra E's because these are managed identifiers. Links and runs fine, I haven't tested yet if it solves the static initialization order fiasco problem. It is promising.



标签: c++-cli