From: Jason C. <ja...@so...> - 2001-08-17 20:06:49
|
> -----Original Message----- > From: min...@li... > [mailto:min...@li...]On Behalf Of Wizord > Sent: Friday, August 17, 2001 9:07 AM > To: min...@li... > Subject: [Mingw-users] Linking DirectX libraries > > Hello all. > > This is my first message to this list, and English is not my > primary language, > so please be patient :) Let me be the first (maybe) to say this: welcome! Recently, there appears to be several new people who aren't of english origin, so don't worry. > I'm working on a Win32, DirectX program using MingW. I'm trying > to give away > the infamous MS VisualC++. I don't use any IDE: only my text editor and > "make". Same here, Wordpad and make is all I need :). > Once the source was compiled with MinGW, I tried to build an > executable with a > command-line like this: > > gcc -o program.exe -L /mingw/lib -lkernel32 -luser32 -ladvapi32 > -lgdi32 -lwinmm > -lddraw -ldsound -ldinput -ldxguid program.o > > All the libraries referred with -l are on the /mingw/lib directory as > "libXXX.a" (all of them from the mingw-1.0.1-20010726 package). First off, you shouldn't need the -L switch, so long as the libraries you reference are in the /lib directory under where you installed all the MinGW files. GCC can determine the location of these libs relative to it's install path. > > gcc -o program.exe -L /mingw/lib -lkernel32 -luser32 -ladvapi32 > -lgdi32 -lwinmm > program.o /mingw/lib/libddraw.a /mingw/lib/libdsound.a > /mingw/lib/libdinput.a > /mingw/lib/libdxguid.a > > The only differences are: on the first, I put the libraries as > libraries; on > the second, I put them as as additional modules. Not quite the only difference. Notice that in the first command line, you placed you object (program.o) AFTER the libraries. In the second one, you placed it BEFORE all you directx libraries. LD (the linker) IS sensitive to the order of it's objects. If program.o references symbols in libdsound.a (et al), it must be written first on the command line. > > Regards, > Jose Luis Sanchez <aka> Wizord. Your English sounds pretty good! Hope I helped :), Jason A. Craig |