Sync winapi_check to Wine spec files.
[wine.git] / documentation / winelib-mfc.sgml
blob47c8d7372151347d300a3a4748cb8d7700f3c7c9
1 <chapter id="mfc">
2 <title id="mfc.title">Dealing with the MFC</title>
4 <sect1 id="mfc-introduction">
5 <title id="mfc-introduction.title">Introduction</title>
6 <para>
7 To use the MFC in a Winelib application you will first have to
8 recompile the MFC with Winelib. In theory it should be possible to
9 write a wrapper for the Windows MFC as described in
10 <xref linkend="bindlls" endterm="bindlls.title">. But in practice
11 it does not seem to be a realistic approach for the MFC:
12 </para>
13 <itemizedlist>
14 <listitem>
15 <para>
16 the huge number of APIs makes writing the wrapper a big task in
17 itself.
18 </para>
19 </listitem>
20 <listitem>
21 <para>
22 furthermore the MFC contain a huge number of APIs which are tricky
23 to deal with when making a wrapper.
24 </para>
25 </listitem>
26 <listitem>
27 <para>
28 even once you have written the wrapper you will need to modify
29 the MFC headers so that the compiler does not choke on them.
30 </para>
31 </listitem>
32 <listitem>
33 <para>
34 a big part of the MFC code is actually in your application in
35 the form of macros. This means even more of the MFC headers have
36 to actually work to in order for you to be able to compile an
37 MFC based application.
38 </para>
39 </listitem>
40 </itemizedlist>
41 <para>
42 This is why this guide includes a section dedicated to helping you
43 compile the MFC with Winelib.
44 </para>
45 </sect1>
47 <sect1 id="mfc-legal-issues">
48 <title id="mfc-legal-issues.title">Legal issues</title>
49 <para>
50 (Extracted from the HOWTO-Winelib written by Wilbur Dale
51 &lt;wilbur.dale@lumin.nl&gt;)
52 </para>
53 <para>
54 The purpose of this section is to make you aware of potential legal
55 problems. Be sure to read your licenses and to consult your lawyers.
56 In any case you should not consider the remainder of this section to
57 be authoritative since it has not been written by a lawyer.
58 </para>
59 <para>
60 Well, let's try to have a look at the situation anyway.
61 </para>
62 <para>
63 During the compilation of your program, you will be combining code
64 from several sources: your code, Winelib code, Microsoft MFC code,
65 and possibly code from other vendor sources. As a result, you must
66 ensure that the licenses of all code sources are obeyed. What you are
67 allowed and not allowed to do can vary depending on how you combine
68 the code and if you will be distributing it. For example, if you
69 are releasing your code under the GPL or LGPL, you cannot use MFC
70 because these licenses do not allow covered code to depend on
71 libraries with non-compatible licenses.
72 There is a workaround - in the license for your
73 code you can make an exception for the MFC library.
74 For details see
75 <ulink url="http://www.gnu.org/licenses/gpl-faq.html">The GNU GPL FAQ</ulink>.
76 </para>
77 <para>
78 Wine/Winelib is distributed under the GNU Lesser General Public
79 License. See the license for restrictions on the modification and
80 distribution of Wine/Winelib code. In general it is possible to
81 satisfy these restrictions in any type of application.
82 On the other hand, MFC
83 is distributed under a very restrictive license and the restrictions
84 vary from version to version and between service packs. There are
85 basically three aspects you must be aware of when using the MFC.
86 </para>
87 <para>
88 First you must legally get MFC source code on your computer. The MFC
89 source code comes as a part of Visual Studio. The license for
90 Visual Studio implies it is a single product that can not
91 be broken up into its components. So the cleanest way to get MFC on
92 your system is to buy Visual Studio and install it on a dual boot
93 Linux box.
94 </para>
95 <para>
96 Then you must check that you are allowed to recompile MFC on a
97 non-Microsoft operating system! This varies with the version of MFC.
98 The MFC license from Visual Studio 6.0 reads in part:
99 </para>
100 <blockquote>
101 <para>
102 1.1 General License Grant. Microsoft grants to you as an
103 individual, a personal, nonexclusive license to make and use
104 copies of the SOFTWARE PRODUCT for the sole purposes of designing,
105 developing, and testing your software product(s) that are designed
106 to operate in conjunction with any Microsoft operating system
107 product. [Other unrelated stuff deleted.]
108 </para>
109 </blockquote>
110 <para>
111 So it appears you cannot even compile MFC for Winelib using this
112 license. Fortunately the Visual Studio 6.0 service pack 3 license
113 reads (the Visual Studio 5.0 license is similar):
114 </para>
115 <blockquote>
116 <para>
117 1.1 General License Grant. Microsoft grants to you as an
118 individual, a personal, nonexclusive license to make and use
119 copies of the SOFTWARE PRODUCT for the purpose of designing,
120 developing, and testing your software product(s). [Other unrelated
121 stuff deleted]
122 </para>
123 </blockquote>
124 <para>
125 So under this license it appears you can compile MFC for Winelib.
126 </para>
127 <para>
128 Finally you must check whether you have the right to distribute an
129 MFC library. Check the relevant section of the license on
130 <quote>redistributables and your redistribution rights</quote>. The
131 license seems to specify that you only have the right to distribute
132 binaries of the MFC library if it has no debug information and if
133 you distribute it with an application that provides significant
134 added functionality to the MFC library.
135 <!-- FIXME: quote relevant sections of EULA in above paragraph. -->
136 </para>
137 </sect1>
139 <sect1 id="mfc-compiling">
140 <title id="mfc-compiling.title">Compiling the MFC</title>
141 <para>
142 Here is a set of recommendations for getting the MFC compiled with
143 WineLib:
144 </para>
145 <para>
146 We recommend running winemaker in
147 '<option>--interactive</option>' mode to specify the right
148 options for the MFC and the ATL part (to get the include paths
149 right, to not consider the MFC MFC-based, and to get it to
150 build libraries, not executables).
151 </para>
152 <para>
153 Then when compiling it you will indeed need a number of
154 <literal>_AFX_NO_XXX</literal> macros. But this is not enough
155 and there are other things you will need to
156 '<literal>#ifdef</literal>-out'. For instance Wine's richedit
157 support is not very good. Here are the AFX options I use:
158 </para>
159 <para>
160 <programlisting>
161 #define _AFX_PORTABLE
162 #define _FORCENAMELESSUNION
163 #define _AFX_NO_DAO_SUPPORT
164 #define _AFX_NO_DHTML_SUPPORT
165 #define _AFX_NO_OLEDB_SUPPORT
166 #define _AFX_NO_RICHEDIT_SUPPORT
167 </programlisting>
168 </para>
169 <para>
170 You will also need custom ones for
171 <function>CMonikerFile</function>, <function>OleDB</function>,
172 <function>HtmlView</function>, ...
173 </para>
174 <para>
175 We recommend using Wine's msvcrt headers (<literal>-isystem
176 $(WINE_INCLUDE_ROOT)/msvcrt</literal>), though it means you
177 will have to temporarily disable winsock support
178 (<literal>#ifdef</literal> it out in
179 <filename>windows.h</filename>).
180 </para>
181 <para>
182 You should use g++ compiler more recent than g++ 2.95. g++
183 2.95 does not support unnamed structs while the more recent
184 ones do, and this helps a lot. Here are the options worth
185 mentioning:
186 <itemizedlist>
187 <listitem>
188 <para>
189 <literal>-fms-extensions</literal> (helps get more code
190 to compile)
191 </para>
192 </listitem>
193 <listitem>
194 <para>
195 <literal>-fshort-wchar -DWINE_UNICODE_NATIVE</literal>
196 (helps with Unicode support)
197 </para>
198 </listitem>
199 <listitem>
200 <para>
201 <literal>-DICOM_USE_COM_INTERFACE_ATTRIBUTE</literal>
202 (to get the COM code to work)
203 </para>
204 </listitem>
205 </itemizedlist>
206 </para>
207 <para>
208 When you first reach the link stage you will get a lot of
209 undefined symbol errors. To fix these you will need to go back
210 to the source and <literal>#ifdef</literal>-out more code
211 until you reach a 'closure'. There are also some files that
212 don't need to be compiled.
213 </para>
214 <para>
215 Maybe we will have ready-made makefile here someday...
216 </para>
217 </sect1>
219 <sect1 id="mfc-using">
220 <title id="mfc-using.title">Using the MFC</title>
221 <para>
222 </para>
223 <para>
224 Specific winemaker options,
225 the configure options,
226 the initialization problem...
227 </para>
228 </sect1>
229 </chapter>
231 <!-- Keep this comment at the end of the file
232 Local variables:
233 mode: sgml
234 sgml-parent-document:("wine-doc.sgml" "book" "chapter" "")
235 End: