Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've migrated from vs2002 to vc2010express.

I used to be able to compile a MINIMAL .exe for a simple c++ app.
Now my .exe needs msvcr100.dll :(

I don't use ANY c runtime funcs.
I don't want exception handling or SEH.
No NOTHIN!
I've defined a custom entry point for linker and...
C#
void *operator new (unsigned int sz)
{ void *p;
   p = (void *) ::HeapAlloc (::GetProcessHeap (), 0, sz ? sz : 1);
   if (p == NULL)  Die ("outa memory!");
   return p;
}

void operator delete (void *p)  {if (p) ::HeapFree (::GetProcessHeap (), 0, p);}


I've tweaked the settings best I can, but can't seem to get the linker to not need msvcr100.dll :(

Does anybody have a minimal type .vcxproj file they could share with me or ideas to set c compiler, linker settings to?

Or just some tips?

Pleeeeeeeease :)

...Steve
Posted
Comments
Richard MacCutchan 13-Sep-10 15:14pm    
With reference to your comment below, I would be extremely surprised if MessageBox could function without the use of at least one of the 'printf/sprintf' family of functions. And even without that the prologue to any C/C++ program is created from the C runtimes. As to argc and argv these are mere placeholder names for the parameters passed into main() but have no other significance.
stephen.hazel 13-Sep-10 15:47pm    
"hello world" has no %s in it, so it doesn't NEED printf. There's also a wsprintf func built into win32 api - it doesn't do FULL sprintf formatting, but does ints and the easier stuff.

::MessageBox is a pure win32 api function - no c runtime support needed.
Although argc,v are just param names, there are some funcs that NEED to be linked in from c runtime that turn pure win32 api command line (a long string) into split up strings in argc,v...
Emilio Garavaglia 14-Sep-10 3:13am    
Although all that works, the stabdard signature for operator new shold be either (or both, if yo need it)
void *operator new(size_t, std::nothrow_t) throw() or
void *operator new(size_t) throw(std::bad_alloc).

Until none of your code (or its dependent) ever meet #include<new> that's not an issue, but if this happen -to avoid the "different exception throwing" error- you can include yourself <new> and <exception> (note: not <stdexcept> since it also requires <string>) and declare your new ops. as inlined and calling your internal functions.

I suppose you have to use the /NODEFAULTLIB linker switch. But then you've to set an entry point for your application, see the following MSDN page [^].
:)
 
Share this answer
 
v2
Comments
stephen.hazel 13-Sep-10 16:17pm    
That at the very least looks like a good place to start.

THANKYOU so much :)
Correct me if I am wrong, but is this not the C runtime library that is required to run event the most basic "Hello World" program?
 
Share this answer
 
Comments
stephen.hazel 13-Sep-10 14:23pm    
You're right, but printf and argc,argv use by "hello world" actually pull in a lot of code.
(c runtime lib)

My app is the equivalent, but doesn't use argc,argv and doesn't use printf.
Instead it uses ::MessageBox (NULL, "", "Hello WinWorld", MB_OK|MB_ICONINFORMATION);

I don't even use strcmp or memcpy, etc.
I don't use =any= c runtime lib funcs.
But something in my compile/link params is still causing it to be pulled in...:(

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900