C program not linking to CRT calls memset() for unknown reasons
Question
Sunday, November 9, 2014 10:28 PM
Hi,
I've set up Visual C++ 2008 to not use the CRT as described here: http://www.dreamincode.net/forums/topic/228780-microsoft-writing-c-applications-without-the-runtime-system/. For some reason I keep getting the error:
1>test.obj : error LNK2001: unresolved external symbol _memset
1>C:\test.exe : fatal error LNK1120: 1 unresolved externals
when trying to build the following code:
#include <windows.h>
#include <ddraw.h>
typedef HRESULT (WINAPI *DIRECTDRAWCREATE) (LPGUID, LPDIRECTDRAW*, IUnknown*);
void WinMainCRTStartup(void) {
HMODULE hDDrawDLL;
LPDIRECTDRAW lpDD;
LPDIRECTDRAWSURFACE lpDDSPrimary;
DIRECTDRAWCREATE DirectDrawCreate;
DDSURFACEDESC ddsd = { 0 };
hDDrawDLL = LoadLibrary(L"DDRAW.DLL");
DirectDrawCreate = (DIRECTDRAWCREATE) GetProcAddress(hDDrawDLL, "DirectDrawCreate");
DirectDrawCreate(NULL, &lpDD, NULL);
lpDD->lpVtbl->SetCooperativeLevel(lpDD, NULL, DDSCL_NORMAL);
ddsd.dwSize = sizeof ddsd;
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
lpDD->lpVtbl->CreateSurface(lpDD, &ddsd, &lpDDSPrimary, NULL);
lpDDSPrimary->lpVtbl->Release(lpDDSPrimary);
lpDD->lpVtbl->Release(lpDD);
FreeLibrary(hDDrawDLL);
ExitProcess(0);
}
It seems to be related to DDSURFACEDESC ddsd = { 0 }; and lpDD->lpVtbl->CreateSurface(lpDD, &ddsd, &lpDDSPrimary, NULL); but I don't see what could be wrong. I hope that you're able to help me.
(I know that DD is deprecated but I need the ability to use overlays with source color keying)
All replies (1)
Monday, November 10, 2014 1:00 AM âś…Answered
I've set up Visual C++ 2008 to not use the CRT as described here: http://www.dreamincode.net/forums/topic/228780-microsoft-writing-c-applications-without-the-runtime-system/. For some reason I keep getting the error:
1>test.obj : error LNK2001: unresolved external symbol _memset
1>C:\test.exe : fatal error LNK1120: 1 unresolved externals
See if this old thread sheds any light:
MSVC++ 2005 automatically calling memset?
Archived Forums
Visual C++ Express Edition
https://social.msdn.microsoft.com/Forums/en-US/a51fe950-cd74-4133-8d84-1bc07b353bc2/msvc-2005-automatically-calling-memset?forum=Vsexpressvc
Note that this in a closed and archived forum. so you won't be able to post to that thread.
- Wayne