Thread: Open Watcom 1.9 small executable

  1. #1
    Registered User
    Join Date
    Jul 2017
    Posts
    3

    Open Watcom 1.9 small executable

    Hello everybody. One of these days I decided to try Watcom, but I can not understand how to compile correctly to get the minimal executable. In Microsoft VS 6.0, I used "cl C_exp.c / TC / MD / Ox / link / entry: main / subsystem: console" to compile this code:
    Code:
    #pragma comment (linker, "/ignore:4060,4078,4089,4096,4108")
    #pragma comment (linker, "/merge:.rdata=.data")
    #pragma comment (linker, "/merge:.text=.data")
    #pragma comment (linker, "/merge:.reloc=.data")
    #pragma comment (linker, "/align:0x8")
    #pragma comment (linker, "/filealign:0x8")
    #pragma optimize("gsy", on)
    
    #include <stdio.h>
    
    int main(void)
    {
        int number, right_digit;
        printf("enter num\n");
        scanf("%i", &number);
    
        do
        {
            right_digit = number % 10;
            
            printf("%i", right_digit);
            if (right_digit < 0) number = -number;
            number /= 10;
            
        } while(number != 0);
        printf("\n");
    getchar();
    
    return 0;
    }
    size .exe == 712 bytes
    And for watcom "wcl386 -bcl = nt -br -d0 option alignment = 16 С_exp.c" but without the #pragma directives in the code.

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    35,870
    So how big was the watcom version then?

    Sure, but does your code actually run?
    Linker Tools Warning LNK4060
    The MS-DOS application specified with the /STUB option does not have a full 40-byte header. The stub program may not run as expected.

    Linker Tools Warning LNK4078
    multiple "section" sections found with different attributes

    Linker Tools Warning LNK4089
    all references to "dynamic-link library" discarded by /OPT:REF

    Linker Tools Warning LNK4096
    The base address you specified is invalid.

    Linker Tools Warning LNK4108
    Bad alignment can prevent the operating system from loading the final image. Do not use the /ALIGN option unless building a driver or vxd.

    It seems like a p.ssing contest to me.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Jul 2017
    Posts
    3
    Yes, this code really works. I have 32-bit Windows XP, visual studio 6.0
    I use "cl prog.c / TC / MD / Ox / link / entry: main / subsystem: console / align: 16" for compilation, and it really works. The size of the executable file is 712 bytes. But it is compiled with cl.exe. And how to get the same thing with watcom? (I'm using open watcom 1.9). Wlink is a power but difficult instrument.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    35,870
    "works for me" is hardly a ringing endorsement.

    It's easy to make a small exe file if you strip out all the debug information and off-load all the work into a DLL.

    So that we don't have to STFW and RTFM for you, perhaps you could meet us half-way and post a link to the manual for wlink you're reading.

    > I have 32-bit Windows XP, visual studio 6.0
    I suppose you're logged in as administrator, compiling programs and surfing the web.
    Obsolete OS, obsolete compiler, obsolete work practices.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Registered User
    Join Date
    Jul 2017
    Posts
    3
    Yes, I work as an administrator. I could not find any articles on watcom as using only the compiler and linker to achieve the minimum executable file.

    ftp://openwatcom.org/manuals/current/lguide.pdf


  6. #6
    Registered User
    Join Date
    Oct 2006
    Posts
    3,420
    Honestly, why do you care? None of this is useful on a modern PC, with a modern operating system. Get a real compiler, and stop worrying about making the smallest possible executable file. Mass storage is cheap. Get a bigger hard drive.
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DLL linking in Watcom
    By Rutabega in forum Windows Programming
    Replies: 3
    Last Post: 11-21-2006, 10:12 AM
  2. Open Watcom CreateThread pointer parameter problems, m'kay?
    By Mad_guy in forum Windows Programming
    Replies: 2
    Last Post: 11-06-2005, 01:26 AM
  3. small executable with bcc32
    By mpx in forum C++ Programming
    Replies: 3
    Last Post: 05-05-2005, 11:15 AM
  4. Command line executable not a KDE executable?
    By FillYourBrain in forum Linux Programming
    Replies: 3
    Last Post: 10-03-2003, 12:01 PM
  5. Open Watcom C/C++....
    By Nitrous in forum C++ Programming
    Replies: 5
    Last Post: 07-29-2003, 12:34 PM

Tags for this Thread