# Re[4]: [Gc] Compiling a program on WINXP using winxp

Ivan Maidanski ivmai at mail.ru
Fri Apr 9 02:05:38 PDT 2010

```Fri, 9 Apr 2010 13:28:45 +0500 Yasir Majeed <leoyasir at gmail.com>:

> can you tell me how to generate libgc.a using mingw, as i did not have done
> that earlier?

Well, there are 3 ways: use configure, use CMake, and manually type gcc/ar.

I haven't tried the first 2 ways (although, I think it should be easy to install and use CMake build system) for MinGW, so I can tell you only how I'm doing. Type the following (to produce an optimized library w/o debug support):

gcc -O2 -fno-strict-aliasing -fno-omit-frame-pointer -Wall -DALL_INTERIOR_POINTERS -DGC_GCJ_SUPPORT -DNO_DEBUGGING -DUSE_MUNMAP -DGC_THREADS -DTHREAD_LOCAL_ALLOC -DPARALLEL_MARK -I.\include -I.\libatomic_ops\src -c *.c *.cpp

ar crus libgc.a *.o

Tips:
1. I really prefer to use "libgcmt.a" name instead of "libgc.a" to differ from the signle-threaded version.

2. You may remove all -D... options except for ALL_INTERIOR_POINTERS and GC_THREADS if you don't need these features/optimizations.

>
>
>
> 2010/4/9 Ivan Maidanski <ivmai at mail.ru>
>
> >
> > Fri, 9 Apr 2010 12:21:56 +0500 Yasir Majeed <leoyasir at gmail.com>:
> >
> > > Thanx for replying. I tried and followed all ur instructions but the
> > error
> > > is sam frend.... the matter is not solved
> > >
> > > 2010/4/9 Ivan Maidanski <ivmai at mail.ru>
> > >
> > > >
> > > > Fri, 9 Apr 2010 10:08:47 +0500 Yasir Majeed <leoyasir at gmail.com>:
> > > >
> > > > >  I compiled gc-7.0 in the following way on my winxp
> > > >
> > > > Try to use gc-7.2alpha4.tar.gz. Should work for you without a warning.
> > > >
> > > > >
> > > > > 1) open a console window
> > > > > 2) go to the directory of the gc
> > > > > 3) copy NT_STATIC_THREADS_MAKEFILE to MAKEFILE
> > > > > 4) type vcvars32.exe; it must be in the path
> > > > > 5) type nmake nodebug=1 CFG="gc - Win32 Release"
> > > > >
> > > > > That worked fine for me. i have also got gc.lib file now. Then i
> > wrote a
> > > > > simple program and compiled it using mingw using following command on
> > > > winxp
> > > > >
> > > > > > gcc test.c -o test gc.lib
> >
> > I'm sorry I've overlooked that you hadn't passed any -D... when compiling
> > test.c - this is half of your problem. The other half is that mingw might
> > not recognize correctly everything in the .lib generated by VS. It's better
> > to either:
> > - build libgc.a with MinGW (or mingw-w32);
> > - build gc.dll (either with VS or MinGW).
> >
> > Sample commands (you might also try CMake script but I haven't tried it
> > yet):
> > 1. build libgc.a and gctest.exe (with MinGW):
> >
> > gcc -O2 -fno-strict-aliasing -fno-omit-frame-pointer -Wall
> > -DALL_INTERIOR_POINTERS -DGC_GCJ_SUPPORT -DNO_DEBUGGING -DUSE_MUNMAP
> > -I.\libatomic_ops\src -c *.c *.cpp
> > ar crus libgc.a *.o
> > gcc -O2 -fno-strict-aliasing -fno-omit-frame-pointer -Wall
> > -DALL_INTERIOR_POINTERS -DGC_GCJ_SUPPORT -DNO_DEBUGGING -DUSE_MUNMAP
> > -I.\libatomic_ops\src -s -o gctest tests/test.c libgc.a -luser32
> >
> > 2. build gc.dll, gcdll.lib and gctest.exe with VS:
> > cl -Ox -W3 -GF -MT -DALL_INTERIOR_POINTERS -DGC_GCJ_SUPPORT
> > -DATOMIC_UNCOLLECTABLE -DNO_DEBUGGING -DUSE_MUNMAP -DGC_THREADS
> > -DTHREAD_LOCAL_ALLOC -DPARALLEL_MARK -I.\include -I.\libatomic_ops\src
> > -D_CRT_SECURE_NO_DEPRECATE -DGC_DLL -LD *.c *.cpp /link /implib:gcdll.lib
> > /out:gc.dll /nologo user32.lib
> > cl -Ox -W3 -GF -MT -DALL_INTERIOR_POINTERS -DGC_GCJ_SUPPORT
> > -DATOMIC_UNCOLLECTABLE -DNO_DEBUGGING -DUSE_MUNMAP -DGC_THREADS
> > -DTHREAD_LOCAL_ALLOC -DPARALLEL_MARK -I.\include -I.\libatomic_ops\src
> > -D_CRT_SECURE_NO_DEPRECATE -DGC_DLL tests\test.c /link /out:gctest.exe
> > gcdll.lib /nologo
> >
> > I repeat, gc-7.2alpha4 is assumed.
> >
> > > > >
> > > > > it gives error like that
> > > > >
> > > > > test.c: In function `main':
> > > > > test.c:5: warning: return type of 'main' is not `int'
> > > > > test.c:13:2: warning: no newline at end of file
> > > > > Warning: .drectve `/DEFAULTLIB:"uuid.lib" /DEFAULTLIB:"uuid.lib"
> > > > > /DEFAULTLIB:"LI
> > > > > BCMT" /DEFAULTLIB:"OLDNAMES" ' unrecognized
> > > > > ...
> > > > > gc.lib(mark.obj):(.text+
> > > > > 0x13fb): undefined reference to `_except_handler4'
> > > > > gc.lib(mark.obj):(.text+0x140d): undefined reference to
> > > > > gc.lib(win32_threads.obj):(.text+0x3f2): undefined reference to
> > > > `_tls_array'
> > > > > gc.lib(win32_threads.obj):(.text+0x3f7): undefined reference to
> > > > `_tls_index'
> > > > > gc.lib(win32_threads.obj):(.text+0x5c7): undefined reference to
> > > > > `__security_cook
> > > > > ie'
> > > > > gc.lib(win32_threads.obj):(.text+0x6b5): undefined reference to
> > > > > `@__security_che
> > > > > ck_cookie at 4'
> > > > > gc.lib(win32_threads.obj):(.text+0x6e6): undefined reference to
> > > > > `@__security_che
> > > > > ck_cookie at 4'
> > > > > gc.lib(win32_threads.obj):(.text+0x80b): undefined reference to
> > > > > `_except_handler
> > > > > 4'
> > > > > gc.lib(win32_threads.obj):(.text+0x81d): undefined reference to
> > > > > `__security_cook
> > > > > ie'
> > > > > gc.lib(thread_local_alloc.obj):(.text+0xe7): undefined reference to
> > > > > `_tls_array'
> > > > >
> > > > > gc.lib(misc.obj):(.text+0x627): undefined reference to
> > > > > gc.lib(misc.obj):(.text+0xa40): undefined reference to
> > > > > `@__security_check_cookie
> > > > > @4'
> > > > > collect2: ld returned 1 exit status
> > > > >
> > > > > *My questions are that how this error can be solved and secondly as i
> > > > want
> > > > > to use gc library and i dont want that gc source code should be fully
> > > > copied
> > > > > to my project. Instead gc lib should work for me. How do i achieve
> > that.
> > > >
> > > > Just build gc.lib and copy it to your project along with:
> > > > - the required header files in the "include" folder excluding
> > > > "include/private" (typically only gc.h, gc_config_macros.h, gc_cpp.h,
> > > > gc_version.h are required);
> > > > - doc/README file (which also acts as a License file).
> > > >
> > > > > Kindly reply me. M wating for ur response.*
> > > > >
> > > > >
> > > > > --
> > > > > Yasir Majeed
> > > > > Ph.D scholar
> > > > > Center of Research in Networks and Telecommunication (CoReNeT)
> > > > > www.corenet.org.pk
> > > >
> > > >
> > >
> > >
> > > --
> > > Yasir Majeed
> > > Ph.D scholar
> > > Center of Research in Networks and Telecommunication (CoReNeT)
> > > www.corenet.org.pk
> > > +923335935382
> > >
> > >
> >
>
>
>
> --
> Yasir Majeed
> Ph.D scholar
> Center of Research in Networks and Telecommunication (CoReNeT)
> www.corenet.org.pk