Fixed another regression in PlaySound.
[wine.git] / documentation / winelib-mfc.sgml
blob7f46226fdbbfc6bf3ca2e450b5d7ea73a0b8f757
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 compile
68 your program and if you will be distributing it. For example, if you
69 are releasing your code under the GPL, you cannot link your code to
70 MFC code because the GPL requires that you provide ALL sources to your
71 users. The MFC license forbids you from distributing the MFC source so
72 you cannot both distribute your program and comply with the GPL
73 license. On the other hand, if your code is released under the LGPL,
74 you cannot statically link your program to the MFC and distribute it,
75 but you can dynamically link your LGPL code and the MFC library and
76 distribute it.
77 </para>
78 <para>
79 Wine/Winelib is distributed under an X11-like license. It places few
80 restrictions on the use and distribution of Wine/Winelib code. I doubt
81 the Wine license will cause you any problems. On the other hand, MFC
82 is distributed under a very restrictive license and the restrictions
83 vary from version to version and between service packs. There are
84 basically three aspects you must be aware of when using the MFC.
85 </para>
86 <para>
87 First you must legally get MFC source code on your computer. The MFC
88 source code comes as a part of Visual Studio. The license for
89 Visual Studio implies it is a single product that can not
90 be broken up into its components. So the cleanest way to get MFC on
91 your system is to buy Visual Studio and install it on a dual boot
92 Linux box.
93 </para>
94 <para>
95 Then you must check that you are allowed to recompile MFC on a
96 non-Microsoft operating system! This varies with the version of MFC.
97 The MFC license from Visual Studio 6.0 reads in part:
98 </para>
99 <blockquote>
100 <para>
101 1.1 General License Grant. Microsoft grants to you as an
102 individual, a personal, nonexclusive license to make and use
103 copies of the SOFTWARE PRODUCT for the sole purposes of designing,
104 developing, and testing your software product(s) that are designed
105 to operate in conjunction with any Microsoft operating system
106 product. [Other unrelated stuff deleted.]
107 </para>
108 </blockquote>
109 <para>
110 So it appears you cannot even compile MFC for Winelib using this
111 license. Fortunately the Visual Studio 6.0 service pack 3 license
112 reads (the Visual Studio 5.0 license is similar):
113 </para>
114 <blockquote>
115 <para>
116 1.1 General License Grant. Microsoft grants to you as an
117 individual, a personal, nonexclusive license to make and use
118 copies of the SOFTWARE PRODUCT for the purpose of designing,
119 developing, and testing your software product(s). [Other unrelated
120 stuff deleted]
121 </para>
122 </blockquote>
123 <para>
124 So under this license it appears you can compile MFC for Winelib.
125 </para>
126 <para>
127 Finally you must check whether you have the right to distribute an
128 MFC library. Check the relevant section of the license on
129 <quote>redistributables and your redistribution rights</quote>. The
130 license seems to specify that you only have the right to distribute
131 binaries of the MFC library if it has no debug information and if
132 you distribute it with an application that provides significant
133 added functionality to the MFC library.
134 <!-- FIXME: quote relevant sections of EULA in above paragraph. -->
135 </para>
136 </sect1>
138 <sect1 id="mfc-compiling">
139 <title id="mfc-compiling.title">Compiling the MFC</title>
140 <para>
141 Here is a set of recommendations for getting the MFC compiled with
142 WineLib:
143 </para>
144 <para>
145 We recommend running winemaker in
146 '<option>--interactive</option>' mode to specify the right
147 options for the MFC and the ATL part (to get the include paths
148 right, to not consider the MFC MFC-based, and to get it to
149 build libraries, not executables).
150 </para>
151 <para>
152 Then when compiling it you will indeed need a number of
153 <literal>_AFX_NO_XXX</literal> macros. But this is not enough
154 and there are other things you will need to
155 '<literal>#ifdef</literal>-out'. For instance Wine's richedit
156 support is not very good. Here are the AFX options I use:
157 </para>
158 <para>
159 <programlisting>
160 #define _AFX_PORTABLE
161 #define _FORCENAMELESSUNION
162 #define _AFX_NO_DAO_SUPPORT
163 #define _AFX_NO_DHTML_SUPPORT
164 #define _AFX_NO_OLEDB_SUPPORT
165 #define _AFX_NO_RICHEDIT_SUPPORT
166 </programlisting>
167 </para>
168 <para>
169 You will also need custom ones for
170 <function>CMonikerFile</function>, <function>OleDB</function>,
171 <function>HtmlView</function>, ...
172 </para>
173 <para>
174 We recommend using Wine's msvcrt headers (<literal>-isystem
175 $(WINE_INCLUDE_ROOT)/msvcrt</literal>), though it means you
176 will have to temporarily disable winsock support
177 (<literal>#ifdef</literal> it out in
178 <filename>windows.h</filename>).
179 </para>
180 <para>
181 You should use g++ compiler more recent than g++ 2.95. g++
182 2.95 does not support unnamed structs while the more recent
183 ones do, and this helps a lot. Here are the options worth
184 mentioning:
185 <itemizedlist>
186 <listitem>
187 <para>
188 <literal>-fms-extensions</literal> (helps get more code
189 to compile)
190 </para>
191 </listitem>
192 <listitem>
193 <para>
194 <literal>-fshort-wchar -DWINE_UNICODE_NATIVE</literal>
195 (helps with Unicode support)
196 </para>
197 </listitem>
198 <listitem>
199 <para>
200 <literal>-DICOM_USE_COM_INTERFACE_ATTRIBUTE</literal>
201 (to get the COM code to work)
202 </para>
203 </listitem>
204 </itemizedlist>
205 </para>
206 <para>
207 When you first reach the link stage you will get a lot of
208 undefined symbol errors. To fix these you will need to go back
209 to the source and <literal>#ifdef</literal>-out more code
210 until you reach a 'closure'. There are also some files that
211 don't need to be compiled.
212 </para>
213 <para>
214 Maybe we will have ready-made makefile here someday...
215 </para>
216 </sect1>
218 <sect1 id="mfc-using">
219 <title id="mfc-using.title">Using the MFC</title>
220 <para>
221 </para>
222 <para>
223 Specific winemaker options,
224 the configure options,
225 the initialization problem...
226 </para>
227 </sect1>
228 </chapter>
230 <!-- Keep this comment at the end of the file
231 Local variables:
232 mode: sgml
233 sgml-parent-document:("wine-doc.sgml" "book" "chapter" "")
234 End: