From d05748e041e7583b074c0bec4bbdf2eb90a431c5 Mon Sep 17 00:00:00 2001
From: William S Fulton
+Setting up the infrastructure needed for running the test-suite using the COM module is a bit more tricky than for other modules. This is because you need tools that are usually not present on POSIX systems, like a IDL and RC compiler. In addition often the compiler used for building SWIG itself is not appropriate for running the tests. This page shows some ways to set up an environment for running the test-suite. +
+
+This section lists the commands used for compiling the modules using various toolchains. This might be useful for verifying if the environment is set up correctly. We assume that we are using C++ and that the module is named 'example'. +
+
+
+$ midl example.idl +$ rc example.rc +$ cl /LD /GR /EHs /Feexample.dll example.cpp example_wrap.cxx example.def example.res ole32.lib uuid.lib advapi32.lib oleaut32.lib ++
+
+Please note that the MinGW linker does not understand .res files and the .rc file needs to be compiled to an object file before linking. To prevent potential name clashes you can rename the object file containing the resources, as shown below. +
+
+$ midl example.idl +$ windres example.rc example_rc.o +$ g++ -shared -o example.dll example.cpp example_wrap.cxx example.def example_rc.o -lole32 -luuid -ladvapi32 -loleaut32 ++
+
+$ midl example.idl +$ rcc example.rc +$ dmc -WD -L/exetype:nt -oexample.dll example.cpp example_wrap.cxx example.def example.res ole32.lib uuid.lib advapi32.lib oleaut32.lib kernel32.lib user32.lib ++
+
+Please note that the MinGW linker does not understand .res files and the .rc file needs to be compiled to an object file before linking. To prevent potential name clashes you can rename the object file containing the resources, as shown below. +
+
+$ widl -t -I /usr/include/wine/windows example.idl +$ i586-mingw32msvc-windres example.rc example_rc.o +$ i586-mingw32msvc-g++ -shared -o example.dll example.cpp example_wrap.cxx example.def example_rc.o -lole32 -luuid -ladvapi32 -loleaut32 ++
+
+
+$ widl -t -I /usr/include/wine/windows example.idl +$ wrc -i example.rc -o example.res +$ wineg++ -shared -o example.dll.so example.cpp example_wrap.cxx example.def example.res -lole32 -luuid -ladvapi32 -loleaut32 ++
+You are welcome to add instructions for other toolchains to this page. +
+
+This section shows how you can run the tests on Windows using Cygwin (using various C/C++ compilers). Other POSIX-like environments (UWIN, MS SFU, MKS Toolkit) might work too but have not been tested. We assume that you have the MIDL compiler (search for midl.exe) installed somewhere; it comes with Visual Studio and probably also with the Windows SDK (previously known as Platform SDK). +
+
+The only thing not available in Cygwin is the IDL compiler, so you will need to set it up (unless you are lucky and midl works out of the box). You can use the following script to set up the paths needed by MIDL (you may need to adjust the actual paths): +
+
+# vars_cygwin.sh + +# Path to midl.exe +export PATH=$PATH:/cygdrive/c/Program\ Files/Microsoft\ SDKs/Windows/v6.0A/bin + +# Path to cl.exe (used as preprocessor) +export PATH=$PATH:/cygdrive/c/Program\ Files/Microsoft\ Visual\ Studio\ 9.0/VC/bin/ + +# Contains DLLs needed by cl.exe +export PATH=$PATH:/cygdrive/c/Program\ Files/Microsoft\ Visual\ Studio\ 9.0/Common7/IDE + +# Platform includes, needed for MIDL +export INCLUDE=c:\\Program\ Files\\Microsoft\ SDKs\\Windows\\v6.0A\\Include ++
+Now you can use the following options for configure: +
+
+$ . ./vars_cygwin.sh +$ ./configure --with-com-cc=gcc --with-com-cxx=g++ --with-com-idl=midl --with-com-rc=windres ++
+
+You can use the following script to set up the paths needed by MSVC and MIDL (you may need to adjust the actual paths): +
+
+# vars_vc.sh + +# Path to midl.exe +export PATH=$PATH:/cygdrive/c/Program\ Files/Microsoft\ SDKs/Windows/v6.0A/bin + +# Path to cl.exe (used as preprocessor) +export PATH=$PATH:/cygdrive/c/Program\ Files/Microsoft\ Visual\ Studio\ 9.0/VC/bin/ + +# Contains DLLs needed by cl.exe +export PATH=$PATH:/cygdrive/c/Program\ Files/Microsoft\ Visual\ Studio\ 9.0/Common7/IDE + +# Includes +export INCLUDE=c:\\Program\ Files\\Microsoft\ SDKs\\Windows\\v6.0A\\Include\;c:\\Program\ Files\\Microsoft\ Visual\ Studio\ 9.0\\VC\\Include + +# Libs +export LIB=c:\\Program\ Files\\Microsoft\ SDKs\\Windows\\v6.0A\\Lib\;c:\\Program\ Files\\Microsoft\ Visual\ Studio\ 9.0\\VC\\Lib ++
+Now you can use the following options for configure: +
+
+$ . ./vars_vc.sh +$ ./configure --with-com-cc=cl --with-com-cxx=cl --with-com-idl=midl --with-com-rc=rc ++
+
+You can use the following script to set up the paths needed by DMC and MIDL (you may need to adjust the actual paths): +
+
+# vars_dmc.sh + +# Path to midl.exe +export PATH=$PATH:/cygdrive/c/Program\ Files/Microsoft\ SDKs/Windows/v6.0A/bin + +# Path to cl.exe (used as preprocessor) +export PATH=$PATH:/cygdrive/c/Program\ Files/Microsoft\ Visual\ Studio\ 9.0/VC/bin/ + +# Path to Digital Mars installation +# Note: It is important that DMC's cl.exe does not override Visual Studio's +# cl.exe which is used as the C preprocessor by midl.exe +export PATH=$PATH:/cygdrive/c/Program\ Files/dmc/bin + +# Contains DLLs needed by cl.exe +export PATH=$PATH:/cygdrive/c/Program\ Files/Microsoft\ Visual\ Studio\ 9.0/Common7/IDE + +# Platform includes, needed for MIDL +export INCLUDE=c:\\Program\ Files\\Microsoft\ SDKs\\Windows\\v6.0A\\Include ++
+Now you can use the following options for configure: +
+
+$ . ./vars_dmc.sh +$ ./configure --with-com-cc=dmc --with-com-cxx=dmc --with-com-idl=midl --with-com-rc=rcc ++
+
+On Unix platforms you will definitely need WINE (for WIDL and for run-tests) - most recent versions should be OK (0.9.46, 1.0 and 1.1.0 are known to work). You may use WINE's gcc wrapper (winegcc) or the separate MinGW cross compiler. We assume that the binaries are present in your PATH. +
+
+If you have WINE installed properly you can just use the following options for configure: +
+
+$ ./configure --with-com-runtool=wine --with-com-cc=winegcc --with-com-cxx=wineg++ --with-com-idl=widl --with-com-rc=wrc ++
+
+For MinGW use the following options: +
+
+$ ./configure --with-com-runtool=wine --with-com-cc=i586-mingw32msvc-gcc --with-com-cxx=i586-mingw32msvc-g++ --with-com-idl=widl --with-com-rc=i586-mingw32msvc-windres ++
+
+The test suite contains run-tests written in C and in VBScript. The C tests should 'just work' as should the VBScript ones on Windows. If you want to use the VBScript tests on Linux you will first need to install the Windows Script Host (standalone or as part of Internet Explorer) under WINE. This procedure may depend on the version of WINE/WSH/IE and is outside of the scope of this page. After installing WSH you will need to create a wrapper script (let's call it cscript) and put it in your PATH. The script could look like this: +
+
+#!/bin/sh + +wine c:\\windows\\system32\\cscript.exe $* ++
+You can then add the following option to configure: +
+
+--with-com-cscript=cscript ++
+On platforms other than Windows/Cygwin the presence of cscript is not autodetected (as it's highly unusual to have it) and you will need to specify it manually. + +
@@ -277,7 +548,7 @@ of differences between C/C++ and COM there are some aspects that need special attention. They are described in this section
-@@ -302,7 +573,7 @@ Print example.fact(4) -
@@ -375,7 +646,7 @@ extern char *path; // Read-only (due to %immutable) -
@@ -398,7 +669,7 @@ Please note that SWIG can infer the C type from the #define directive - is wrapped as a floating point value while VERSION is wrapped as a string.
-@@ -459,7 +730,7 @@ example.MyClass.bev = example.MyClass.PILSNER -
@@ -535,7 +806,7 @@ This is especially important when you use a cast from a supertype to a subtype; case only dynamic_cast is guaranteed to work reliably.
-@@ -570,7 +841,7 @@ about how SWIG handles C++ classes is provided in the next section.
-@@ -669,7 +940,7 @@ functions/variable). If you plan to create a multi-threaded program you should e either within the wrapped C/C++ code or in the target language.
-@@ -713,7 +984,7 @@ example.spam(b) -
@@ -774,7 +1045,7 @@ to hold the result and a pointer is returned (the generated COM code will free t memory when the object is no longer needed, that is when its reference count reaches 0).
-@@ -784,7 +1055,7 @@ You should not pass null to functions expecting a reference - in this case the function call will fail with an E_INVALIDARG error.
-@@ -817,7 +1088,7 @@ void spam(unsigned short); // Ignored -
@@ -837,7 +1108,7 @@ void defaults(double d=10.0, int i=0); -
@@ -899,7 +1170,7 @@ If you have more than one namespace and you want to keep their symbols separate, consider wrapping them as separate SWIG modules.
-@@ -953,7 +1224,7 @@ Obviously there is no way to use this syntax for calling a constructor that expe receive parameters.
-@@ -1005,7 +1276,7 @@ Obviously, there is more to template wrapping than shown in this example. More details can be found in the SWIG and C++ chapter.
-@@ -1013,7 +1284,7 @@ TODO
-@@ -1022,7 +1293,7 @@ COM objects. For users wanting to have a better understanding of how things work beneath the surface this section provides some more details.
-@@ -1084,7 +1355,7 @@ value as an out parameter, and the ISWIGWrappedObject interfac They will be described in later subsections.
-@@ -1157,7 +1428,7 @@ a class object (e.g. using CreateObject in Basic) and need to use the m class. There is no good reason for it other than that it has not yet been implemented.
-@@ -1228,7 +1499,7 @@ change the public interface of some of your wrapped classes you can do this eith manually specifying their new CLSIDs and IIDs, or by changing the master GUID.
-@@ -1242,7 +1513,7 @@ SWIG supports COM aggregation for proxy classes. The module class currently cann aggregated.
-@@ -1260,7 +1531,7 @@ then you will need to explicitly provide a pointer to the address where the retu is to be stored.
-@@ -1283,7 +1554,7 @@ so you should not rely on its presence. However it may be useful for debugging purposes.
-@@ -1300,7 +1571,7 @@ deallocated using delete; this means that the destructor will be called, just as it would be called in C++.
-@@ -1330,10 +1601,10 @@ You can customize the exception handling process by modifying the throws typemap.
--- cgit v1.2.1