Compiling and distributing C programs


M

Malcolm McLean

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?
 
Ad

Advertisements

J

James Kuyper

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 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
consequence.
... 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.

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.
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?

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
<http://sourceforge.net/directory/games/os:linux/?q=snake> to find out
how they do it.
 
N

Nobody

However it won't link the PlaySound() function.

You need to link in winmm.lib.
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?

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
curve.

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).
 
I

Ian Collins

Malcolm said:
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.

Just avoid windows and move to a more developer friendly, anti-virus
free, platform.
 
B

BartC

Ian Collins said:
Just avoid windows and move to a more developer friendly, anti-virus free,
platform.

Sure. Then you just have to persuade thousands of customers to do the same!
 
Ad

Advertisements

I

Ian Collins

BartC said:
Sure. Then you just have to persuade thousands of customers to do the same!

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.
 
J

James Kuyper

Sure. Then you just have to persuade thousands of customers to do the same!

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
created.
 
L

Lynn McGuire

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?

www.openwatcom.org has a nice C and C++ compiler
with a fairly primitive IDE.

Lynn
 
M

Malcolm McLean

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
created.

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.
 
J

JohnF

Lynn McGuire said:
www.openwatcom.org has a nice C and C++ compiler
with a fairly primitive IDE. Lynn

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?) ?
 
Ad

Advertisements

B

BartC

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

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.
 
J

James Kuyper

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.

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 <https://modaps.nascom.nasa.gov:9500/software/>
(though only after you've registered
<https://modaps.nascom.nasa.gov:9500>, 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
<http://newsroom.gsfc.nasa.gov/sdptoolkit/toolkit.html>,
<http://www.hdfgroup.org/>; 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.
 
B

BartC

James Kuyper said:
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

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.
 
J

James Kuyper

....
Inevitable if you dismiss the other main options of distributing source
code, or somehow using interpreters;

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.
... 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.

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.
In any case, you will still need *some* executables to do anything with the
source code or byte code.

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.
 
M

Malcolm McLean

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.
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.
 
Ad

Advertisements

B

BartC

James Kuyper said:
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.

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.
 
M

Malcolm McLean

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.
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.
 
J

James Kuyper

....
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.

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.
 
Ad

Advertisements

C

cmontiers

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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top