On 1/31/12, Marc Feeley feeley@iro.umontreal.ca wrote:
On 2012-01-31, at 3:43 AM, REPLeffect wrote:
I just thought I'd share this in case it helps someone else.
To compile Gambit 4.6.3 in the MinGW/MSys shell, I had to add the following flags to the gcc commands for compiling C files to object files:
-fpermissive -fno-keep-inline-dllexport
Recent versions of MinGW use gcc version 4.6.1, which I suspect has stricter default requirements on the C code than prior versions of gcc, and I believe that's why I had to add -fpermissive.
The -fno-keep-inline-dllexport flag was added because I was getting an out of memory error compiling at least one C file.
I also added -Wno-write-strings because I was tired of warning messages.
It's a bit of a hack (and I'm sure there is a more correct place to put this), but I modified the configure script to do this by adding it in the FLAGS_OBJ line here:
case "$target_os" in
mingw*) # add Windows libraries needed by MinGW LIBS="$LIBS -lws2_32" FLAGS_OBJ="$FLAGS_OBJ -D_WINDOWS -Wno-write-strings
-fpermissive -fno-keep-inline-dllexport"
If Marc (or others) want more detail, I'd be happy to oblige. I can extract the 4.6.3 tar file somewhere else and try to build it, and not the exact error messages, etc.
Note that -fpermissive is specific to C++. Were you using --enable-cplusplus? Moreover, the documentation says:
-fpermissive Downgrade some diagnostics about nonconformant code from errors
to warnings. Thus, using -fpermissive will allow some nonconforming code to compile.
Now, why did you have to use this option? Can you send me the error message that were generated? I don't want to add this option to the default compilation options because it implies that the Gambit sources have some nonconformance issue, and that shouldn't be the case.
Marc
Yes, I am compiling the code using the C++ compiler. I am configuring with:
./configure --enable-single-host --enable-cplusplus
I just untarred the v4.6.3 tarball and reconfigured it with those options. After starting the build, the first set of errors showed up in os_tty.c:
os_tty.c:3399:52: error: invalid conversion from 'unsigned char*' to 'LPCSTR {aka const char*}' [-fpermissive] c:\mingw\bin../lib/gcc/mingw32/4.6.1/../../../../include/winuser.h:4084:24: error: initializing argument 2 of 'BOOL SetWindowTextA(HWND, LPCSTR)' [-fpermissive] os_tty.c: In function 'int lineeditor_copy_to_clipboard(___device_tty*, unsigned int*, int)': os_tty.c:4499:60: error: invalid conversion from 'LPVOID {aka void*}' to 'short unsigned int*' [-fpermissive] os_tty.c: In function 'int lineeditor_paste_from_clipboard(___device_tty*)': os_tty.c:4584:60: error: invalid conversion from 'LPVOID {aka void*}' to 'short unsigned int*' [-fpermissive] make[1]: *** [os_tty.o] Error 1 make[1]: Leaving directory `/f/tst/gambc-v4_6_3-devel/lib' make: *** [all-recursive] Error 1
A few simple casts got me past those errors (without the -fpermissive switch being turned on):
diff --git a/lib/os_tty.c b/lib/os_tty.c index e833328..a0abb96 100644 --- a/lib/os_tty.c +++ b/lib/os_tty.c @@ -3396,7 +3396,7 @@ ___U8 *text_arg;) { if (text_arg != NULL) { - SetWindowTextA (cons_wind, text_arg); /* ignore error */ + SetWindowTextA (cons_wind, (LPCSTR)text_arg); /* ignore error */ } else { @@ -4496,7 +4496,7 @@ int len;)
if (global_copy != NULL) { - ___U16 *locked_copy = GlobalLock (global_copy); + ___U16 *locked_copy = (___U16*)GlobalLock (global_copy);
if (locked_copy == NULL) GlobalFree (global_copy); @@ -4581,7 +4581,7 @@ ___device_tty *self;)
if (global_copy != NULL) { - ___U16 *locked_copy = GlobalLock (global_copy); + ___U16 *locked_copy = (___U16*)GlobalLock (global_copy);
if (locked_copy != NULL) {
C++ purists will say I should have used static_cast<___U16*>( ... ), etc. OK, well I didn't :-D
Interestingly enough, this time I was able to get v4.6.3 to successfully compile without using -fno-keep-inline-dllexport.
The machine I'm compiling on only has 1 GB of RAM, and the last time I compiled I probably had other programs running on the machine that were consuming a lot of memory. Basically nothing else was running while doing this test compile. However, I do know that in recent past attempts I *have* received an out-of-memory error when compling Gambit without the -fno-keep-inline-dllexport option. I have also used that option to get past out-of-memory errors when compiling my own programs written in Gambit Scheme (some of which use a fair bit of memory and are sometimes compiled on machines that are memory-constrained)
As a final test, I started over with a fresh copy ov v4.6.3, applied the above patch, and ran a make bootstrap, make update, and make install -- all of which worked wonderfully, without the -fpermissive switch being used.
BTW Marc, the MinGW "make check" and shell-command(bug 152) fixes you recently applied work great on my MingW-compiled copy of Gambit also.
Thanks, and let me know if there's any more information you need on this.