blob: 37d58068409c10d5ed85289b94c0aa317f53d678 [file] [log] [blame]
Wilbur N. Dalecf4bb072000-06-07 03:59:39 +00001WineLib HOWTO
2Version 04-Jun-2000
3
4AUTHOR:
5Wilbur Dale
6Lumin Software BV
7Zandheuvel 52 B
84901 HW Oosterhout (NB)
9The Netherlands
10
11wilbur.dale@lumin.nl
12
13WARNING: This HOWTO is incomplete. I expect to add to it on a weekly
14basis until it is complete.
15
16=====================================================================
17
18Table of Contents
19
20 I. Introduction: Wine vs. WineLib
21
22 II. Legal Issues
23
24III. How Much Work?
25
26 IV. Compiling A Simple Win32 Program
27
28 V. Compiling A Win32 Program With Resources
29
30 VI. DLLs
31 A. Native DLL.
32 B. so DLL.
33 C. elfdll.
34
35VII. How to use MFC
36 A. Using a native MFC dll
37 B. Compiling MFC
38
39VIII. Trademarks
40Windows 3.x, Windows 95, Windows 98, Windows NT are trademarks of
41Microsoft Corporation.
42
43Unix is a trademark of ???? FIXME: who has the trademark this week?
44
45CrypKey is a trademark of Kenonic Controls Ltd.
46
47All other trademarks are the property of their respective owners.
48
49=====================================================================
50
51I. Introduction: Wine vs. WineLib
52
53Wine/Winelib provides the Win32/Win16 API's to a non-Microsoft
54operating system. The wine/winelib Win32/Win16 functions use X11
55functions to perform the actual drawing on the screen. Wine and
56winelib are based on the same set of functions that implement the
57Win32/Win16 API. The difference between wine and winelib is the type
58of executable that is loaded into memory and executed. If an
59executable and any associated DLLs were compiled for x86 hardware
60running the Windows 3.x, 95, 98, or Windows NT (TM) operating systems,
61then Wine can use a special binary loader to load the program and the
62libraries into memory and execute it. Winelib on the other hand allows
63you to take the source for such a program and DLLs and compile it into
64the native format of a x86 Unix or Linux operating system. Winelib
65also allows you to partially compile the program and DLLs into the
66native format. For example, if you use a DLL from a vendor to provide
67some functions to your program and the vendor does not give you
68source, then you can use the Windows version of the DLL to provide the
69functions and compile the rest of your program in the native form for
70your system.
71
72Windows compilers assume a different structure than standard
73compilers. For example, standard compilers assume that the function
74main() exists and is the entry point of the program. On the other
75hand, windows compilers create a main() that issues an error message
76that states that windows is required for executing the program and the
77real entry point is the function WinMain(). As a result, winelib
78provides certain aids to generate code so that your program can be
79compiled and run as written for windows. For example, winelib
80generates a main() to initialize the windows API, to load any
81necessary DLLs and then call your WinMain(). Therefore you need to
82learn four basic operations to compile a windows program using
83winelib: compiling a simple program, compiling resources, compiling
84libraries, and compiling MFC. These skills are operations are
85explained in later sections of this HOWTO.
86
87Before you start porting your windows code to winelib, you need to
88consider whether you are allowed to port your program to winelib. As
89you compile your program using winelib, you will be combining software
90from several sources and you need to ensure that the licenses for the
91components is compatible. Hence in the next section, we will examine
92several legal issues.
93
94II. Legal Issues
95
96Disclaimer! I am not a lawyer. The purpose of this section is to make
97you aware of potential legal problems. Be sure to read your licenses
98and to consult your attorney.
99
100During the compilation of your program, you will be combining code
101from several sources: your code, winelib code, code from your vendor's
102DLLs (if any), and Microsoft MFC code (if used). As a result, you must
103ensure that the licenses of all code sources are obeyed. What you are
104allowed and not allowed to do can vary depending on how you compile
105your program and if you will be distributing it. For example, if you
106are releasing your code under the GPL, you cannot link your code to
107MFC code because the GPL requires that you provide ALL sources to your
108users. The MFC license forbids you from distributing the MFC source so
109you can not comply with the GPL license except by not distributing you
110program. On the other hand, if your code is released under the LGPL,
111you cannot statically link your program to MFC and distribute it, but
112you can dynamically link your LGPL code and MFC code and distribute
113it.
114
115Wine/Winelib is distributed under an X11-like license. It places few
116restrictions on the use and distribution of Wine/Winelib code. I doubt
117the Wine license will cause you any problems. On the other hand MFC is
118distributed under a very restrictive license and the restrictions vary
119from version to version and between service packs.
120
121If you plan on using MFC, there are three hurdles to legally using
122MFC. The first hurdle is how to legally get MFC source code on your
123computer. MFC source code comes as a part of Visual Studio. The
124license for Visual Studio implies it is a single product that can not
125be broken up into its components. The cleanest way to get MFC on you
126system is to use a dual boot Linux box with the windows partition
127visible to the Linux OS. Boot into windows and install Visual
128Studio. Since Visual Studio is installed on the computer, you have not
129broken it into its components. There may be other solutions, but I
130think this is the easiest.
131
132The second hurdle for MFC is the legality of compiling MFC on a
133non-Microsoft operating system. This varies with the version of MFC.
134
135MFC license from Visual Studio 6.0:
136
137 1.1 General License Grant. Microsoft grants to you as an
138 individual, a personal, nonexclusive license to make and use
139 copies of the SOFTWARE PRODUCT for the sole purposes of designing,
140 developing, and testing your software product(s) that are designed
141 to operate in conjunction with any Microsoft operating system
142 product. [Other unrelated stuff deleted.]
143
144So it appears you cannot compile MFC for Winelib using this
145license. On the other hand, Visual Studio 6.0 service pack 3 (Visual
146Studio 5.0 is similar):
147
148 1.1 General License Grant. Microsoft grants to you as an
149 individual, a personal, nonexclusive license to make and use
150 copies of the SOFTWARE PRODUCT for the purpose of designing,
151 developing, and testing your software product(s). [Other unrelated
152 stuff deleted]
153
154So it appears you can compile MFC for Winelib using this license.
155
156The third hurdle is your legal right to distribute an MFC
157library. Check the relevant section of the license on redistributables
158and your redistribution rights. As I read the license, you only have
159the right to distribute binaries of the MFC library if it has no debug
160information and if you distribute it with an application that provides
161significant added functionality to the MFC library.
162
163Once you have examined the licenses for all of the sources used in
164compiling your program and have decided you can legally compile you
165program using winelib, you should probably experiment with your
166program running under wine to determine how much work will be involved
167in the port. The next section will give advice on estimating the
168amount of work required for porting your program to winelib.
169
170III. How Much Work?
171
172Wine and winelib use the same functions to implement the windows API;
173hence, if your program correctly runs under wine, it should run under
174winelib. However, wine/winelib is incomplete. You may have trouble
175running your program under wine. Many people have successfully run many
176programs under wine, so there is a good chance you will have no
177trouble.
178
179Wine executes the binary program that was compiled for a windows
180operating system. There are differences between the windows operating
181system and Unix/Linux operating systems. For example, in Windows 3.x,
182Windows 95, and Windows 98, the program has direct access to the
183hardware. A copy protection program that you purchased for your
184windows executable may use direct hardware access to write data to the
185disk. Hence, you may need to disable the copy protection in order to
186test your executable under wine.
187
188As a specific example, CrypKey is a copy protection program we use at
189Lumin Software. Our program does not execute under wine with the copy
190protection enabled. We disabled the copy protection, recompiled the
191windows executable, and our program works fine. CrypKey also works for
192Windows NT where it creates a service. Using wine with the --winver
193nt40 option "almost" gets the our program working with copy
194protection. At a later date, we intend to either implement the system
195calls in wine that are missing for CrypKey or to use another copy
196protection program that does work under Linux.
197
198During the execution of your program, wine prints error messages to
199standard error. These error messages include "stubs", which are
200windows API functions that have not been completely
201implemented. Depending on the the system call, these could be harmless
202or crash your program. Most of the common windows API functions have
203already been implemented, so you should have no missing API functions
204or only a few missing functions. If you intend to continue with the
205port to winelib, you will need to implement these API
206functions. After running your program for a while, you should have a
207good feel for the number of windows API functions that you need to
208implement.
209
210It is not necessary for you to implement the entire documented
211behavior of an API function in order to get your program to work. For
212example, many API functions have pointer parameters that are NULL in
213the common cases. If you always call the function with a NULL pointer
214for the default behavior, you can save yourself some effort by
215implementing a function that only works for the NULL pointer
216parameter. If you do this, make sure you test if the parameter is
217non-null and issue a warning for the non-null case. Also document in
218the source that the API function is incomplete.
219
220Once you have implemented an API function, submit the change back to
221the wine project so the next person to need the same function does not
222need to repeat your work. Remember, someone else wrote all of the
223other API functions that you are using, so you are benefiting from
224their work. Let other people benefit from your work as well. If you
225work for a company, you may need your company's permission to "give
226away" your work.
227
228IV. Compiling A Simple Win32 Program
229
230Wine and Winelib are written in C as is the MS Win32/16 API; thus, if
231have a program that calls only the Win32 API directly, you can compile
232the program using a C compiler and link it with some of the
233wine/winelib libraries. For examples of how to do this, see the
234directory libtest/ in the wine source tree.
235
236FIXME: to be continued.
237Describe spec file.
238Go through hello world example 1 and 2.
239
240V. Compiling A Win32 Program With Resources
241
242FIXME: to be continued.
243Describe wrc.
244Go through hello world example 3.
245
246VI. DLLs
247 A. Native DLL.
248 B. so DLL.
249 C. elfdll.
250
251FIXME: to be continued.
252QUESTION: what are so DLL and elfdll. I think I have been doing so
253DLL.
254
255Go over an example similar to edrlib in Petzold.
256
257VII. How to use MFC
258 A. Using a native MFC dll
259 B. Compiling MFC
260
261FIXME: to be continued.
262
263=====================================================================
264The information included here is from various wine-devel posting and
265private e-mails. I am including them so that any one starting on MFC
266will have some documentation. Glean what you can and good luck.
267
268Before I write more detailed info on compiling MFC I have three
269questions. The info I have mentions three problems:
270
271 1. wine header files---what is the status of this? Do changes need
272 to be made in the headers and if so, do I submit the changes back
273 into wine cvs? Do the changes need #ifdef for C vs. C++
274 compilation?
275
276 2. DOS format files <CR/LF> and no case distinction in
277 filenames. Do the extensions Corel made to gcc 2.95 handle this?
278 If so, how?
279
280 3. Microsoft extensions to the C++ syntax. Do the extensions Corel
281 made to gcc 2.95 handle this? If so, how?
282
283If you have info that needs to be added, send me email at
284<wilbur.dale@lumin.nl> and I will add it.
285
286=====================================================================
287
288THANKS
289
290Most of the information in this file came from postings on
291<wine-devel@winehq.com> and from private e-mails. The following people
292contributed information for this document and I thank them for their
293time and effort in answering my questions. I also want to thank them
294for encouraging me to attack the MFC problem.
295
296CONTRIBUTERS:
297
298 Damyan Ognyanoff <Damyan@rocketmail.com>
299 Gavriel State <gav@magmacom.com>
300 Ian Schmidt <ischmidt@cfl.rr.com>
301 Jeremy White <jwhite@codeweavers.com>
302
303
304From: Ian Schmidt <ischmidt@cfl.rr.com>
305Subject: Re: WineLib and MFC
306
307"Wilbur N. Dale" wrote:
308
309> What is the status of MFC under winelib?
310
311I don't know precisely. Corel has done more MFC work than anyone (all
312of their applications which they are porting are MFC-based), and
313reportedly they have MFC itself compiled. I was just trying to get a
314moderately simple MFC-using app to compile, with moderate success
315(there are still some problems with MFC's headers after my patch, but
316at least they don't appear to be Wine's fault :) I did not try to
317compile MFC itself.
318
319> Which versions of MFC, if any?
320
321I have no idea what version Corel uses. As noted in my patch, I was
322fiddling with the headers for MFC 6 (from Visual C++ 6.0 Service Pack
3233). Most of the stuff my patch addressed was for newer IE 5-related
324features, so I'd guess MFC 5 (VC++ 5.0) is likely what they used.
325
326> Is there any documentation on how to compile MFC for winelib? If so
327> where?
328
329Not that I know of.
330
331> I have started to compile programs using winelib (hello.c last
332> Sunday) and expect to be ready to start compiling MFC in a couple of
333> weeks. If documentation is not available on compiling MFC, I am
334> willing to write it.
335
336Documentation would be a Good Thing, as WineLib in general is grossly
337underdocumented right now. Here's a few tips I discovered to get you
338started:
339
340- First off, run all the MFC headers (and source too if you try it)
341through a utility to strip out the DOS carriage returns. They cause
342havoc with GCC when it sees one after a line that ends with a \ (and
343MFC has many macros in it's headers that meet that description). If
344you don't have one, do a Google search on "fromdos" and you should
345locate some source (or it's fairly easy to make your own).
346
347- Use GCC 2.95.2, and the -fpermissive flag to make it less picky.
3482.95.2 has some VC++-compatibility features that Corel paid for, and I
349believe more are forthcoming in future GCCs.
350
351- Use -I to add whereever you have the MFC headers at to your include
352path, as MFC apps typically use #include <> to access them rather than
353"".
354
355- Be prepared to have to rename and/or symlink headers, unless you
356compile on a case-insensitive filesystem :)
357
358- When you make install Wine it seems not to include all it's headers
359in /usr/local/include/wine. To have any chance at getting MFC going
360you'll want to use -I to add the include/ directory from the Wine
361source tarball to the path so it can grab everything.
362
363Sorry I can't help you more, but good luck!
364
365-Ian Schmidt
366ischmidt@cfl.rr.com
367
368
369From: Jeremy White <jwhite@codeweavers.com>
370Subject: Re: RFC: Wine 1.0
371
372"Wilbur N. Dale" wrote:
373> > Further, we have successfully built MFC after making only
374> > a modest set of changes to it, even with older
375> > versions of g++.
376>
377> Lumin Software is about to use winelib to port a window program to linux. A
378> couple of years ago we thought we had to make a modification to MFC for one
379> of our projects and we had problems getting MFC to compile under MS Visual C++.
380> After much wailing and gnashing of teeth, we gave up and did things another
381> way. After this bad experience, we were wondering --- approximately how many
382> man-hours did you spend compiling and changing MFC ?
383
384 Urk. I misspoke. None of the developers here that I thought
385had working versions of MFC with Wine have working versions any
386longer. So, it may be a bit trickier than I led you to believe.
387
388 We have it working pretty reliably with Twine, but not
389quite so cleanly (yet) with Wine. However, it really shouldn't
390be too difficult, and this is what I can remember of the process:
391
392 1. If you use a very modern version of gcc (2.95.2 or higher),
393 I believe you will need to add the -relaxed flag to
394 have any hope of compiling.
395
396 2. If you use an earlier version of gcc, you will need to
397 adjust the many anonymous structs/unions that MFC supplies.
398 We prefer this approach, because requiring very
399 modern gcc implementations seems harsh to us.
400
401 3. You will need to adjust for the many type differences
402 between MFC intrinsic types and the types supplied by Wine.
403 For example, I believe that MFC expects a HANDLE to
404 be compatible with certain scalar types, (and it is
405 under Windows/VC, but is not with Wine/gcc).
406
407 4. The key procedure: add many -DNO_XXX flags to the
408 makefile. If you start with Microsofts make file
409 for MFC, convert it into a Wine makefile, and then turn
410 on many of the flags they list there (of the form -DNO_XXX),
411 your life will get much easier. Once you get it working
412 with a few -DNO_XXX flags, you can go back and add them
413 back in.
414
415 5. The best resource: you need someone who knows C++ very,
416 very well. You occassionaly run into very obscure C++
417 problems where MS has extended the C++ standard and
418 gcc has not. It really helps to have a guru on hand
419 when you hit those.
420
421
422I hope this helps. Sorry for the earlier deceptive post.
423
424Jeremy
425
426From: Gavriel State <gav@magmacom.com>
427Subject: Re: MFC questions
428
429"Wilbur N. Dale" wrote:
430
431> 1. Compile MFC. Several years ago we (Lumin Software) tried to
432> compile MFC. The attempt failed and we found another way to do what
433> we wanted. MS documentation states that compiling MFC was
434> deliberately made difficult. Considering my experience with stuff
435> they call "easy" I am not looking forward to compiling MFC. We are
436> currently using Visual Studio 5 for windows development.
437
438At Corel, we had MFC compiled and running sample apps in WineLib in
439late 1998. It's mostly a question of the Wine headers, which weren't
440originally up to snuff. We did quite a bit of work on them, and most
441of those changes have been contributed back to WineHQ, so it should be
442pretty easy now. The other thing that was a big deal was getting the
443startup code working properly - since MFC needs to initialize static
444data *after* WineLib gets initialized. I believe that that issue has
445been addressed now on the WineHQ side with some of the work done on
446the .spec file tools recently.
447
448-Gav
449
450--
451Gavriel State
452CEO
453TransGaming Technologies Inc.
454gav@transgaming.com
455
456From: Jeremy White <jwhite@codeweavers.com>
457Subject: Re: MFC questions
458
459"Wilbur N. Dale" wrote:
460[snip]
461> 1. Compile MFC. Several years ago we (Lumin Software) tried to
462> compile MFC. The attempt failed and we found another way to do what
463> we wanted. MS documentation states that compiling MFC was
464> deliberately made difficult. Considering my experience with stuff
465> they call "easy" I am not looking forward to compiling MFC. We are
466> currently using Visual Studio 5 for windows development.
467
468Wilbur, I personally think that this is the 'right' approach, although
469approach #2 may prove faster.
470
471Despite your previous experience, and despite my earlier incorrect
472statements, I think that this is simpler than you fear. It's one of
473those tasks that's darkest before the storm - you spend all of your
474energy getting all the include files to work. Once you have *one*
475object file, the rest go much more quickly (alright, getting it to
476link is also a hairball of a job, but it's tractable <g>).
477
478If you're not in a hurry, getting MFC to compile, and having a
479documented procedure for compiling it is on our agenda for the
480relatively near future (see the Wine 1.0 task list).
481
482Jer
483
484p.s. Stick with Visi C++ 5. IMHO its MFC license is cleaner than that
485of VC 6.
486
487From: Gavriel State <gav@magmacom.com>
488Subject: The MSVC++ 6.0 license
489
490Jeremy White wrote:
491> p.s. Stick with Visi C++ 5. IMHO its MFC license is cleaner than that
492> of VC 6.
493
494Actually, I just picked up a copy of MSVC 6.0 and it appears that they
495changed the license between the original release and the Service Pack
4963 release - they removed the bit in section 1.1 about requiring that
497you be developing your software product only for use with a Microsoft
498OS. In any case, even the original license explicitly says that the
499MFC redistribution rights are *in addition* to the usage rights in
500section 1.1.
501
502The relevant portion of the original EULA:
503
504 1.1 General License Grant. Microsoft grants to you as an individual, a
505 personal, nonexclusive license to make and use copies of the SOFTWARE
506 PRODUCT for the sole purposes of designing, developing, and testing your
507 software product(s) that are designed to operate in conjunction with
508 any Microsoft operating system product. [Other unrelated stuff deleted]
509
510>From the SP3 EULA:
511
512 3. Section 1.1 of the EULA is deleted in its entirety and replaced
513 with the following:
514
515 1.1 General License Grant. Microsoft grants to you as an individual, a
516 personal, nonexclusive license to make and use copies of the SOFTWARE
517 PRODUCT for the purpose of designing, developing, and testing your
518 software product(s). [Other unrelated stuff deleted]
519
520Disclaimer - I am not a lawyer, but I've spent lots of time with them
521investigating software licenses.
522
523 -Gav
524
525--
526Gavriel State
527CEO
528TransGaming Technologies Inc.
529gav@transgaming.com
530
531From: Damyan Ognyanoff <Damyan@rocketmail.com>
532Subject: Need a hint
533
534Hi,
535
536I manage to build mfc42 as .so library and a application using it (as
537a .so library too). I execute it using simple loader which is linked
538to wine and I load my application in it's WinMain routine. The
539problem is how clearly to unload mfc and my application (to invoke
540mfc's destructors before loader is terminated) All is fine except that
541there is a "zombi" reference to code in shared library which is
542invoked in wine code and generate GPF. debugger stops somewhere in
543aplication's InitInstance !!! - and the stack is broken so I can't
544catch where exactly the problem is. Any hints are welcome. I'm using
545wine-2000517 shapshot downloaded form wine.datapary.no
546
547TNX.
548
549Damyan
550p.s.
551If any of You is interested in details I can share my
552experience.
553
554
555From: Damyan Ognyanoff <Damyan@rocketmail.com>
556Subject: Re: Wine MFC info request
557
558hi,
559my MFC is from VC6.0 with SP3
560MFC Bulid: (form afxbld_.h)
561 #define _MFC_BUILD 8447
562 #define _MFC_USER_BUILD "8447"
563 #define _MFC_RBLD 0
564mfcdll.rc
565 FILEVERSION 6,0,_MFC_BUILD,_MFC_RBLD
566 PRODUCTVERSION 6,0,0,0
567
568Hints:
569 1. wine include files
570
571In some of them you will find error about '__attribute__' all kinds of
572similar errors can be fixed using proper typedefs first example :
573
574typedef BOOL (CALLBACK *DLGPROC)(HWND,UINT,WPARAM,LPARAM);
575
576must be converted to
577
578typedef BOOL CALLBACK (*DLGPROC)(HWND,UINT,WPARAM,LPARAM);
579
580and the second kind is something like
581
582TYPE* WINAPI SomeFunction(HWND param1,UINT param2);
583
584The problem here is a TYPE* or TYPE& (in some of mfc files) the
585workaround is to declare a type before:
586
587typedef TYPE* TYPEPtr;
588
589or
590
591typedef TYPE& TYPERef;
592
593and declaration will look like:
594
595TYPEPtr WINAPI SomeFunction(HWND param1,UINT param2);
596
597note: don't miss a 'struct' when you define struct type pointers. I
598miss it and get a lot of problems compiling MFC:
599
600>>
601struct _TEB;
602typedef !!!struct!!! _TEB* P_TEB;
603extern inline P_TEB WINAPI NtCurrentTeb(void);
604<<
605
606Those conversions are semanticaly the same as above but g++ compile
607them and generate proper code to invoke __stdcall kind of functions
608
609in some of wine/obj_XXX.h files: wine/obj_base.h - there are a lot of
610defines's that are used to declare a COM interfaces
611
612#define ICOM_METHOD(ret,xfn) \
613 public: virtual ret (CALLBACK xfn)(void) = 0;
614
615will be (for all of them that are related to C++ (watch #ifdef's
616carefully)):
617
618#define ICOM_METHOD(ret,xfn) \
619 public: virtual ret CALLBACK (xfn)(void) = 0;
620
621and the second tip is an error when compiler stops on line like:
622
623 ICOM_DEFINE(ISomeInterfase,IUnknown)
624
625watch method declarations above to find something like:
626
627ICOM_METHOD1(TYPE*,MethodName, DWORD,dwParam)
628
629and replace TYPE* with proper TYPEPtr type. In many cases You will see
630void* which can be replaced simply by LPVOID.
631
632qthere are several errors related to anonymous structs and unions but
633they can be avoided with proper - #ifdef __cplusplus
634
635This is all about wine headers I think. If you find something that I
636miss type a line of mail to me.
637
6382. MFC
639The rules are the same with some new issues:
640
641virtual BOOL Method1(int param1, BOOL (CALLBACK *param2)
642(HWND,UINT,WPARAM,LPARAM));
643
644don't compile. I remove a function pointer declaration
645outside method:
646
647typedef BOOL CALLBACK
648(*param2Type)(HWND,UINT,WPARAM,LPARAM);
649
650virtual BOOL Method1(int param1, param2Type param2);
651
652I didn't apply this technique to a operator new
653definitions:
654
655 void* AFXAPI operator new(size_t nSize);
656
657so i remove AFXAPI from these declarations:
658
659I got some missed #defines from commctrl.h and I added
660them form VC6.0 include.
661
662these are my defines form Makefile which I used to
663compile MFC
664
665-DTWINE_NO_CMONIKER \ -- this is related to exclude
666CMonikerFile
667-D__urlmon_h__ \ -- wine didn't have URL interfaces
668-D_AFX_NO_OLEDB_SUPPORT \
669-D_WIN32 \
670-DNOWIN98 \ -- this is used to exclude all
671unimplemented classes from commctrl
672-D_AFX_PACKING \
673-D_AFX_NO_DHTML_SUPPORT \
674-D_AFX_NO_SOCKET_SUPPORT \
675-D_AFX_NO_SYNC_SUPPORT \
676-D_AFX_NO_OCX_SUPPORT \
677-D_AFX_PORTABLE \
678-D_AFX_OLD_EXCEPTIONS \
679-D_AFX_NO_SOCKET_SUPPORT \
680-D_AFX_NO_DEBUG_CRT \
681-D_AFX_NO_DAO_SUPPORT \
682-D_AFX_NO_OCC_SUPPORT \
683-D_AFX_NO_INET_SUPPORT \
684-D_AFX_NO_RICHEDIT_SUPPORT \
685-D_X86_ \
686-DLONGHANDLES
687
688may be you will try to enable some of features of mfc I tested only
689-D_AFX_NO_OCC_SUPPORT but got missing interfaces from wine
690
691in file afxcom_.h
692- _CIP<_Interface, _IID>::~_CIP<_Interface, _IID>()
693+ _CIP<_Interface, _IID>::~_CIP()
694
695in file afxtempl.h
696- BOOL Lookup(BASE_CLASS::BASE_ARG_KEY key,
697VALUE& rValue) const
698- { return BASE_CLASS::Lookup(key,
699(BASE_CLASS::BASE_VALUE&)rValue); }
700+ BOOL Lookup(typename BASE_CLASS::BASE_ARG_KEY
701key, VALUE& rValue) const
702+ { return BASE_CLASS::Lookup(key,
703(typename BASE_CLASS::BASE_VALUE&)rValue); }
704
705and all releated errors can be fixed in this way.
706
7073. spec file
708 name mfc42
709 type win32
710 rsrc mfc42
711
712 10 stdcall WinMain(long long ptr long) WinMain
713
7144. linking
715 use -rdynamic wnen link libmfc.so to get ARGV and
716ARGC from loader
717
7185. I didn'n build a extention dll with wine but I suspect that there
719will be some problems releated to a chaining Runtime classes form MFC
720to a new dll
721
7226. build your app as a MODULE too.
723
7247. make a loader and in it's _WinMain:
725... includes are here
726iint PASCAL (*winMain)(HINSTANCE,HINSTANCE,LPSTR,int) =
7270;
728my app uses these to manage filenames
729VOID __cdecl (*_splitpath1)(LPCSTR path, LPSTR drive,
730LPSTR directory, LPSTR filename, LPSTR extension ) =
731NULL;
732VOID __cdecl _splitpath(LPCSTR path, LPSTR drive,
733LPSTR directory, LPSTR filename, LPSTR extension )
734{
735 if (_splitpath1)
736 _splitpath1(path, drive, directory, filename,
737extension );
738}
739VOID __cdecl (*_makepath1)(LPSTR path, LPCSTR drive,
740LPCSTR directory, LPCSTR filename, LPCSTR extension )
741= NULL;
742VOID __cdecl _makepath(LPSTR path, LPCSTR drive,
743LPCSTR directory, LPCSTR filename, LPCSTR extension )
744{
745 if (_makepath1)
746 _makepath1(path, drive, directory, filename,
747extension);
748}
749int PASCAL _WinMain(HINSTANCE h,HINSTANCE h1,LPSTR
750lpszCmdParam,int c)
751{
752 HINSTANCE hInstance,hins,hlib,htst,hform,himag,hexe;
753 int retv;
754
755 hins = LoadLibrary("CRTDLL.DLL");
756 _splitpath1 = GetProcAddress(hins,
757"_splitpath");
758 _makepath1 = GetProcAddress(hins,
759"_makepath");
760 hins = LoadLibrary("COMCTL32.DLL");
761 hins = LoadLibrary("COMDLG32.DLL");
762
763
764 hins = dlopen("libmfc42.so",2);
765 hlib = LoadLibrary("mfc42");
766 himag = dlopen("libmxformatslib.so",2);
767 hform = LoadLibrary("mxformatslib");
768 hexe = dlopen("libmxpaint.so",2);
769 htst = LoadLibrary("mxpaint");
770
771 winMain = GetProcAddress(hlib, "WinMain");
772 if (winMain)
773 {
774 retv = winMain (htst, // note the > htst
775< HERE
776 0,
777 lpszCmdParam,
778 SW_NORMAL);
779 }
780 FreeLibrary(htst);
781 FreeLibrary(hform);
782 FreeLibrary(hlib);
783 dlclose(hexe);
784 dlclose(himag);
785 dlclose(hins);
786 return retv;
787}
788the spec for loader is:
789name c10
790mode guiexe
791type win32
792init _WinMain
793
794please find attached a Makefile which i use to build
795MFC
796
797Regards
798Damyan.
799
800 LocalWords: elfdll wrc devel cvs ifdef CR LF Corel gcc Damyan Ognyanoff app
801 LocalWords: Gavriel MFC's Wine's IE VC underdocumented Google fromdos GCCs SP
802 LocalWords: fpermissive whereever apps symlink filesystem tarball RFC linux
803 LocalWords: Urk misspoke structs DNO XXX Microsofts occassionaly WineHQ Gav
804 LocalWords: TransGaming alright hairball Jer Visi IMHO MSVC EULA mfc mfc's rc
805 LocalWords: destructors zombi GPF aplication's InitInstance shapshot TNX RBLD
806 LocalWords: Bulid afxbld mfcdll FILEVERSION PRODUCTVERSION BOOL CALLBACK HWND
807 LocalWords: DLGPROC UINT WPARAM LPARAM WINAPI SomeFunction param TYPEPtr TEB
808 LocalWords: TYPERef struct NtCurrentTeb semanticaly stdcall obj defines's COM
809 LocalWords: ICOM ret xfn ifdef's ISomeInterfase IUnknown MethodName DWORD int
810 LocalWords: dwParam LPVOID qthere cplusplus AFXAPI nSize commctrl DTWINE URL
811 LocalWords: CMONIKER CMonikerFile urlmon AFX OLEDB DNOWIN DHTML SYNC OCX DAO
812 LocalWords: OCC INET RICHEDIT DLONGHANDLES afxcom CIP IID afxtempl ARG rValue
813 LocalWords: const typename releated rsrc ptr rdynamic wnen libmfc ARGV ARGC
814 LocalWords: didn'n extention iint winMain HINSTANCE LPSTR cdecl splitpath SW
815 LocalWords: LPCSTR makepath lpszCmdParam hInstance hins hlib htst hform himag
816 LocalWords: hexe retv LoadLibrary CRTDLL GetProcAddress COMCTL COMDLG dlopen
817 LocalWords: libmxformatslib mxformatslib libmxpaint mxpaint FreeLibrary init
818 LocalWords: dlclose guiexe