Конференция "KOL" » TIP: KOL and C .obj linking [Delphi, C++ Builder]
 
  • Thaddy © (08.01.12 18:05) [0]
    there is a not very well documented crtl.dcu in Delphi since version 6.
    This is the complete C runtime library and can be used for easy linking.
    It uses native Delphi memory management.
    Example:

    program Project4;
    {$APPTYPE CONSOLE}
    uses
     crtl;
    begin
       writeln('my name is ', crtl._strlen(PAnsichar('Thaddy')), ' characters long');
       readln;
    end.



    This will work from D2005 to D XE2 (Ansi mode)

    For D6 and D7 you need a little trick, because they didn't clean up the uses clause for crtl.dcu.
    There is a dependency on midaslib.dcu! and it gives an internal error.
    Well, not really.

    You can add this little unit:

    unit midaslib;
    interface
    implementation
    end.



    Now you can also use crtl with D6 and D7 (although a little big)
    Like:

    program Project4;
    // only necessary for Delphi 6 and Delphi 7
    {$APPTYPE CONSOLE}
    uses
     crt, midaslibl;
    begin
       writeln('my name is ', crtl._strlen(PAnsichar('Thaddy')), ' characters long');
       readln;
    end.



    From D2005 and higher it is now very easy to link small C obj files (OMF format)
    Maybe this tip is not only for KOL.
  • Thaddy © (08.01.12 18:12) [1]
    Typo.

    program Project4;
    // only necessary for Delphi 6 and Delphi 7
    {$APPTYPE CONSOLE}
    uses
    crt, midaslib;
    begin
      writeln('my name is ', crtl._strlen(PAnsichar('Thaddy')), ' characters long');
      readln;
    end.



    I recommend using BC5.5 freeware.
    f.e. with sqlite 2 you can create a < 100K sql database with KOL <smile>
  • Jon © (08.01.12 21:44) [2]
    Typo II:


    program Project4;
    // only necessary for Delphi 6 and Delphi 7
    {$APPTYPE CONSOLE}
    uses
    crtl, midaslib;
    begin
     writeln('my name is ', crtl._strlen(PAnsichar('Thaddy')), ' characters long');
     readln;
    end.



    Thanks for the info Thaddy - I see that you also have it on your blog:
    http://www.thaddy.com/drupal/?q=node/10

    Do you know if the same is possible with Free Pascal?
  • Thaddy © (08.01.12 21:59) [3]
    Yes,

    Freepascal could link C (not C++) OMF obj and also (but not mixed) COFF obj for years.
    The current release is also able to link C++ libs.
    In the case of FPC not crtl but libc.

    Tnx for correcting typo 2!
 
Конференция "KOL" » TIP: KOL and C .obj linking [Delphi, C++ Builder]
Есть новые Нет новых   [119256   +38][b:0][p:0.001]