NO

Author Topic: CRT Startup Function and Dependencies  (Read 10385 times)

Prodelos

  • Guest
CRT Startup Function and Dependencies
« on: May 21, 2012, 12:32:11 AM »
Maybe this is answered elsewhere, but I haven't been able to locate it.

I need to write my own startup functions. In MSVC 6, the startup function is called mainCRTStartup() for console apps, WinMainCRTStartup() for Windows programs, and _DllMainCRTStartup() for DLL's.

I need to know what to call the startup functions in Pelles C,  and what the Pelles C Runtime Library requires in the way of initialization in the startup to function properly.

Any information, or links to information regarding this would be greatly appreciated.

Thanks!

CommonTater

  • Guest
Re: CRT Startup Function and Dependencies
« Reply #1 on: May 21, 2012, 02:14:50 AM »
Take a look in the help file... it's all detailed in the appendix under "Program Startup".

With Pelles C... "When in doubt press F1 on your keyboard"


Online Vortex

  • Member
  • *
  • Posts: 867
    • http://www.vortex.masmcode.com
Re: CRT Startup Function and Dependencies
« Reply #2 on: May 21, 2012, 07:08:50 PM »
Hi Prodelos,

You can check this thread :

http://forum.pellesc.de/index.php?topic=88.0
Code it... That's all...

Prodelos

  • Guest
Re: CRT Startup Function and Dependencies
« Reply #3 on: May 24, 2012, 07:17:39 AM »
Thanks Vortex. That was very helpful.

I get the  following error whenever I try to create the MSVCRT.LIB to be able to compile your Wcrt0 projects:

C:\Program Files\PellesC\Bin>polink c:\windows\system32\msvcrt.dll /OUT:d:\PellesC\msvcrt.lib
POLINK: fatal error: Invalid machine type in object 'c:\windows\system32\msvcrt.dll'.


Whenever I add windows.h to a project and 'build' from the IDE, I get this error:

"C:\Program Files\PellesC\Include\Win\winnt.h(558): fatal error #1014: #error: "No target architecture"."


The Project Options | Compiler tab has X86 selected. I've even tried setting the _M_IA86=600 preprocessor symbol, to no avail.

I'm sure I have something set wrong somewhere, but I have no clue what it could be.

Any ideas?

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: CRT Startup Function and Dependencies
« Reply #4 on: May 24, 2012, 01:14:22 PM »
Wrong program, try this:
Code: [Select]
polib.exe c:\windows\system32\msvcrt.dll /OUT:d:\PellesC\msvcrt.lib
May the source be with you

Offline AlexN

  • Global Moderator
  • Member
  • *****
  • Posts: 394
    • Alex's Link Sammlung
Re: CRT Startup Function and Dependencies
« Reply #5 on: May 24, 2012, 03:41:44 PM »
Wrong program, try this:
Code: [Select]
polib.exe c:\windows\system32\msvcrt.dll /OUT:d:\PellesC\msvcrt.lib
Hi Timo

I know this line (or similar) exist many times in this forum. Perhaps it would be a good idea, if you write a little chapter in the Wiki of Pelles C how to do this with some knowledge around. :)
best regards
 Alex ;)

Online Vortex

  • Member
  • *
  • Posts: 867
    • http://www.vortex.masmcode.com
Re: CRT Startup Function and Dependencies
« Reply #6 on: May 24, 2012, 07:35:10 PM »
Hi Prodelos,

You can create the import library with def2lib.exe  The attachment contains an example. Don't forget to run BuildLib.bat before building the project.

def2lib needs only a module definition file to create an import library :

Code: [Select]
def2lib msvcrt.def
Code it... That's all...

Prodelos

  • Guest
Re: CRT Startup Function and Dependencies
« Reply #7 on: May 24, 2012, 11:48:35 PM »
Thanks guys!

I feel like such a 'newbie' now. :-[ POLIB to make a LIB, not POLINK. DUH! Learning how to use new tools sux! :)

I was able to create msvcrt.lib/.def using tools from my other compilers, no problem. I still can't figure out why PellecC spews errors about machine target/archetecture whenever I add windows.h. I reinstalled it to make sure nothing was corrupt, but the errors persist.

Also, PellesC doesn't seem to merge duplicate strings, which made my 86K app grow to 141K.  :o

I never had problems like this with Turbo C 2.0. Maybe it's time to retire.  ;)

TGIF!

CommonTater

  • Guest
Re: CRT Startup Function and Dependencies
« Reply #8 on: May 25, 2012, 04:53:54 AM »
First off... Turbo C is an antique, deserving of a museum display nest to the triceritops and steigosaurus.  It is non-standard in all kinds of ways, 2.0 produces 16 bit code that won't even run on a 64 bit operating system and it allows a great number of non-standard behaviours.

One reason not to merge duplicate strings is that you end up with crosslinked variables giving rise to magic values... changing one changes both.

If you have string constants you are using in multiple places, you can #define them like this...
Code: [Select]
#define FILE_PATH "C:\\testfiles\\test7\\fred.xyz"
#define PAGE_TITLE "This Title Appears On All Pages"
and refer to them by name as often as you like.

This also has the advantage that if you need to change it for some reason... changing the #define will effectively change it everywhere it's referenced.

 

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: CRT Startup Function and Dependencies
« Reply #9 on: May 25, 2012, 05:31:28 AM »
Quote
I still can't figure out why PellecC spews errors about machine target/archetecture whenever I add windows.h.
Remember to set Project -> Project options -> Compiler -> Enable Microsoft extensions
or -Ze in compiler commandline when you use Windows.h headers.
« Last Edit: May 25, 2012, 05:35:08 AM by timovjl »
May the source be with you

Prodelos

  • Guest
Re: CRT Startup Function and Dependencies
« Reply #10 on: June 02, 2012, 09:11:40 AM »
timovjl... you're a genius!

The -Ze switch fixed it. Thank you so much for your patience and your valuable assistance.

Online Vortex

  • Member
  • *
  • Posts: 867
    • http://www.vortex.masmcode.com
Re: CRT Startup Function and Dependencies
« Reply #11 on: June 02, 2012, 10:43:36 AM »
Hi Prodelos,

FYI, you can turn-off completely the CRT startup module if you wish.
Code it... That's all...