Luigi Auriemma

aluigi.org (ARCHIVE-ONLY FORUM!)
It is currently 19 Jul 2012 19:28

All times are UTC [ DST ]





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 22 posts ] 
Author Message
 Post subject: C compiler
PostPosted: 15 Dec 2007 20:53 

Joined: 24 Sep 2007 02:12
Posts: 1114
Location: http://sethioz.co.uk
hey. just wanted to know what c compiler is best to use.
Luigi you mentioned MingW GCC compiler in one topic .. can you give a direct link to gcc compiler .. there is lot of stuff on mingw homepage, im not sure which one is the right one.
what about Borland C builder ? any good ?


Top
 Profile  
 
 
 Post subject:
PostPosted: 15 Dec 2007 21:16 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
Mingw/Gcc in my opinion is the best because produces executables which are enough small (if compared to other compilers) and then it's multiplatform so building a windows/linux program is more simple than with other compilers (for example "#include <stdint.h>" and other syntax related stuff).

The problem of Mingw, as you have seen, is just the biiiig amount of packages caused by the independent updating of all the components.
If I'm not in error there is a way which auto install mingw (Automated MinGW Installer), I used it in the past but wasn't happy because it didn't allow me to use the latest beta stuff, probably now it's better.

So how I downloaded Mingw?
Simple, http://sourceforge.net/project/showfile ... up_id=2435 and download all the most recent things paying attention to avoid the *src* packages.


Top
 Profile  
 
 Post subject:
PostPosted: 16 Dec 2007 01:32 

Joined: 24 Sep 2007 02:12
Posts: 1114
Location: http://sethioz.co.uk
huh. you mean that i should get all packages under ''Latest File Releases'' ? ..or will the automatic do ? ..it still kind a confuses me.


Top
 Profile  
 
 Post subject:
PostPosted: 16 Dec 2007 17:18 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
Try first with the automatic program and check if everything works correctly.


Top
 Profile  
 
 Post subject:
PostPosted: 16 Dec 2007 23:16 

Joined: 24 Sep 2007 02:12
Posts: 1114
Location: http://sethioz.co.uk
well i tried to compile one program, but didnt work. says something like ''undefined reference to 'stristr' ''...etc
it does compile a simple program like ..
Code:
#include <stdio.h>

int main(int argc, char **argv)
{
  printf ("test123blabla\n");
  return (0);
}


Top
 Profile  
 
 Post subject:
PostPosted: 16 Dec 2007 23:34 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
stristr is not included by default in the windows related compilers, you must add it manually.
It's very simple, download this file:

http://aluigi.org/mytoolz/stristr.c

and compile it as an object:

gcc -c stristr.c

now it's read to be used like in the following example for my flashchatz tool:

gcc -o flashchatz.exe flashchatz.c mydownlib.c -lws2_32 -lz stristr.o

remember that you need zlib to compile flahschatz in case you receive an error:

http://gnuwin32.sourceforge.net/downlin ... ib-zip.php

just place the stuff in that zip in the Mingw folder


Top
 Profile  
 
 Post subject:
PostPosted: 17 Dec 2007 06:07 

Joined: 24 Sep 2007 02:12
Posts: 1114
Location: http://sethioz.co.uk
where do i put stristr.c (.o after compilation) ?
i prefer to use cygwin ...with cygwin i can browse to any folder i want, so i dont need to put everything into mingw/bin

i did a quick test with the flashchatz ... still got error in mingw ''stristr.o:stristr.c:(.text +0x34): undefined reference to '_imp___ctype_' ''
4 times of it .. with different .text part (address ?)


Top
 Profile  
 
 Post subject:
PostPosted: 17 Dec 2007 12:31 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
place stristr.c in the same folder where is located the program you want to compile


Top
 Profile  
 
 Post subject:
PostPosted: 19 Dec 2007 05:15 

Joined: 24 Sep 2007 02:12
Posts: 1114
Location: http://sethioz.co.uk
yeah i did, thats what it said then. ..need to look deeper in it .. somethings so not right with it.


Top
 Profile  
 
 Post subject: compile errors (q3fill)
PostPosted: 06 Jan 2008 07:47 

Joined: 14 Dec 2007 23:10
Posts: 6
I'd thought I should add my problem here :)
Hi, I'm using MingW version 5 fresh install and I'm trying to compile q3fill.c using
Quote:
C:\MinGW\bin\q3fill>..\gcc.exe -o q3fill2.exe q3fill.c stristr.o -lws2_32 -lz stristr.o


and I get

Quote:
..\..\lib\gcc\mingw32\3.4.5\..\..\..\..\mingw32\bin\ld.exe: cannot find -lz
collect2: ld returned 1 exit status


Any ideas?


Top
 Profile  
 
 Post subject:
PostPosted: 07 Jan 2008 11:41 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
http://gnuwin32.sourceforge.net/downlin ... ib-zip.php

you can use -lz or just c:\mingw\lib\libz.a


Top
 Profile  
 
 Post subject:
PostPosted: 07 Jan 2008 23:48 

