Compiling and distributing C programs

Discussion in 'C Programming' started by Malcolm McLean, Jun 23, 2013.

  1. Here's the situation.

    I'm using Windows. My desktop machine is Vista, my notebook runs XP.

    I had a free compiler called tcc (tiny C compiler) which was small and
    minimal, but did most of what I wanted without fuss, which was to write
    portable commandline utilities. The anti virus broke it and started
    labelling the executables it produced. I had a nice paid for Visual
    Studio 6.0, but the personal version (cost about 60 quid) not the
    professional. Microsoft deliberately broke it.

    Microsoft sell paid for C compilers, but they are too expensive for
    hobby use. They offer Visual Studio Express. So I downloaded it. It's
    a horrible thing and you have to fight it just to compile "hello world".
    But it does the trick, as long as you only want to compile standard C
    with a few Windows API calls.

    Now I wanted to write a snake game. Just a bit of fun. So I had to fight
    it to put in the few amateur graphics - you have to edit the so-called
    resource script by hand. However it won't link the PlaySound() function.
    I can't get the beeps in. Now if a freebie hobby compiler isn't suitable
    for "snake", what is it intended for?

    Also I can't distribute the executables easily. Everyone bans them because
    of the virus threat.

    Now the Vista machine is getting long in the tooth. I thinking of replacing
    it by Windows 8. But I feel so badly bitten by Microsoft, that I really
    feel twice shy. But the reality is that most PCs still run Windows.

    I want to be able to write little programs like "snake", with graphics and
    sound, and distribute them to people who want to play them. I don't have
    vast sums to spend. What's the best way of achieving that end?
    Malcolm McLean, Jun 23, 2013
    1. Advertisements

  2. Malcolm McLean

    James Kuyper Guest

    I presume your anti-virus software labeled them as infected? If so, can
    you be certain it was wrong? If a virus were infecting your compiler,
    your linker, and possibly any one of several other possible pieces of
    software, production of infected executables would be a plausible
    You're using "paid for" as an adjectival phrase here. I couldn't
    possibly cite the relevant grammar rule, but based upon a half-century
    of voracious reading in English, I'm pretty sure that should be written
    as "paid-for". I found it very confusing without the dash.
    If you were looking specifically for a Microsoft solution, I couldn't
    answer any of your questions. However, if that's what you were looking
    for, you would have posted it to a MicroSoft-oriented forum (right?). I
    know that you can get all the tools you need to build a snake-like game
    for Linux, absolutely free. It's not my area of expertise, so I couldn't
    give you an detailed advice about how to do it, but snake-like games are
    commonplace in the Linux world. Download one of the projects from
    <> to find out
    how they do it.
    James Kuyper, Jun 23, 2013
    1. Advertisements

  3. Malcolm McLean

    JohnF Guest

    Not sure about graphics support, but I use both
    to distribute win executables without problem.
    And, btw, people seem to still request executables,
    despite virus possibilities.
    JohnF, Jun 23, 2013
  4. Malcolm McLean

    Nobody Guest

    You need to link in winmm.lib.
    Either MinGW (gcc for Windows) or Visual Studio Express.

    There are plenty of advantages to using VS (e.g. the debugger), but any
    program of that size has a significant learning curve. Actually, whatever
    program you use, programming for a modern OS has a significant learning

    Personally, I use MinGW if I'm writing a cross-platform program, and VS if
    it's going to be Windows-only (apart from anything else, it's easier to
    find pre-compiled libraries for VS).
    Nobody, Jun 23, 2013
  5. Malcolm McLean

    Ian Collins Guest

    Just avoid windows and move to a more developer friendly, anti-virus
    free, platform.
    Ian Collins, Jun 23, 2013
  6. Malcolm McLean

    BartC Guest

    Sure. Then you just have to persuade thousands of customers to do the same!
    BartC, Jun 23, 2013
  7. Malcolm McLean

    Ian Collins Guest

    If I were developing a simple game (of for the time!) I would be be
    writing it on Linux for Android, or Mac for IOS. if my kids and their
    mates are typical, that's were the audience and potential market is
    these days.
    Ian Collins, Jun 23, 2013
  8. Malcolm McLean

    James Kuyper Guest

    No, that part's already been done. The number of people using
    non-windows platforms is measured at least in the millions. Whether it's
    measured in 10's of millions, or hundreds, I'm not sure, but the last
    time that the number of users of operating systems other than windows
    was measured in mere thousands was probably before windows itself was
    James Kuyper, Jun 24, 2013
  9. Malcolm McLean

    Lynn McGuire Guest has a nice C and C++ compiler
    with a fairly primitive IDE.

    Lynn McGuire, Jun 24, 2013
  10. I downloaded an Android dev kit. I did get "hello world" running on it. But I've only 2GB of memory, and someone told me it needs 16. Certainly it ran far too slowly to be usable.
    But I'm replacing the Vista machine, so a 16GB job isn't out of the question.
    Malcolm McLean, Jun 24, 2013
  11. Malcolm McLean

    JohnF Guest

    Thanks for that. Looks interesting, and I'll give it a try
    when time permits. Anybody have any remarks comparing
    experiences with mingw, djgpp, openwatcom (and other?) ?
    JohnF, Jun 24, 2013
  12. Malcolm McLean

    BartC Guest

    So what do they use instead?

    I think if you want to use C, then distribution in the form of some sort of
    executable is inevitable.
    BartC, Jun 24, 2013
  13. Malcolm McLean

    James Kuyper Guest

    For something that's supposedly inevitable, it seems to have been
    avoided with considerable frequency.

    Most of the software that NASA pays my company to write for them is
    available exclusively as C (or in some cases, Fortran) source code at no
    charge to the public <>
    (though only after you've registered
    <>, which requires faxing to us a
    signed copy of NASA's Software Usage Agreement). The third-party
    libraries it relies upon are entirely free and available as C (or C++)
    source code
    <>; the same is true of much of the other
    software running on both my work and home computers.

    Disclaimer: I am not speaking in any official capacity as a
    representative of either my company or NASA.
    James Kuyper, Jun 24, 2013
  14. Malcolm McLean

    BartC Guest

    Inevitable if you dismiss the other main options of distributing source
    code, or somehow using interpreters; end-users just want to play the game
    (or whatever the application does) not spend days trying to get something
    working. They shouldn't need to know what language is being used anyway, and
    besides the app might not be open source.

    In any case, you will still need *some* executables to do anything with the
    source code or byte code.
    BartC, Jun 24, 2013
  15. Malcolm McLean

    James Kuyper Guest

    Well, anything can become inevitable, if you dismiss the alternatives.
    Failing to mention that your conclusion was dependent upon that
    dismissal gave your comment a very different meaning, in that context.
    You're now saying that "distributing source code, or somehow using
    interpreters" are "the main options"? That's almost exactly the opposite
    of the implications, in context, of your previous claim. Both claims are
    too extreme to match reality, which, as usual, messily decides to fall
    in between them.
    Well, of course you're unlikely to get source code if it isn't some form
    of "open source". But there's a awful lot of open source software out
    there nowadays.
    Well, of course. For that matter, you need some form of executable just
    to boot up the computer. But most software. open source or not, gets
    distributed without including all of the other software it needs before
    you can use it. OS distributions are the main exception to this rule,
    and I can't think of too many others.
    James Kuyper, Jun 24, 2013
  16. It's a little game. I want to write it quickly and easily, and put it
    somewhere that players, who may well be children, can get it, play it
    for a few minutes, then move on to something else. If I can charge a few
    pence then that's fine, if I can't that's fine also.

    It's not intended as a hugely serious project.

    I've just downloaded jQuery. I'm seriously thinking of rewriting it in
    Javascript, purely because of Microsoft's attitude to developers like
    me. But it's a pity.
    Malcolm McLean, Jun 24, 2013
  17. Malcolm McLean

    BartC Guest

    Let's list all the options:

    o Self-contained binary
    o Source code
    o Byte-code
    o All the others

    For most practical purposes, for distributing programs to end-users to be
    actually executed, the binary method has to be *the* main one. The others
    might also be 'main' because they follow immediately in the list, but would
    normally be dismissed.
    BartC, Jun 24, 2013
  18. I read one bioinformatics paper which was comparing sequence alignment
    algorithms. It mentioned that some methods had been excluded from the
    analysis because they were too difficult to install and run. These were
    people with doctorates in a computer-related discipline, doing something
    as their full time job of work.
    For the casual user, it's got to be click and go. He just can't be fiddling
    about wit paths and make scripts and other odds and ends.
    Malcolm McLean, Jun 25, 2013
  19. Malcolm McLean

    James Kuyper Guest

    That's more reasonable, by reason of being less extreme, than your
    original claim that distribution as an executable was "inevitable". Your
    use of "most practical purposes", "main one", and "normally" all bring
    it into closer alignment with reality.
    James Kuyper, Jun 26, 2013
  20. Malcolm McLean

    cmontiers Guest

    False positive detections can happen with any compiler.
    I remember that using Visual C++ 2002 it use msvcrt71.dll (i not remember well), but with a hexadecimal editor i change it for use msvcrt.dll, this text was detected by some antivirus, i remember letting the reference only as "msvcrt"

    I use tiny c as my compiler, and i modified some thing from the source code (tccpe.c and chkstk.S) in some scenarios for avoid some false detections.

    Solve false positives for all antivirus is a fight, and nothing assure that if you bypass today all detections, in a month it continue.

    With tiny c you can link for use the function PlaySound, i do it.

    using tiny c sometimes you need some macros definitions from files .h of mingw.
    For example: PlaySound uses mmsystem.h (but if you look it from mingw folder (c:\Mingw) you can copy some macros):

    #include <windows.h>

    #define SND_SYNC 0
    #define SND_NODEFAULT 2
    #define SND_FILENAME 0x20000

    int main(int argc, char ** argv)
    if (argc > 1) {
    PlaySound("C:\\Windows\\Media\\chimes.wav", NULL, SND_FILENAME | SND_SYNC | SND_NODEFAULT);

    return 0;


    for link you need run this commands:

    cd /d c:\tcc\
    tiny_impdef.exe c:\windows\system32\winmm.dll
    move winmm.def lib
    tcc.exe source.c -lwinmm

    For insert resources in the executable generated by tcc.exe I use program called Resource Hacker for insert the resources.
    cmontiers, Jul 25, 2013
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.