home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / os2 / programm / 8010 < prev    next >
Encoding:
Text File  |  1993-01-25  |  3.5 KB  |  105 lines

  1. Newsgroups: comp.os.os2.programmer
  2. Path: sparky!uunet!brunix!brunix!wcn
  3. From: wcn@cs.brown.edu (Wen-Chun Ni)
  4. Subject: Re: GCC and DLL's
  5. Message-ID: <1993Jan25.194620.14179@cs.brown.edu>
  6. Sender: news@cs.brown.edu
  7. Organization: Brown University Department of Computer Science
  8. References: <1993Jan25.153958.4298@VFL.Paramax.COM>
  9. Date: Mon, 25 Jan 1993 19:46:20 GMT
  10. Lines: 93
  11.  
  12. In article <1993Jan25.153958.4298@VFL.Paramax.COM> rickt@rmtc.paramax.com (Rick Thompson [RMTC/ISP]) writes:
  13. >
  14. >Hello,
  15. >
  16. >I've just obtained GCC from hobbes and was wondering if I can create dll's with
  17. >it?  Regular exe's went fine.  If it is possible can someone send me an example
  18. >make file or whatever you think appropriate?
  19. >
  20. >
  21.  
  22. I asked the question a couple of days before, but nobody replied. I went
  23. ahead and tried it myself. Up to now, almost all testable DLL samples in
  24. the redbook and November PDK are compiled and ran without problems.
  25. Several points should be noted:
  26.  
  27.     * Look at the manual entry of emxomfld in /emx/doc/emxdev.doc.
  28.       Also check the section about how to create a DLL.
  29.     * Compile the program with
  30.         gcc -Zdll -c foo.c
  31.       It is better to add -Zmt to use the run-time DLL.
  32.       Also you may want
  33.         gcc -Zdll -Zomf -c foo.c
  34.        to produce foo.obj, rather than foo.o.
  35.     * If you directly use link386, do remember to include
  36.        /emx/lib/dll0.obj in the object file section.
  37.        libc.lib, libgcc.lib, libemx1.lib, libemx2.lib, and libos2.lib
  38.        are possibly the minimal set of libraries you want to
  39.        load if you use link386.
  40.        A good example is 
  41.         link386 \emx\lib\dll0.obj foo.obj, foo.dll,     \
  42.           $(ALL_THE_LIBS), foo;
  43.        I don't remember those cryptic link386 flags, check it
  44.        yourself.
  45.       * You don't need PDK to get a running DLL but it's recommended.
  46.  
  47. The following is my version of Makefile for pwfolder in the redbooks.
  48. Enjoy it!
  49.  
  50. #****************************************************************************
  51. #  Dot directive definition area (usually just suffixes)
  52. #****************************************************************************
  53.  
  54. .SUFFIXES: .c .o .obj .dll .csc .sc .h .ih .ph .psc .rc .res
  55.  
  56. #****************************************************************************
  57. #  Environment Setup for the component(s).
  58. #****************************************************************************
  59.  
  60.  
  61. #
  62. # Compiler/tools Macros
  63. #
  64.  
  65. CFLAGS     = -O -c -Zdll -Zmt
  66. CC         = gcc 
  67. LINK       = link386
  68. LDFLAGS    = /noi /map /nol /nod /exepack /packcode /packdata /align:16
  69. LIBS       =  libc+libgcc+libemx1+libemx2+libos2
  70.  
  71. #****************************************************************************
  72. # Set up Macros that will contain all the different dependencies for the
  73. # executables and dlls etc. that are generated.
  74. #****************************************************************************
  75.  
  76. OBJS= pwfolder.obj \emx\lib\dll0.obj
  77.  
  78. #****************************************************************************
  79. #   Setup the inference rules for compiling source code to
  80. #   object code.
  81. #****************************************************************************
  82.  
  83. .c.obj:
  84.         $(CC) $(CFLAGS) -c $<
  85.     emxomf $*.o
  86.  
  87. .csc.ih:
  88.     sc $<
  89.  
  90. all: pwfolder.dll
  91.  
  92. pwfolder.obj: $*.c $*.ih $*.h  $*.sc
  93.  
  94. pwfolder.dll: $(OBJS) pwfolder.res
  95.          $(LINK) $(LDFLAGS) $(OBJS),$@,,$(LIBS),$*;
  96.          rc $*.res $*.dll
  97.  
  98. pwfolder.res: pwfolder.rc
  99.          rc -r $*.rc $*.res
  100.  
  101. Wen-Chun Ni, wcn@cs.brown.edu
  102. -------------------------------------------------------------------
  103.   "Great spirits have always encountered violent opposition 
  104.     from mediocre minds..."    -- Albert Einstein
  105.