I'm using Visual C++ 2005 Express.

In my solution I have 2 projects, a static library project and a executable project.

The problem starts because I need WinMain() inside the static library to remove almost all the platform specific code from the executable project.

How you set the entry point on the executable project to the WinMain() inside the static library?

If you create a windows project (as opposed to a console program) just remove the winmain() that the IDE created and put it in the library. That's all there is to it. I assume you downloaded the Windows Platform SDK and installed it according to the instructions on M$ site. If you didn't then you can't create a windows program.

Sorry but it doesn't seem it be working that way, as that is what I have in effect done.

LINK : fatal error LNK1561: entry point must be defined

I need to define the entry point as inside the library.
Its probably cryptic but not complex.

I just tried it and the IDE does not have an option to include more than one project in the same solution, or maybe I just don't know how its done. I do it a lot with the Pro edition, but don't see it in the Express edition.

So zip up your project after deleting all compiler-generated files and post it and I'll give it a try.

I think I've almost solved this one:-

I've added the /ENTRY switch as /ENTRY:WinMainCRTStartup.

Problem is that I don't want any CRT in my application, do you know if that value with add any? I'm looking for any native/MFC ones

you can not do MFC with the Express edition of the compiler because the libraries are not included in the Windows PSDK. You need the Standard or better version.

you can not do MFC with the Express edition of the compiler because the libraries are not included in the Windows PSDK. You need the Standard or better version.

is CreateWindowEx() MFC? I always thought so; I might be wrong :$

> I don't want any CRT in my application
do not use anything from the library that rquires CRT to be initialized. no malloc or new, no printf or streams, no statics requiring dynamic initialization or having non-trivial destructors, no atexit etc. and write your own entry-point function. here is a sample console based program:

#include <windows.h>
// link with switches /SUBSYSTEM:CONSOLE /ENTRY:"look_ma_no_main"
// to set these from within the ide
//    properties -> Linker -> System ->  SubSystem := Console
//    properties -> Linker -> Advanced ->  Entry Point :=  look_ma_no_main

extern "C" int look_ma_no_main()
{
  char hello[] = "hello world!\n\r" ; // assumes narrow character console
  DWORD ignore = 0 ;
  WriteFile( GetStdHandle(STD_OUTPUT_HANDLE), hello, 
                 sizeof(hello)-1, &ignore, 0 ) ;
  MessageBoxA( 0, "Hello World!", "No CRT", MB_ICONEXCLAMATION ) ;
  return 0 ;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.