[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Making MzScheme extensions using VC++ 5.0?



Matthew -

Thanks for the note. It was very helpful.

In poking around some more in DejaNews and Google, it does seem this is
a problem related to VC 6.0 changing the object file format so VC 5.0
can't link to it. Microsoft does this all the time with Word documents,
so I shouldn't be surprised in retrospect -- it's more or less the kind
of behavior one can expect from Microsoft. Of course, this issue is not
documented on their site anywhere I could find...

So, I downloaded GCC for Win32, installing gcc-2_95_2-crtdll.exe from:
  http://www.xraylith.wisc.edu/~khan/software/gnu-win32/
which leads to:
  http://www.xraylith.wisc.edu/~khan/software/gnu-win32/gcc.html
and then to:
  ftp://ftp.xraylith.wisc.edu/pub/khan/gnu-win32/mingw32/gcc-2.95.2/
(I did not install the patch files though...)

After a minor issue with setting my path in an NT User Variable ("as"
doesn't work) instead of a System Variable ("as" works), I could compile
a test C program (not a DLL) to make an "a.exe" which worked
stand-alone.

Thanks for the pointer to use --tool gcc. I tried this and mzc does pick
the right compiler. And the -v flag helps out too.

However, using mzc with gcc, I now get a different problem in the DLL
link: undefined reference to `scheme_make_string'

===============sample output=====================
C:\PdfScheme\extensions>c:\plt\mzc --tool gcc -v --cc Hello.c
MzScheme compiler (mzc) version 102, Copyright (c) 1996-2000 PLT
"Hello.c":
compile-extension: (g:\gcc-2.95.2\bin\gcc.exe -c -O2
-Ic:\plt\.\collects\setup\.
.\..\collects\mzscheme\include Hello.c -o .\Hello.obj)
 [output to ".\Hello.obj"]

C:\PdfScheme\extensions>c:\plt\mzc --tool gcc -v  --ld Hello.dll
Hello.obj
MzScheme compiler (mzc) version 102, Copyright (c) 1996-2000 PLT
"Hello.obj":
link-extension: (g:\gcc-2.95.2\bin\ld.exe --dll Hello.obj
c:\plt\.\collects\setu
p\..\..\collects\mzscheme\lib\win32\i386\gcc\mzdyn.exp
c:\plt\.\collects\setup\.
.\..\collects\mzscheme\lib\win32\i386\gcc\mzdyn.o
c:\plt\.\collects\setup\..\..\
collects\mzscheme\lib\win32\i386\gcc\init.o
c:\plt\.\collects\setup\..\..\collec
ts\mzscheme\lib\win32\i386\gcc\fixup.o --base-file C:\temp\tmp12.base -e
_dll_en
try@12 -o Hello.dll)
Hello.obj(.text+0x1f):Hello.c: undefined reference to
`scheme_make_string'
link-extension: command failed
========================================

Any thoughts from anyone out there? Is everone out there building
MzScheme extensions using a different version of GCC? Is it time to
figure out how to patch the GCC compiler I just installed (none of the
patches seemed to relate to DLL building that I noticed)? 

I noticed you referenced Cygwin. It is my understanding if I use that,
the related linked DLL code all falls under the GPL (not LGPL).
 
http://www.xraylith.wisc.edu/~khan/software/gnu-win32/x86-win32-ports.html
  http://sources.redhat.com/cygwin/licensing.html
In turn, that means my entire program that uses the DLL will also be
under the GPL. That is why I tried the crtdll version. 

If MzScheme has dependencies on Cygwin then does this create an issue
with having extentions under LGPL instead of GPL (unless you purchase a
commercial license)? Ah, what a tangled licensing web we weave... For me
a problem with the GPL is that it makes you commit to giving away source
at the start, whereas many projects want to reserve their options till
the finish (and then perhaps allow their users to reserve their
options). For example, I probably would not have thought seriously about
using MzScheme if was under the GPL (instead of LGPL, which gives me
pause enough), even though it is likely most if not all things I do with
it will eventually be given away with redistributable source. I
generally prefer BSD-Revised, X/MIT, or Python style licenses, because I
feel people people who want to contribute will do so anyway, and others
will just find a way around any restrictions. That being said, my wife
and I put a six-person year project (a simulation) under the GPL a few
years back, so go figure...

Sorry to be so bothersome with questions at the edge of MzScheme.
Hopefully after this is over I can move on to making some useful
MzScheme extensions (like truncate).

I'm also still trying to digest these details on building dlls with GCC:
  http://www.geocities.com/Tokyo/Towers/6162/win32/dll/make.html

-Paul Fernhout
Kurtz-Fernhout Software 
=========================================================
Developers of custom software and educational simulations
Creators of the Garden with Insight(TM) garden simulator
http://www.kurtz-fernhout.com

Matthew Flatt wrote:
> 
> I've had mostly good experience with MSVC 6, but never tried MSVC 5.
> Others have reported a similar "Internal error" message with MSVC 5. I
> wonder whether it's an incompatibility in the .obj format, since
> mzdyn.obj (as distributed) was built with MSVC 6.
> 
> Quoting Paul Fernhout:
> > So, I made my own project to build an Win32 DLL.
> > [...]
> > Any suggestions?  It seems that the "escheme.h" header is insufficient
> > for Windows. I think the alternative is to have a seperate export file,
> 
> mzc does indeed use an export file:
>   plt/collects/mzscheme/lib/win32/i386/msvc/mzdyn.exp
> 
> You can run mzc wth the -v flag to see exactly how it's calling cl.exe.
> 
> > Or is it time to switch to GCC?
> 
> Yes, I expect you'll find more success with Cygwin. The Cygwin
> interface for DLLs is messy, but mzc knows how work with it.
> 
> If you have both MSVC and Cygwin installed, use "--tool gcc" to get mzc
> to use Cygwin.
> 
> Matthew