Reputation: 4775
I feel very foolish asking this question, but please bear with me and read the symptoms before commenting "it's main()
, duh".
I'm working on a project in Visual Studio Express 2012. We have hitherto built only for the Win32 (x86) platform but I am converting the .exe build to 64 bit. I now have a fully linked .exe, but a funny thing happened along the way: the entry-point no longer gets called.
The entry-point to the (C++, console) program is a C++ function declared at file scope with the following signature: int main(int argc, char * argv[])
. This function has happily worked in the x86 executable since day 1. It is not being called on x64:
main
like int * p(nullptr); *p = 5;
, the program doesn't crash (even without this I'm certain main()
isn't running).What could be causing this issue? How can I debug it? I'm not sure where to set a breakpoint in my debuggers due to the fact that none of my code ever runs...
Upvotes: 4
Views: 3689
Reputation: 6303
0xc000007b
is STATUS_INVALID_IMAGE_FORMAT
. That is, the operating system never even gets the binary loaded far enough to start executing it.
There could be something wrong in your compilation settings. However, usually when I have seen this error, the problem has been in the 64-bit application trying to dynamically link to a 32-bit DLL.
Check your libraries, and verify your paths point to the 64-bit versions of any DLLs.
Upvotes: 6
Reputation: 145439
The errlook
utility says 127 is “The specified procedure could not be found.” Searching that text in <winerror.h>
yielded ERROR_PROC_NOT_FOUND
.
This sounds like a DLL problem.
Now I don't like the term "entry point" applied to main
, because what should one then call the entry point, the address you supply to the linker to set the entry point? Startup function might be better. This is not just quibbling: Microsoft's tech writers have confused themselves so thoroughly that now 20 years of incorrect and just self-contradictory documentation about PE entry points could be celebrated. They'll never get it right, I think.
gdb
is in my experience pretty unreliable, not a good tool to check whether something is called. It's unreliable, at least when it detects me as user. Instead do a message box or something just as easily recognized and guaranteed, in main
.
Upvotes: 0
Reputation: 351
You can find (and modify) the entry point to an exe by the /ENTRY compiler flag.
http://msdn.microsoft.com/en-us/library/f9t8842e.aspx
To set this linker option in the Visual Studio development environment
Upvotes: -1