Joined: 24 Sep 2007 02:12
Posts: 1114
Location: http://sethioz.co.uk
just on the record...
i got it working. compiles just fine, but file size is different from Luigi's compiled programs. Well still works the same way..so np.


Top
 Profile  
 
 Post subject:
PostPosted: 08 Jan 2008 01:46 

Joined: 14 Dec 2007 23:10
Posts: 6
Thanks for the reply.

The new error I get is below:

Quote:
C:\MinGW\bin\q3fill>..\gcc.exe -o q3fill2.exe q3fill.c -lws2_32 -lz stristr.o
F:\DOCUME~1\rwhite\LOCALS~1\Temp/ccqYbaaa.o:q3fill.c:(.text+0x28ca): undefined reference to `md5_update'
F:\DOCUME~1\rwhite\LOCALS~1\Temp/ccqYbaaa.o:q3fill.c:(.text+0x28e2): undefined reference to `md5_finish'
collect2: ld returned 1 exit status


Thanks in advanced,

sub.

Fixed - I just had to add md5.o to the list


Top
 Profile  
 
 Post subject:
PostPosted: 08 Jan 2008 13:06 

Joined: 22 Dec 2007 15:57
Posts: 10
what are the mingws switches to make executable smaller?

i know for 2 of them:
-s
-Os

are there some more maybe?

with these current 2, i can make C compiled "hello word" program of size 6kb. there has to be way to make it even smaller or not?


Top
 Profile  
 
 Post subject:
PostPosted: 08 Jan 2008 14:20 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
subt13:
you can also pass md5.c directly in the command-line, Gcc will automatically compile also it without compiling it as object before (faster and easier to use)

djeZo:
-s does an automatic stripping of the executable (like doing "strip file.exe") so this is one is very useful
-Os instead is referred to the compiled code, the assembly code will be built in a way that less instructions and space will be used.

Some other options which can probably (I'm not sure) save some bytes is probably -fomit-frame-pointer and -fexpensive-optimizations

Anyway a "hello world" of 6kb with a C compiler is probably the minimum possible, with all the compilers I have tried the size was ever bigger


Top
 Profile  
 
 Post subject:
PostPosted: 08 Jan 2008 14:42 

Joined: 22 Dec 2007 15:57
Posts: 10
i tried one of my projects with:

gcc -s -Os -o file.exe .....

same size with following command line:

gcc -s -Os -fomit-frame-pointer -fexpensive-optimizations -o file.exe ....

maye Os switch already contains fomit frame pointer and fexpensive optimizations.


Top
 Profile  
 
 Post subject: Thanks Luigi
PostPosted: 09 Jan 2008 01:55 

Joined: 14 Dec 2007 23:10
Posts: 6
djezo check out http://www.gentoo.org/doc/en/gcc-optimization.xml It may help you


Top
 Profile  
 
 Post subject:
PostPosted: 11 Jan 2008 03:04 

Joined: 24 Sep 2007 02:12
Posts: 1114
Location: http://sethioz.co.uk
hmm .. about the file size. does it even matter if the difference is so small ?
i mean not small, but .exe files are never too big. ofcourse its possible to reduce file size by like 50%, but it only matters if .exe is over 10mb or so.

What actually makes the .exe smaller/bigger ?


Top
 Profile  
 
 Post subject:
PostPosted: 11 Jan 2008 11:00 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
the big difference is made by the debugging informations and symbols which by default (without -s) are added to the executable.
the rest of the non code size is usually caused by the "padding" (the 0x90 and 0xcc bytes you see with the disassembler and I often use for placing my patches) inserted between the functions and at the end of the PE sections.


Top
 Profile  
 
 Post subject:
PostPosted: 11 Jan 2008 16:45 

Joined: 24 Sep 2007 02:12
Posts: 1114
Location: http://sethioz.co.uk
if you release FINAL release of the program and not planning to make any patches and/or changes etc...then basically all that info that makes it bigger is useless, right ?


Top
 Profile  
 
 Post subject:
PostPosted: 12 Jan 2008 21:01 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
debugging info and symbols are often useless for the 90% of the users, the rest need them only when an exception happens (bug, crash and so on).

The other additional data about I referred (the bytes between the functions) instead depends by the compiler and something else which is not clear.
For example, for what I have seen, on Linux these intra-functions bytes are practically absents.


Top
 Profile  
 
 Post subject:
PostPosted: 13 Jan 2008 21:44 

Joined: 22 Dec 2007 15:57
Posts: 10
ive found something;

heres tut for reducing exe when using MS VC++ for compiler:
http://www.catch22.net/tuts/minexe.asp

i tried following with mingw;

program is hello.c:
Code:
#include <windows.h>

int WinmainCRTStartup()   
{
   MessageBox(NULL, "Hello!", NULL, MB_ICONERROR | MB_OK);
   return 0;
}


build with:
Code:
gcc -s -Os -o hello.exe hello.c -nostdlib -mwindows -luser32


.exe file size is then only 2kb :)

but still, if MSVC can drop under 1kb for such simple program, why gcc wouldnt be able?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 22 posts ] 

All times are UTC [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron