BillHung.Net


powered by FreeFind     sms

GCC

Simple Makefile

20 Dec 2005

all:
gcc -g -o frac frac.c

frac:
gcc -g -o frac frac.c

clean:
rm -f *.o *~ *.exe


#-g is for gdb debug, -o is for the output filename

 

http://cygwin.com/cygwin-ug-net/dll.html
http://gcc.gnu.org/

Making DLL with GCC

15 Dec 2005

$ gcc -c mydll.c
    //-c is to compile and assemble, but not link
$ gcc -shared -o mydll.dll mydll.o
    //generate the mydll.dll, which is 9.78KB, versus mydll.o object file is 0.49KB
$ gcc -o myprog myprog.c -L./ -l mydll
    //tells gcc to link myprog.c to mydll
$ myprog
Hello World!
 

 

mydll.dll
#include <stdio.h>

int hello()
{
  printf ("Hello World!\n");
}

 

myprog.c
int main ()
{
  hello ();