As some of you probably know I have been working on compiling Wine on Windows using Microsoft Visual C/C++ (MSVC). Even though it doesn't really work that well yet there have been at least some success.
Anyway recently I have began trying to get the Wine tests to compile and work using MSVC. More specifically I have been trying to get the my generated tests for data structure packing (tests/generated.c) to work. This currently works quite well. A few patches regarding errors found coming soon.
However there are at least two intresting ways to compile and run the tests on Windows. 1. Compile using the Wine headers. 2. Compile using the Microsoft headers.
Currently only (1) works in a portable way.
To get (2) to work I had to add the directory of the Microsoft includes to the begining of the include path. This is not very portable since it differs from installation to installation. I have currently hardcoding my specific directory.
The above have to be done because the Wine tests includes include/wine/test.h as thus ......\include (or similar depending on directory depth have to be added the the include). This overides the Microsoft headers!!! Microsoft C unlike GNU C have no option to avoid this other than adding the path the Microsoft include directory which as I previously mention varies depend on installation. :-)
However I finally think I have found a portable solution, that will work not only with the Wine test but also with Wine itself (eventhough that is perhaps less instresting right now).
We currently have the directory structure like
include: Wine's version of Windows headers include/wine: Wine's internal and "extension" headers
I would like to have a directory structure like
include: Wine's version of Windows headers include/wine: Wine's internal headers include/wine/wine: Wine's "extension" headers
With "extension" headers I mean that headers that are exported and usuable by Winelib applications.
This would allow me to, using MSVC, just do
/I ......\include\wine
instead of the current very ugly and unportable
/I d:\program files\microsoft visual studio\vc98\include /I ......\include
So concretely what I think needs to be done (not tested) is the following.
cd include/wine mkdir wine mv exception.h test.h unicode.h wine # Then include/Makefile.in needs to be changed accordingly as well. # In principle all the include/wine/ files named in include/Makefile.in # should be moved as well. However the files named above is enough for # the Wine tests AFAICS.
--- Make.rules.in 19 Oct 2002 17:15:00 -0000 1.131 +++ Make.rules.in 21 Oct 2002 12:58:35 -0000 @@ -45,7 +45,7 @@ LN = @LN@ LN_S = @LN_S@ TOOLSDIR = @TOOLSDIR@ -DIVINCL = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include $(EXTRAINCL) +DIVINCL = -I$(SRCDIR) -I. -I$(TOPSRCDIR)/include -I$(TOPOBJDIR)/include -I$(TOPSRCDIR)/include/wine $(EXTRAINCL) ALLCFLAGS = $(DIVINCL) $(CFLAGS) $(DEFS) $(OPTIONS) LD = @LD@ LDFLAGS = @LDFLAGS@
So what do you think?
Note that compiling Winelib applications under Linux might benefit from this as well since it makes it easier to use the real Microsoft headers together the Wine extensions (wine/*.h). Sure currently GNU C chokes on this but one day some compiler (GNU C or some other) might not...
Patrik Stridvall ps@leissner.se writes:
I would like to have a directory structure like
include: Wine's version of Windows headers include/wine: Wine's internal headers include/wine/wine: Wine's "extension" headers
With "extension" headers I mean that headers that are exported and usuable by Winelib applications.
That's ugly IMO. Besides there is no such distinction between internal and "extension" headers, all the headers in include/wine are supposed to be usable by Winelib app. I'd suggest you simply copy the ones you need with MSVC somewhere else to avoid conflicts.
On Mon, 21 Oct 2002, Patrik Stridvall wrote: [...]
However there are at least two intresting ways to compile and run the tests on Windows.
- Compile using the Wine headers.
- Compile using the Microsoft headers.
Currently only (1) works in a portable way.
To get (2) to work I had to add the directory of the Microsoft includes to the begining of the include path. This is not very portable since it differs from installation to installation. I have currently hardcoding my specific directory.
Actually there is a portable solution. Here's what i did when I compiled the Wine tests on Windows:
Run 'vcvars32.bat' first. When you install Microsoft Visual C++ you can either tell it to add environment variables with the useful stuff (either in autoexec.bat or the registry for NT), or just rely on 'vcvars32.bat'. This script is usually in the include directory: c:\Program Files\Microsoft Visual Studio\VC98\include\vcvars32.bat
Well, so I run it on the command line and then in the makefile (a realy .mak file) I put:
INCLUDE=$(TOTOP)\include;$(INCLUDE)
Then I don't use -I at all and the compiler will automatically use the environment variable. If using the .mak file directly from the IDE you don't even need to run vcvars32.bat,
However I still had include order problems: part of the headers were coming from MS and part from Wine but did not have time to look into it in detail. So I ended up extracting the tests from the Wine tree. But if you are able to avoid the header mixup then the above could work.