User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 455,965 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,684 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 1235 | Replies: 8
Reply
Join Date: Apr 2007
Posts: 15
Reputation: ganbree is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
ganbree ganbree is offline Offline
Newbie Poster

Question Entery point inside a Static Library

  #1  
Nov 18th, 2007
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?
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,539
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 40
Solved Threads: 972
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Most Valuable Poster

Re: Entery point inside a Static Library

  #2  
Nov 18th, 2007
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.
<<Freelance Programmer>> << Hobby Site>>
Signature links for sale. PM me for details
Reply With Quote  
Join Date: Apr 2007
Posts: 15
Reputation: ganbree is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
ganbree ganbree is offline Offline
Newbie Poster

Re: Entery point inside a Static Library

  #3  
Nov 18th, 2007
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.
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,539
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 40
Solved Threads: 972
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Most Valuable Poster

Re: Entery point inside a Static Library

  #4  
Nov 18th, 2007
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.
<<Freelance Programmer>> << Hobby Site>>
Signature links for sale. PM me for details
Reply With Quote  
Join Date: Apr 2007
Posts: 15
Reputation: ganbree is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
ganbree ganbree is offline Offline
Newbie Poster

Re: Entery point inside a Static Library

  #5  
Nov 18th, 2007
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
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,539
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 40
Solved Threads: 972
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Most Valuable Poster

Re: Entery point inside a Static Library

  #6  
Nov 18th, 2007
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.
<<Freelance Programmer>> << Hobby Site>>
Signature links for sale. PM me for details
Reply With Quote  
Join Date: Apr 2007
Posts: 15
Reputation: ganbree is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
ganbree ganbree is offline Offline
Newbie Poster

Re: Entery point inside a Static Library

  #7  
Nov 18th, 2007
Originally Posted by Ancient Dragon View Post
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
Reply With Quote  
Join Date: Aug 2005
Location: near St Louis, Missouri, USA
Posts: 11,539
Reputation: Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of Ancient Dragon has much to be proud of 
Rep Power: 40
Solved Threads: 972
Moderator
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Most Valuable Poster

Re: Entery point inside a Static Library

  #8  
Nov 18th, 2007
It is standard win32 api function. Scroll down to the bottom of the page and it will tell you what libraries are required.
<<Freelance Programmer>> << Hobby Site>>
Signature links for sale. PM me for details
Reply With Quote  
Join Date: Dec 2006
Location: india
Posts: 1,084
Reputation: vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all vijayan121 is a name known to all 
Rep Power: 9
Solved Threads: 163
vijayan121 vijayan121 is offline Offline
Veteran Poster

Re: Entery point inside a Static Library

  #9  
Nov 18th, 2007
> 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:
  1. #include <windows.h>
  2. // link with switches /SUBSYSTEM:CONSOLE /ENTRY:"look_ma_no_main"
  3. // to set these from within the ide
  4. // properties -> Linker -> System -> SubSystem := Console
  5. // properties -> Linker -> Advanced -> Entry Point := look_ma_no_main
  6.  
  7. extern "C" int look_ma_no_main()
  8. {
  9. char hello[] = "hello world!\n\r" ; // assumes narrow character console
  10. DWORD ignore = 0 ;
  11. WriteFile( GetStdHandle(STD_OUTPUT_HANDLE), hello,
  12. sizeof(hello)-1, &ignore, 0 ) ;
  13. MessageBoxA( 0, "Hello World!", "No CRT", MB_ICONEXCLAMATION ) ;
  14. return 0 ;
  15. }
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 9:06 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC