简体   繁体   中英

Removed the C runtime library, and i am receiving some unresolved externals

hey guys i am working on an application and i removed the CRT to save alot of space in the executable and making it as small as possible :) the thing is that when i removed the CRT i also received tons of errors on unresolved external and i was able to remove most of them just by adding a few operators like these:

void * __cdecl operator new(unsigned int bytes) {
  return HeapAlloc(GetProcessHeap(), 0, bytes);
}

void __cdecl operator delete(void *ptr) {
  if(ptr) HeapFree(GetProcessHeap(), 0, ptr);
}

extern "C" int __cdecl __purecall(void) {
  return 0;
}

extern "C" const DWORD_PTR __security_cookie = 0xE64EBB40;

extern "C" void __fastcall __security_check_cookie(DWORD_PTR cookie) {
    if (cookie != __security_cookie)
        __asm int 3;
}

but now i am stuck with the last three errors and i have no clue on how to solve them, and one that i am really curious of is the _memmove error ? i am not using the memmove operator anywhere in my code so i have not clue why i am receiving it :P

atleast here are the errors, i would be very greatefull for your answers.

Error   2   error LNK2001: unresolved external symbol "void __cdecl std::_Xbad_alloc(void)" (?_Xbad_alloc@std@@YAXXZ)   C:\Users\Fluttershy!\documents\visual studio 2012\Projects\PincelStub\PincelStub\PincelStub.obj
Error   3   error LNK2001: unresolved external symbol "void __cdecl std::_Xlength_error(char const *)" (?_Xlength_error@std@@YAXPBD@Z)  C:\Users\Fluttershy!\documents\visual studio 2012\Projects\PincelStub\PincelStub\PincelStub.obj
Error   4   error LNK2001: unresolved external symbol _memmove  C:\Users\Fluttershy!\documents\visual studio 2012\Projects\PincelStub\PincelStub\PincelStub.obj

VC++ probably uses those internally (the first two to signal for error conditions and _memmove , well, to move memory blocks around in plain old struct assignments, for instance). The first two, I would just define as {} , but as for the last, I would try fiddling with optimization options (something about "intrinsic functions" etc.) or reimplement it fully (not just stub it).

I'm not sure why you want to shoot yourself in the leg, but whatever. The source of the CRT sits there, so you can just search it for the missing stuff and copy. the memmove function should be obvious. The other two looks like connected to standard exceptions.

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