|
From: Keith M. <kei...@us...> - 2010-11-26 11:37:29
|
On 26 November 2010 10:16, William Simpson wrote: >>> ... I am referring to my makefile, >>> not Keith's. [Keith's did not work at all, as shown in the message >>> below] ... >> >> In what way did it not work? > > This was what happened when I did a make: > C:\MinGW\local\lib\src\rand>make > gcc -c rand.c > del librand.a > Could Not Find C:\librand.a So, I think we've established that's because you lose your current working directory, when cmd.exe is spawned to run 'del'. > ar rcvs librand.a rand.o > a - rand.o This appears to work, without loss of CWD. > gcc rand.o librand.a -o rand Where did this come from? I don't recall it, in my original script. > c:/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../libmingw32.a(main.o):main.c:(.tex > t+0xd2): undefined reference to `WinMain@16' > collect2: ld returned 1 exit status > mingw32-make: *** [rand] Error 1 John Brown (not his real name, I suspect) has already explained why the above rogue command will cause this failure. > But below you said to do make install, so: Yes, because it is generally a bad idea to combine the logically separate tasks of building and installing into a single operation; you want an opportunity to test a new build before you cavalierly overwrite a previous good installation with an untested, and possibly bad copy. Thus, my version of the makefile separates the two tasks: "make" on its own will perform the default "rand" task, to build librand.a in CWD; a subsequent "make install" (after testing) installs it. > C:\MinGW\local\lib\src\rand>make install > copy librand.a c:/mingw/local/lib > The system cannot find the file specified. > mingw32-make: *** [install] Error 1 Again, because spawning cmd.exe lost CWD. >> ... you need: >> >> libdir = c:\mingw\local\lib >> includedir = c:\mingw\local\inlcude >> >> or maybe even: >> >> libdir = c:\\mingw\\local\\lib >> includedir = c:\\mingw\\local\\inlcude > > Tried both. Each time, results identical to above. Same reason: the source file to copy is in lost CWD. >> (because make uses backslash as an escape; I don't know if GNU make >> built for native windows is smart enough to guess when any single >> backslash is intended to represent a path name separator, or an escape). > > I think \ by itself is ok. Good to know. GNU make generally does try to DTRT, but I do wonder if there may be some cases where it may assume that a single backslash is intended as a directory name separator, when the actual intent was for it to be an escape? > You know, I agree that Windows is complete crap, and that bash is far > superior to cmd.exe. I have used linux since 1998. You don't need to > convince me. But being forced to work in a Windows environment I have > to be pragmatic. Maybe I will install MYSYS at some point, but for > now, given my primitive skill set and needs, I think I can cope with > cmd.exe vs bash. I would never use grep and other unix utilities. IIRC, you said you used mingw-get for your initial installation? In that case, maybe: mingw-get install msys-tiny msys-make will give you sufficient for your needs. It will give you a bash shell, plus the MSYS version of GNU make, plus a few other essentials -- you would need to use rm rather than del, cp or ln rather than copy, and mv rather than move or ren, so it includes them. >> ... (And please stop top-posting, or I may stop responding). > > OK sorry about top-posting. No problem. It's just that I will quickly lose interest, if you make me scroll backwards and forwards, or read reams of barely relevant history, to determine context for your replies. -- Regards, Keith. |