ltmain.in: Use func_warning for all warnings
[libtool.git] / mail / cygwin32
blobf337a207e5e4d5e5407cbd95955075ad207d9551
1 From ian@cygnus.com Tue Nov  3 23:23 EDT 1998
2 Received: from grande.dcc.unicamp.br (grande.dcc.unicamp.br [143.106.7.8])
3         by amazonas.dcc.unicamp.br (8.8.5/8.8.5) with ESMTP id XAA22373
4         for <oliva@amazonas.dcc.unicamp.br>; Tue, 3 Nov 1998 23:23:22 -0200 (EDT)
5 Received: from tweedledumb.cygnus.com (tweedledumb.cygnus.com [192.80.44.1])
6         by grande.dcc.unicamp.br (8.8.5/8.8.5) with ESMTP id XAA20164
7         for <oliva@dcc.unicamp.br>; Tue, 3 Nov 1998 23:23:18 -0200 (EDT)
8 Received: from subrogation.cygnus.com (subrogation.cygnus.com [192.80.44.76])
9         by tweedledumb.cygnus.com (8.8.5/8.8.5) with ESMTP id UAA13699;
10         Tue, 3 Nov 1998 20:25:28 -0500 (EST)
11 Received: (ian@localhost) by subrogation.cygnus.com (950413.SGI.8.6.12/8.6.4) id UAA01678; Tue, 3 Nov 1998 20:25:28 -0500
12 Date: Tue, 3 Nov 1998 20:25:28 -0500
13 Message-Id: <199811040125.UAA01678@subrogation.cygnus.com>
14 From: Ian Lance Taylor <ian@cygnus.com>
15 To: gvaughan@oranda.demon.co.uk
16 CC: tanner@gmx.de, oliva@dcc.unicamp.br, gord@trick.fig.org,
17         bug-libtool@gnu.org
18 In-reply-to: <363F3F85.2B31574@oranda.demon.co.uk>
19         (gvaughan@oranda.demon.co.uk)
20 Subject: Re: Inter-library dependencies in libtool
21 Content-Type: text
22 X-Content-Length: 3237
23 Xref: araguaia.dcc.unicamp.br libtool-cygwin32:2
24 Lines: 69
25 X-Gnus-Article-Number: 2   Wed Nov  4 01:39:12 1998
27    Date: Tue, 03 Nov 1998 17:38:13 +0000
28    From: "Gary V. Vaughan" <gvaughan@oranda.demon.co.uk>
30    It would seem that the dll code has bitrotted =(O|  Pity.  Ian, do you
31    have time/want to fix this, or do you want to pass the torch on?
33 I no longer have access to a Windows machine, nor do I have all that
34 much interest in the problem, so I'd say that somebody else had better
35 pick up the torch.
37 Incidentally, I believe that DJ Delorie is working on adding DLL
38 support directly to ld, which will mean that dlltool is no longer
39 required, and should make it possible to greatly simplify the win32
40 hacks in dlltool, perhaps even simply using the standard GNU ld code.
42    Shouldn't libtool notice that it is running on cygwin32 and pass the
43    -no-undefined option by itself?  It seems to go against the raison
44    d'etre for libtool to force the Makefile developer to figure this out...
46 This kind of goes to the heart of libtool.  libtool wants to present a
47 particular interface for using shared libraries.  In order to do this,
48 it assumes that the system supports certain capabilities.  One of
49 those is that the system can support undefined symbols in shared
50 libraries.
52 That means that on systems which do not permit shared libraries to
53 have undefined symbols--AIX and Windows--libtool doesn't really work.
55 The --no-undefined option is a hack which tells libtool that the
56 shared library has special characteristics which permit libtool to
57 create a shared library on AIX or Windows, or any other supported
58 platform.
60 I think the general idea is that you should use the --no-undefined
61 option whenever possible.  If you do, you will be able to create
62 shared libraries on AIX and Windows.  If you do not or can not, you
63 will not be able to create them.
65 libtool should not add a --no-undefined option itself.  If it used
66 that option inappropriately, then building the shared library would
67 fail.  Instead, libtool users should always use --no-undefined if they
68 can.
70 Of course, there are problems.  For example, in the GNU binutils, I
71 can arrange matters such that --no-undefined will work on Windows, but
72 to do so I have to link various libraries together and I have to link
73 against special Windows system libraries.  So I do that, which means
74 that I have to change the options I pass to libtool based on the
75 system.
77 In other words, the interface which libtool presents is deficient.  It
78 does not successfully hide the system on which it is running, and it
79 forces the code which calls libtool to make adjustments.
81 I doubt there is any wholly acceptable solution here.  The only
82 workable one I can see would be to effectively enhance Windows and AIX
83 shared libraries such that they support creating shared libraries with
84 undefined symbols.  On Windows, this could be done by doing the link
85 once, checking for undefined symbols, creating little stub routines
86 for those symbols which track down the symbols in some other open DLL,
87 compiling those stubs, and linking them into the DLL.  Perhaps
88 something similar is possible on AIX.
90 Of course even that will not make Windows DLLs identical to ELF shared
91 libraries.  ELF shared libraries permit the main program to override a
92 symbol in the shared library, and Windows DLLs do not.
94 Ian
96 When libtool links DLLs, it strips some command line switches. It's probably
97 the case that this is ok for most situations. However, this potentially breaks
98 Mingw32 support in the Cygwin environment.
100 In order to get Mingw32 support in Cygwin, the compiler must be invoked with
101 the -mno-cygwin switch. If libtool strips this switch out during the link
102 process, the resulting binary will get linked with the wrong import libraries.
104 The following is a small example. I've edited the output a bit for
105 readability. When I send this email, long lines will get broken up, so it
106 still might be a bit difficult to read.
108 -------------------------
110 $ libtool --version
111 ltmain.sh (GNU libtool) 1.3.3 (1.385.2.181 1999/07/02 15:49:11)
114 $ cat xx.c
116 extern __declspec(dllexport) int func(void);
118 int func()
123 $ libtool --mode=compile gcc -mno-cygwin -c xx.c
124 mkdir .libs
125 gcc -mno-cygwin -c  -DPIC xx.c -o .libs/xx.lo
126 mv -f .libs/xx.lo xx.o
127 ln -s xx.o xx.lo
129 $ libtool --mode=link gcc -mno-cygwin -o libxx.la xx.lo \
130         -version-info 0:0:0 -no-undefined -rpath /usr/local/lib
132 rm -fr .libs/libxx.la .libs/libxx.* .libs/libxx.*
134 generating symbol list for `libxx.la'
136 test -f .libs/libxx-0-0-0.dll-ltdll.c || sed -e "/^# \/\* ltdll\.c starts here
137 \*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d <
138 /usr/local/bin/libtool > .libs/libxx-0-0-0.dll-ltdll.c
140  test -f .libs/libxx-0-0-0.dll-ltdll.o || (cd .libs && gcc -c
141 libxx-0-0-0.dll-ltdll.c)
143  dlltool --export-all --exclude-symbols
144 DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --output-def
145 .libs/libxx-0-0-0.dll-def .libs/libxx-0-0-0.dll-ltdll.o  xx.o
147  sed -e "1,/EXPORTS/d" -e "s/ @ [0-9]* ; *//" < .libs/libxx-0-0-0.dll-def >
148 .libs/libxx.exp
150 echo EXPORTS > .libs/libxx-0-0-0.dll-def
152  _lt_hint=1; for symbol in `cat .libs/libxx.exp`; do echo " $symbol @
153 $_lt_hint; " >> .libs/libxx-0-0-0.dll-def; _lt_hint=`expr 1 + $_lt_hint`; done
155  test -f .libs/libxx-0-0-0.dll-ltdll.c || sed -e "/^# \/\* ltdll\.c starts
156 here\*\//,/^# \/\* ltdll.c ends here \*\// { s/^# //; p; }" -e d <
157 /usr/local/bin/libtool > .libs/libxx-0-0-0.dll-ltdll.c
159  test -f .libs/libxx-0-0-0.dll-ltdll.o || (cd .libs && gcc -c
160 libxx-0-0-0.dll-ltdll.c)
163 gcc -Wl,--base-file,.libs/libxx-0-0-0.dll-base -Wl,--dll -nostartfiles -Wl,-e,
164 __cygwin_dll_entry@12 -o .libs/libxx-0-0-0.dll .libs/libxx-0-0-0.dll-ltdll.o
165 xx.o
167  dlltool --as=as --dllname libxx-0-0-0.dll --exclude-symbols
168 DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def
169 .libs/libxx-0-0-0.dll-def --base-file .libs/libxx-0-0-0.dll-base --output-exp
170 .libs/libxx-0-0-0.dll-exp
172  gcc -Wl,--base-file,.libs/libxx-0-0-0.dll-base
173 .libs/libxx-0-0-0.dll-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12
174  -o .libs/libxx-0-0-0.dll .libs/libxx-0-0-0.dll-ltdll.o  xx.o
176  dlltool --as=as --dllname libxx-0-0-0.dll --exclude-symbols
177 DllMain@12,_cygwin_dll_entry@12,_cygwin_noncygwin_dll_entry@12 --def
178 .libs/libxx-0-0-0.dll-def --base-file .libs/libxx-0-0-0.dll-base --output-exp
179 .libs/libxx-0-0-0.dll-exp
181  gcc
182 .libs/libxx-0-0-0.dll-exp -Wl,--dll -nostartfiles -Wl,-e,__cygwin_dll_entry@12
183  -o .libs/libxx-0-0-0.dll .libs/libxx-0-0-0.dll-ltdll.o  xx.o
185 (cd .libs && rm -f libxx.a && ln -s libxx-0-0-0.dll libxx.a)
187 dlltool --as=as --dllname libxx-0-0-0.dll --def
188 .libs/libxx-0-0-0.dll-def --output-lib .libs/libxx.a
190 creating libxx.la
192 (cd .libs && rm -f libxx.la && ln -s ../libxx.la libxx.la)
194 ---------------
196 Notice how the 'gcc' lines do not contain the -mno-cygwin switch. This switch
197 should not get stripped.
199 Jon Leichter
200 jon@symas.com
203 "Gary V. Vaughan" wrote:
205 > On Wed, Aug 30, 2000 at 10:51:36AM -0400, Charles Wilson wrote:
206 > > No, it can't.  Currently, libtool itself doesn't support *building*
207 > > dlls.
209 > Ouch.  Yes it does.  I added support around Christmas 1998, and have
210 > been maintaining it ever since.
212 Thanks for the correction.
215 > Yes it does.  And provided your libraries don't trip over the stupid
216 > dll limitation of "to export a non-function symbol you must edit your
217 > sources", it works easily.  Even if you do export data symbols,
218 > libtool woll build and link against a dll for you (even generating an
219 > import lib along the way).
221 > Unfortunately libtool was developed for Unix and assumes a featureful
222 > shared library architecture, which doesn't map very easily onto win32
223 > dll's.
225 > I will be able to simplify the dll build process a little when DJ's
226 > patches to binutils arrive in a cygwin release (did this happen in
227 > 1.1? I have been so busy with m4 that I only upgraded from b20.1 a few
228 > weeks ago).
230 They landed in binutils-20000625, and were finetuned/tweaked to a fairly
231 stable point by binutils-20000722 (the current version in /latest).
233 Also, there were a few additions that changed ld's default search order
234 for libraries:
235   -Bstatic -lfoo  : 
236     looks for libfoo.a
237   -Bdynamic -lfoo : 
238     looks for libfoo.dll.a (default name for an import lib)
239          then foo.dll.a    (alt. name for an import lib)
240          then libfoo.dll   (link directly to a dll)
241          then foo.dll      (ditto, alt. name)
242      finally, libfoo.a     (fall back to static lib)
244 The spec file for gcc (as of 2.95.2-2) changed so that:
245    gcc -static   calls 'ld -Bstatic'
246    gcc           calls 'ld -Bdynamic'
248 Finally, 'gcc -shared' will build a dll, but you need to pass linker
249 options like '-Wl,--out-implib=libfoo.dll.a' explicitly. 
251 FWIW, all of the (non-libtool) libraries I've dll-ized do not use
252 dlltool at all, and rely only on gcc (and ld, indirectly).
254 --Chuck
257 Want to unsubscribe from this list?
258 Send a message to cygwin-unsubscribe@sourceware.cygnus.com
259 From gary  Tue Oct  3 18:51:55 2000
260 Return-Path: <cygwin-return-16563-gvaughan=oranda.demon.co.uk@sources.redhat.com>
261 Received: from pop3.mail.demon.net
262         by localhost with POP3 (fetchmail-5.3.4)
263         for gary@localhost (single-drop); Tue, 03 Oct 2000 18:51:55 +0100 (BST)
264 Received: from punt-2.mail.demon.net by mailstore
265           for gvaughan@oranda.demon.co.uk id 970581289:20:22249:24;
266           Tue, 03 Oct 2000 13:54:49 GMT
267 Received: from sourceware.cygnus.com ([205.180.83.71]) by punt-2.mail.demon.net
268            id aa2022220; 3 Oct 2000 13:54 GMT
269 Received: (qmail 29977 invoked by alias); 3 Oct 2000 13:52:38 -0000
270 Mailing-List: contact cygwin-help@sourceware.cygnus.com; run by ezmlm
271 Precedence: bulk
272 List-Unsubscribe: <mailto:cygwin-unsubscribe-gvaughan=oranda.demon.co.uk@sources.redhat.com>
273 List-Subscribe: <mailto:cygwin-subscribe@sources.redhat.com>
274 List-Archive: <http://sources.redhat.com/ml/cygwin/>
275 List-Post: <mailto:cygwin@sources.redhat.com>
276 List-Help: <mailto:cygwin-help@sources.redhat.com>, <http://sources.redhat.com/ml/#faqs>
277 Sender: cygwin-owner@sources.redhat.com
278 Delivered-To: mailing list cygwin@sources.redhat.com
279 Received: (qmail 29933 invoked from network); 3 Oct 2000 13:52:34 -0000
280 Received: from mumnunah.cs.mu.oz.au (203.19.244.130)
281   by sourceware.cygnus.com with SMTP; 3 Oct 2000 13:52:34 -0000
282 Received: from murlibobo.cs.mu.OZ.AU (murlibobo.cs.mu.OZ.AU [128.250.29.17]) by mumnunah.cs.mu.OZ.AU with ESMTP
283         id AAA23121; Wed, 4 Oct 2000 00:52:14 +1100 (EST)
284 Received: (from fjh@localhost) by murlibobo.cs.mu.OZ.AU (8.8.5/8.7.3) id AAA11289; Wed, 4 Oct 2000 00:52:13 +1100 (EST)
285 Date: Wed, 4 Oct 2000 00:52:13 +1100
286 From: Fergus Henderson <fjh@cs.mu.oz.au>
287 To: "Gary V. Vaughan" <gvv@techie.com>, cygwin@sources.redhat.com,
288         cgf@cygnus.com
289 Subject: Re: linking against shared libraries
290 Message-ID: <20001004005212.A9274@murlibobo.cs.mu.OZ.AU>
291 References: <012a01c02033$936effc0$f7c723cb@lifelesswks> <20000917010735.G606@demon.co.uk> <20000916234420.A23827@cygnus.com> <20000917122440.I606@demon.co.uk> <20000917122837.A24997@cygnus.com>
292 Mime-Version: 1.0
293 Content-Type: text/plain; charset=us-ascii
294 X-Mailer: Mutt 0.95.1i
295 In-Reply-To: <20000917122837.A24997@cygnus.com>; from Chris Faylor on Sun, Sep 17, 2000 at 12:28:37PM -0400
296 Status: RO
297 Content-Length: 2625
298 Lines: 51
300 On 17-Sep-2000, Chris Faylor <cgf@cygnus.com> wrote:
301 > On Sun, Sep 17, 2000 at 12:24:40PM +0100, Gary V. Vaughan wrote:
302 > >If you are interested, I will add an entry to my TODO list to see if I
303 > >can take some of the nicities from the libtldl LoadLibrary wrapper
304 > >code and apply them to the Cygwin LoadLibrary wrapper?  (Automatic `_'
305 > >prefixing for example).
307 > Is this a characteristic of normal linux/UNIX dlsym?
309 AFAIK, Unix systems that support dlopen() don't prefix C symbol
310 names with `_' when compiling them to assembler in the first place,
311 so the issue is moot.  At least this is the case on Solaris (2.7),
312 Linux (>= libc6), and OSF1 (3.2 ), which are the systems that
313 I have easily available right now.  dlopen() originated on Solaris,
314 according to the Linux man page.
316 On systems such as Cygwin which do prefix C names with `_' when
317 compiling to assembler, whether dlopen() should prefix the name with an
318 underscore depends on whether the name that the user is trying to look
319 up is an assembly name or a C name.  If it's a C name, then it's right
320 for dlopen() to prefix the name with an underscore, to match what the
321 C compiler does, but if it's an assembly name, then doing that would
322 be wrong.  Unfortunately the interface to dlopen() provides the
323 dlopen() implementation with no clues as to which one the user meant.
324 The documentation for dlopen() says that the argument is the "symbol
325 name", which is ambiguous, but could be read as implying that it is
326 supposed to be the assembly name.  However, in practice most uses of
327 dlopen() tend to be passing C names rather than assembler names.
329 Probably most uses of dlopen() are for C names, and so inserting
330 the prefix would work well in most cases.  However, inserting the
331 prefix would also make it impossible to look up assember names that
332 don't start with underscore using dlopen().
334 It's a bit like the issue of text-versus-binary:
335 the original unix-only interface didn't need to distinguish
336 between the different cases (text/binary or C/asm/whatever),
337 but in the Windows environment, you do need to make such
338 distinctions.  So some programs will need source modifications.
339 The best you can do is to choose the default carefully,
340 and make it easy to override the default for programs for which
341 the default is not appropriate.
343 -- 
344 Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
345 WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
346 PGP: finger fjh@128.250.37.3        |     -- the last words of T. S. Garp.
349 Want to unsubscribe from this list?
350 Send a message to cygwin-unsubscribe@sourceware.cygnus.com
352 On Sun, Sep 03, 2000 at 01:34:23AM -0400, Charles Wilson wrote:
353 > "Gary V. Vaughan" wrote:
355 > > > Now, suppose that the png folks release a newer version, say png-2.1.x
356 > > > that exposes some additional features, but is backwards compatible with
357 > > > png-2.0.x.  Great.  You build it, but create:
358 > > >
359 > > >   libpng31.dll.a (embeds the name libpng31.dll.a)
360 > > >   libpng.dll.a -> libpng31.dll.a
361 > > >   libpng3.dll (replaces the old version (*))
362 > > 
363 > > I don't think we need anything more than
364 > > 
365 > >     a replacement libpng3.dll
367 > Not so.  Remember, libpng-2.1.x can include additional functions that
368 > were not included by libpng-2.0.x, as long as it includes all of the
369 > 'old' functions/vars without modification.  So, you need to update the
370 > import lib as well as the dll, so that new packages that use the
371 > additional functions will work.
373 Oops.  I hadn't thought of that.  Good point.
375 > > Otherwise we are still in violent agreement.
377 > I agree.
379 =)O|
381 > > > > Maybe Cygwin should put all of it's libtool built libraries (or any
382 > > > > others that are correctly versioned w.r.t the runtime loader) into a
383 > > > > single directory that is near the front of the default path.  /usr/lib
384 > > > > seems like a good place.
385 > > >
386 > > > That's part of my 'easy' solution above.  It may fix the cygwin problem,
387 > > > but the requirement is not nice to native apps or other unix-on-win
388 > > > emulations that the user may have.
389 > > >
390 > > > Relying on 'get dll's from same dir as .exe' works -- but only if EVERY
391 > > > cygwin exe and EVERY cygwin dll are piled into the same dir.
392 > > 
393 > > Can't we assume that the native dll's we rely on are outside cygwin's
394 > > control and can be relied upon to be managed by the operating system
395 > > (I'm thinking of stuff in the SYSTEM directory), and that non-cygwin
396 > > libraries (such as Pauls pw dlls) will not be installed into the
397 > > cygwin binary search path?  In which case I think it is okay to
398 > > install all cygwin dlls and import libs to /usr/lib, making sure that
399 > > cygwin.bat (or any other cygwin startup methods) put /usr/lib first in
400 > > $PATH.  
402 > this works for the 'sandbox user' -- Michael Ring's 'user 1' in this
403 > message:
404 >    http://sources.redhat.com/ml/cygwin/2000-08/msg01241.html
406 > It doesn't work for Michael's 'user 2' -- the guy who normally runs in
407 > cmd.exe/command.com, but relies on cygwin commands every once in a
408 > while.  He doesn't use bash, but likes the cygwin-perl or grep every
409 > once and a while.  User 2 will have the cygwin directories somewhere in
410 > her path -- but not necessarily first.
412 We could tell these people to put C:/cygwin/usr/bin at the front of
413 their PATH...
415 > > Does cygwin ld use -rpath yet?  
417 > I don't think so.  -rpath is something that ld.so uses; Windows doesn't
418 > have ld.so. Windows *always* loads dll's according to the following
419 > search order:
420 >    current directory
421 >    app's load directory
422 >    global executable search path
424 > The only two exceptions I know of are:
426 >   1) In Win2K, if there is a file called 'app.exe.local' in the same
427 > directory as app.exe, then all dll's will be loaded from the app's load
428 > directory -- even if explicitly dlopened() with an absolute path that
429 > points elsewhere.  the .local. may also override the 'current directory'
430 > part of the search order listed above, but I'm not sure.
432 Holy cr@p! What happened to simplicity?  If Bill has decided that he
433 can't understand how to write a decent shared library system, and
434 want's to relegate dll's to LoadLibrary() objects, why doesn't he just
435 say so?  Wouldn't it be easier to statically link a Win2k program that
436 twiddle about with all this .local mess?
438 >   2) You can put something called 'AppPath' in the registry, which will
439 > influence the directories that are searched. I don't know where in the
440 > list above that the directories listed in the 'AppPath' key are
441 > inserted.
443 This sounds promising.  I'll see if I can find any details on it.
445 > > I am prepared to work on having libtool do the right thing as far
446 > > as possible. 
448 > What was the right thing, again?  :-)
450 Based on our conversation so far:
452   * When building a libtool (.la) library, create libfoo.la,
453     libfoo<iface>.dll, libfoo.dll.a and libfoo.a, where:
454       - <iface> is the earliest fully supported interface number
455       - libfoo.dll.a is the import library for libfoo<iface>.dll
456       
457   * When installing a libtool (.la) library:
458       - libfoo.la goes to $prefix/lib
459       - libfoo<iface>.dll goes to $prefix/bin
460       - libfoo.dll.a goes to $prefix/lib
461       - libfoo.a goes to $prefix/lib
462       
463   * When linking against libfoo.la
464       - use libfoo.dll.a unless -static or -all-static 
465       - otherwise use libfoo.a
467   * When linking against -lfoo
468       - if libfoo.la is found, behave as above
469       - else let ld (or gcc) do its thing
471 Which is especially cool, because I don't think I need to worry about
472 dealing with direct linkage to dlls (I can just punt and let gcc/ld do
473 the hard work) which removes a whole pile of spaghetti where I had to
474 cope with compiling the impgen code correctly in cross compilation
475 environments!
477 > > By default libtool always searches for a dll to link against and
478 > > generates the implib on the fly if a suitable one is found.
480 This won't be necessary under the new scheme =)O|
482 > There are occaisions where you want to link to an import lib in
483 > preference to a dll -- for instance, libcygwin.a is an import lib, but
484 > contains initializer code and actual function implementations for some
485 > functions that are not included in the dll itself.  If you attempt to
486 > link directly to cygwin1.dll, the link fails because those things are
487 > missing from the virtual on-the-fly implib.
489 I didn't know about that.  Thanks.
491 > But where do you put the dll?  It has to go into the executable PATH so
492 > that the windows loader can find it.  Do you copy it into /usr/lib, so
493 > that the default ld search path will find it?  Do you add /usr/bin to
494 > the linktime library search path (-L/usr/bin)?  Perhaps a symlink in
495 > /usr/lib, pointing to /usr/bin/libfoo.dll is all you need. 
497 > However!!! Ld uses the following library name search order when hunting
498 > for -lfoo:
500 >   libfoo.dll.a
501 >   foo.dll.a
502 >   libfoo.a  <<<< NOTE!!
503 >   libfoo.dll
504 >   foo.dll
506 Or that.  Thanks again!  Libtool already provides --disable-static if
507 the user wants to build and install only the dll parts of the library.
509 For this to work (that is, in order for me to be able to punt to gcc/ld
510 in the majority of cases) I must generate dll names that will be
511 found, so the cygfoo.dll idea is out (Sorry Paul!).
513 Although this doesn't help ``User 2'' very much, he is no worse off
514 than before if I change libtool's behaviour in this way.  Here's a
515 thought:  For each dll using application linked, I could have libtool
516 install a .bat script to C:/cygwin/launch (or similar) which would set
517 the PATH environment correctly for that application.  As long as
518 ``User 2'' has the launch directory higher in his PATH than the actual
519 binary directory, this would guarantee correct dll selection.
521 This would give ``User 1'' many of the advantages shared libraries
522 offer on Unix, without sinking into DLL Hell.  Assuming that everyone
523 buys into it.  The only reason shared libraries work properly on Unix
524 is that everyone has to agree to conform to the runtime loader's
525 versioning scheme -- so don't give some excuse about ``if we don't
526 want to change the core cygwin dll's to conform this won't work''.  On
527 my linux box, I can move my libc around or drop several incompatible
528 versions of libc into my filesystem, and my applications will stop
529 loading the intended libraries too.  No surprises there!
531 Cheers,
532         Gary.
533 -- 
534   ___              _   ___   __              _         mailto: gvv@techie.com
535  / __|__ _ _ ___ _| | / / | / /_ _ _  _ __ _| |_  __ _ ___       gary@gnu.org 
536 | (_ / _` | '_|// / |/ /| |/ / _` | || / _` | ' \/ _` | _ \
537  \___\__,_|_|\_, /|___(_)___/\__,_|\_,_\__, |_||_\__,_|//_/
538 home page:  /___/                      /___/                  gpg public key:
539 http://www.oranda.demon.co.uk           http://www.oranda.demon.co.uk/key.asc
542 Want to unsubscribe from this list?
543 Send a message to cygwin-unsubscribe@sourceware.cygnus.com
544 On Sun, Sep 03, 2000 at 04:39:51PM -0300, Alexandre Oliva wrote:
545 > On Sep  3, 2000, "Gary V. Vaughan" <gvv@techie.com> wrote:
547 > >   * When installing a libtool (.la) library:
548 > >       - libfoo.la goes to $prefix/lib
549 > >       - libfoo<iface>.dll goes to $prefix/bin
550 > >       - libfoo.dll.a goes to $prefix/lib
551 > >       - libfoo.a goes to $prefix/lib
552 >       
553 > Nope.  libfoo.la goes wherever -rpath specified when the library was
554 > created; it should be the same directory that is specified at install
555 > time.  This is often $(libdir), but it doesn't have to be.
557 > I don't know how to arrange for an additional directory (bindir) to
558 > be specifiable without introducing an additional command-line option.
559 > Remember, libtool doesn't know about prefix, libdir or bindir, it just
560 > knows about what it's given in the command line.
562 Hmm.  I hadn't thought of that.  Still, at least the principle of the
563 thing is right now, I think...
565 Cheers,
566         Gary.
567 -- 
568   ___              _   ___   __              _         mailto: gvv@techie.com
569  / __|__ _ _ ___ _| | / / | / /_ _ _  _ __ _| |_  __ _ ___       gary@gnu.org 
570 | (_ / _` | '_|// / |/ /| |/ / _` | || / _` | ' \/ _` | _ \
571  \___\__,_|_|\_, /|___(_)___/\__,_|\_,_\__, |_||_\__,_|//_/
572 home page:  /___/                      /___/                  gpg public key:
573 http://www.oranda.demon.co.uk           http://www.oranda.demon.co.uk/key.asc
575 There's an easier way -- one command!  'gcc -shared' will create a dll
576 for you.  Just do:
578 $(BASE)=foo
580   gcc -shared -o cyg$(BASE).dll -Wl,--out-implib=lib$(BASE).dll.a \
581     -Wl,--export-all -Wl,--enable-auto-image-base \
582     -Wl,--output-def=cyg$(BASE).def $(OBJS)
584 Grab any of the packages in the 'contrib' directory and look an the
585 makefiles (you might need to do a minimal 'configure' first, to
586 customize the Makefile for cygwin before using it as a model)
588 --Chuck
590 Jrgen Schuck wrote:
592 > I'm not sure about the kind of object that 'gcc -shared'
593 > produces. But I think it won't be what you might expect.
594 > In Windows shared sobjects are DLL's. You probably will
595 > have to convert your Makefiles to cproduce DLL's instead
596 > of UNIX-style .so files.
598 > I did the same task when porting a TCL-extension from
599 > UNIX to Cygwin. The Makefile (SVR4) changes from
601 > libTclDM20.so:
602 >         ld -G -o $@ $(OBJS)
604 > to
606 > LOAD      = TclDM20
607 > DEF       = $(LOAD).def
608 > BAS       = $(LOAD).base
609 > EXP       = $(LOAD).exp
610 > $(DLL): $(OBJS)
611 >         echo EXPORTS >$(DEF)
612 >         nm $+ | grep '^........ [T] _' | sed 's/[^_]*_//' >>$(DEF)
613 >         $(LD) --base-file $(BAS) -dll -o $@ $+ -e _dll_entry@12 \
614 >                                 -L`dirname \`gcc -print-file-name=libgcc.a\`` \
615 >                                 $(LIBS) -lgcc -lcygwin -lkernel32 -lgcc
616 >         dlltool --as=as -dllname $@ --def $(DEF) \
617 >                                         --base-file $(BAS) --output-exp $(EXP)
618 >         $(LD) --base-file $(BAS) $(EXP) -dll -o $@ $+ -e _dll_entry@12 \
619 >                                 -L`dirname \`gcc -print-file-name=libgcc.a\`` \
620 >                                 $(LIBS) -lgcc -lcygwin -lkernel32 -lgcc
621 >         dlltool --as=as -dllname $@ --def $(DEF) \
622 >                                         --base-file $(BAS) --output-exp $(EXP)
623 >         $(LD) $(EXP) -dll -o $@ $+ -e _dll_entry@12 \
624 >                                 -L`dirname \`gcc -print-file-name=libgcc.a\`` \
625 >                                 $(LIBS) -lgcc -lcygwin -lkernel32 -lgcc
627 > For further information see
628 > http://sources.redhat.com/cygwin/docs.html,
629 > section "Writing DLLs". Reading these docs you
630 > will find two further modules: dll_init.c and
631 > dll_fixup.c. I didn't put them into my DLL because
632 > the resulting DLL crashes the TCL-interpreter.
634 > Furthermore I found it very helpful to take a
635 > look into the Makefiles of the DLL-generating
636 > packages of the Cygwin-distribution: tcl, wish
637 > and tix.
639 > Jrgen Schuck
640 > PCM-Kundenbetreuung
641 > Business Unit Information
642 > _________________________________________________
643 > MATERNA GmbH Information & Communications
644 > Vosskuhle 37 * 44141 Dortmund
645 > Tel.: 0231 - 5599 - 191 *  Fax: -272
646 > Handy: 0172 - 23 70 148  * http://www.materna.de
648 > --
649 > Want to unsubscribe from this list?
650 > Send a message to cygwin-unsubscribe@sourceware.cygnus.com
653 Want to unsubscribe from this list?
654 Send a message to cygwin-unsubscribe@sourceware.cygnus.com
655 From gary  Tue Oct 10 18:50:22 2000
656 Return-Path: <cygwin-return-16847-gvaughan=oranda.demon.co.uk@sources.redhat.com>
657 Received: from pop3.mail.demon.net
658         by localhost with POP3 (fetchmail-5.3.4)
659         for gary@localhost (single-drop); Tue, 10 Oct 2000 18:50:22 +0100 (BST)
660 Received: from punt-2.mail.demon.net by mailstore
661           for gvaughan@oranda.demon.co.uk id 971135226:20:06380:2;
662           Mon, 09 Oct 2000 23:47:06 GMT
663 Received: from sourceware.cygnus.com ([205.180.83.71]) by punt-2.mail.demon.net
664            id aa2005552; 9 Oct 2000 23:46 GMT
665 Received: (qmail 16236 invoked by alias); 9 Oct 2000 23:46:45 -0000
666 Mailing-List: contact cygwin-help@sourceware.cygnus.com; run by ezmlm
667 Precedence: bulk
668 List-Unsubscribe: <mailto:cygwin-unsubscribe-gvaughan=oranda.demon.co.uk@sources.redhat.com>
669 List-Subscribe: <mailto:cygwin-subscribe@sources.redhat.com>
670 List-Archive: <http://sources.redhat.com/ml/cygwin/>
671 List-Post: <mailto:cygwin@sources.redhat.com>
672 List-Help: <mailto:cygwin-help@sources.redhat.com>, <http://sources.redhat.com/ml/#faqs>
673 Sender: cygwin-owner@sources.redhat.com
674 Delivered-To: mailing list cygwin@sources.redhat.com
675 Received: (qmail 16211 invoked from network); 9 Oct 2000 23:46:43 -0000
676 Received: from mail.ee.gatech.edu (130.207.230.10)
677   by sourceware.cygnus.com with SMTP; 9 Oct 2000 23:46:43 -0000
678 Received: from ece.gatech.edu (s02-pm03.gatech.campuscwix.net [168.14.1.69])
679         by mail.ee.gatech.edu (8.11.0/8.11.0) with ESMTP id e99NkTO15440;
680         Mon, 9 Oct 2000 19:46:30 -0400 (EDT)
681 Message-ID: <39E259A7.CBAD325F@ece.gatech.edu>
682 Date: Mon, 09 Oct 2000 19:49:59 -0400
683 From: Charles Wilson <cwilson@ece.gatech.edu>
684 X-Mailer: Mozilla 4.75 [en] (Windows NT 5.0; U)
685 X-Accept-Language: en
686 MIME-Version: 1.0
687 To: cygwin@sourceware.cygnus.com
688 Subject: Re: AW: Linking Dynamic Libraries
689 References: <004501c031f0$10478ad0$0d33028b@zapperlot.materna.de> <39E1CC08.F475851F@ece.gatech.edu> <39E2468B.BFDD3AB7@ihug.co.nz>
690 Content-Type: text/plain; charset=us-ascii
691 Content-Transfer-Encoding: 7bit
692 Status: RO
693 Content-Length: 5252
694 Lines: 189
696 You still need to worry about things like __declspec(dllexport) and
697 __declspec(dllimport).  Here's a patch for your files.  
699 (Yes, you are correct; the option is '--export-all-symbols' not
700 '--export-all')
702 As far as documentation, there's the mailing list, and 'ld --help' and
703 Mumit's (really out-of-date) dll-helpers packaqe at
704 http://www.xraylith.wisc.edu/~khan/software/gnu-win32/dllhelpers.html. 
705 Would you like to update that package for the current capabilities of
706 ld/gcc ?  Mumit's tutorial is heavily 'dlltool' based, rather than 'gcc
707 -shared' or 'ld' based.
709 NOTE 1: I had to remove "-Wl,--export-all-symbols" from the options;
710 with export-all I got a stack dump even with my other changes. I'm not
711 sure why.
713 NOTE 2: I used the extension '.dll.a' for the import library; cygwin's
714 linker will search for 'libfoo.dll.a' in preference to 'libfoo.a';
715 libfoo.a is assumed to be a static library (although the linker will use
716 libfoo.a if .dll.a is not found)
718 --Chuck
721 diff -u demo-orig/Makefile demo/Makefile
722 --- demo-orig/Makefile  Mon Oct  9 19:34:15 2000
723 +++ demo/Makefile       Mon Oct  9 19:45:10 2000
724 @@ -3,7 +3,7 @@
725  EXENAME = demo
726  EXEOBJ = demo.o
727  CPLUS = g++ -W -Wall -Werror
728 -LINKDLL = g++ -shared -Wl,--export-all -Wl,--enable-auto-image-base
729 +LINKDLL = g++ -shared -Wl,--enable-auto-image-base
730  LINKEXE = g++ -L.
732  .DELETE_ON_ERROR:
733 @@ -13,13 +13,16 @@
734  all: $(DLLNAME).dll $(EXENAME)
736  clean:
737 -       rm -f $(DLLOBJ) $(DLLNAME).dll lib$(DLLNAME).a $(EXEOBJ)
738 $(EXENAME).exe
739 +       rm -f $(DLLOBJ) $(DLLNAME).dll lib$(DLLNAME).dll.a $(EXEOBJ)
740 $(EXENAME).exe
742  %.o: %.cpp
743         $(CPLUS) -c $< -o $@
745 +$(DLLOBJ): $(DLLOBJ:.o=.cpp)
746 +       $(CPLUS) -DBUILD_DLL -c $< -o $@
748  $(DLLNAME).dll: $(DLLOBJ)
749 -       $(LINKDLL) $(DLLOBJ) -o $(DLLNAME).dll
750 -Wl,--out-implib=lib$(DLLNAME).a
751 +       $(LINKDLL) $(DLLOBJ) -o $(DLLNAME).dll
752 -Wl,--out-implib=lib$(DLLNAME).dll.a
754  $(EXENAME): $(EXEOBJ) $(DLLNAME).dll
755         $(LINKEXE) $(EXEOBJ) -l$(DLLNAME) -o $(EXENAME)
756 diff -u demo-orig/foo.hpp demo/foo.hpp
757 --- demo-orig/foo.hpp   Mon Oct  9 19:35:58 2000
758 +++ demo/foo.hpp        Mon Oct  9 19:35:50 2000
759 @@ -3,7 +3,12 @@
761  #include <string>
763 -extern std::string global_mangle(const std::string& source);
765 +#ifdef BUILD_DLL
766 +#define FOO_EXPORT __declspec(dllexport)
767 +#else
768 +#define FOO_EXPORT __declspec(dllimport)
769  #endif
771 +extern FOO_EXPORT std::string global_mangle(const std::string& source);
773 +#endif
775 Ross Smith wrote:
777 > "Charles S. Wilson" wrote:
778 > >
779 > > There's an easier way -- one command!  'gcc -shared' will create a dll
780 > > for you.  Just do:
781 > >
782 > > $(BASE)=foo
783 > >
784 > >   gcc -shared -o cyg$(BASE).dll -Wl,--out-implib=lib$(BASE).dll.a \
785 > >     -Wl,--export-all -Wl,--enable-auto-image-base \
786 > >     -Wl,--output-def=cyg$(BASE).def $(OBJS)
788 > I can't get this to work. Whenever I link with the import lib produced
789 > this way, the resulting program crashes with a STATUS_ACCESS_VIOLATION.
790 > (See attached code.) I don't even need to call any of the DLL functions
791 > to trigger it -- just linking with -lfoo makes it unworkable. What am I
792 > doing wrong?
794 > And where is all this stuff documented anyway? The ld docs mention
795 > --export-all-symbols (not --export-all), but not any of the others.
797 > -------------------- cut here --------------------
799 > // demo.cpp
801 > #include "foo.hpp"
802 > #include <iostream>
803 > #include <string>
805 > int main() {
806 >   std::string thing("thing");
807 >   std::cout << thing << std::endl;
808 > //  std::cout << global_mangle(thing) << std::endl;
809 >   return 0;
810 > }
812 > -------------------- cut here --------------------
814 > // foo.hpp
816 > #ifndef FOO_HEADER
817 > #define FOO_HEADER
819 > #include <string>
821 > extern std::string global_mangle(const std::string& source);
823 > #endif
825 > -------------------- cut here --------------------
827 > // foo.cpp
829 > #include "foo.hpp"
831 > std::string global_mangle(const std::string& source) {
832 >   return source + "_global";
833 > }
835 > -------------------- cut here --------------------
837 > // Makefile
839 > DLLNAME = foo
840 > DLLOBJ = foo.o
841 > EXENAME = demo
842 > EXEOBJ = demo.o
843 > CPLUS = g++ -W -Wall -Werror
844 > LINKDLL = g++ -shared -Wl,--export-all -Wl,--enable-auto-image-base
845 > LINKEXE = g++ -L.
847 > .DELETE_ON_ERROR:
849 > .PHONY: all clean
851 > all: $(DLLNAME).dll $(EXENAME)
853 > clean:
854 >     rm -f $(DLLOBJ) $(DLLNAME).dll lib$(DLLNAME).a $(EXEOBJ)
855 > $(EXENAME).exe
857 > %.o: %.cpp
858 >     $(CPLUS) -c $< -o $@
860 > $(DLLNAME).dll: $(DLLOBJ)
861 >     $(LINKDLL) $(DLLOBJ) -o $(DLLNAME).dll
862 > -Wl,--out-implib=lib$(DLLNAME).a
864 > $(EXENAME): $(EXEOBJ) $(DLLNAME).dll
865 >     $(LINKEXE) $(EXEOBJ) -l$(DLLNAME) -o $(EXENAME)
867 > demo.o: demo.cpp foo.hpp
868 > foo.o: foo.cpp foo.hpp
870 > -------------------- cut here --------------------
872 > --
873 > Ross Smith <ross.s@ihug.co.nz> The Internet Group, Auckland, New Zealand
874 > ========================================================================
875 > "C++ is to programming as sex is to reproduction. Better ways might
876 > technically exist but they're not nearly as much fun." -- Nikolai Irgens
878 > --
879 > Want to unsubscribe from this list?
880 > Send a message to cygwin-unsubscribe@sourceware.cygnus.com
883 Want to unsubscribe from this list?
884 Send a message to cygwin-unsubscribe@sourceware.cygnus.com
886 From gary  Wed Oct 11 18:38:50 2000
887 Return-Path: <cygwin-return-16974-gvaughan=oranda.demon.co.uk@sources.redhat.com>
888 Received: from pop3.mail.demon.net
889         by localhost with POP3 (fetchmail-5.3.4)
890         for gary@localhost (single-drop); Wed, 11 Oct 2000 18:38:50 +0100 (BST)
891 Received: from punt-1.mail.demon.net by mailstore
892           for gvaughan@oranda.demon.co.uk id 971256552:10:18423:4;
893           Wed, 11 Oct 2000 09:29:12 GMT
894 Received: from sourceware.cygnus.com ([205.180.83.71]) by punt-1.mail.demon.net
895            id aa1018296; 11 Oct 2000 9:29 GMT
896 Received: (qmail 10937 invoked by alias); 11 Oct 2000 09:28:33 -0000
897 Mailing-List: contact cygwin-help@sourceware.cygnus.com; run by ezmlm
898 Precedence: bulk
899 List-Unsubscribe: <mailto:cygwin-unsubscribe-gvaughan=oranda.demon.co.uk@sources.redhat.com>
900 List-Subscribe: <mailto:cygwin-subscribe@sources.redhat.com>
901 List-Archive: <http://sources.redhat.com/ml/cygwin/>
902 List-Post: <mailto:cygwin@sources.redhat.com>
903 List-Help: <mailto:cygwin-help@sources.redhat.com>, <http://sources.redhat.com/ml/#faqs>
904 Sender: cygwin-owner@sources.redhat.com
905 Delivered-To: mailing list cygwin@sources.redhat.com
906 Received: (qmail 10909 invoked from network); 11 Oct 2000 09:28:30 -0000
907 Received: from web6405.mail.yahoo.com (128.11.22.153)
908   by sourceware.cygnus.com with SMTP; 11 Oct 2000 09:28:30 -0000
909 Message-ID: <20001011092829.19377.qmail@web6405.mail.yahoo.com>
910 Received: from [203.97.2.247] by web6405.mail.yahoo.com; Wed, 11 Oct 2000 22:28:29 NZDT
911 Date: Wed, 11 Oct 2000 22:28:29 +1300 (NZDT)
912 From: =?iso-8859-1?q?Danny=20Smith?= <danny_r_smith_2001@yahoo.co.nz>
913 Subject: Re: AW: Linking Dynamic Libraries
914 To: cygwin@sources.redhat.com
915 MIME-Version: 1.0
916 Content-Type: text/plain; charset=iso-8859-1
917 Content-Transfer-Encoding: 8bit
918 Status: RO
919 Content-Length: 1133
920 Lines: 38
922 Ross Smith wrote:
924 > Charles Wilson wrote:
925 > >
926 > > You still need to worry about things like __declspec(dllexport) and
927 > > __declspec(dllimport).
929 > What's the point of --export-all-symbols then? I was under the
930 > impression that it was intended to duplicate the Unix convention,
931 where
932 > all external symbols are automatically exported from a .so.
933 (Actually,
934 > the help refers to "global" symbols, not "external", but I assumed
935 that
936 > just meant that whoever wrote the help didn't know C++.)
939 If you really want to --export-all in C++, this is a workaround.
940 Create a def with dlltool:
941  dlltool --export-all --output-def foo_.def --dllname foo.dll *.o
943 Then look at the def file.  Do you still really want to export-all?
945 To use that def file with ld -shared you need to get rid of the
946 comments (demangled names) 
947 cut does the job:
948   cut -d ';' -f 1 foo_.def >foo.def
950 Cheers
953 _____________________________________________________________________________
954 http://clubs.yahoo.com.au - Yahoo! Clubs
955 - Join a club or build your own!
958 Want to unsubscribe from this list?
959 Send a message to cygwin-unsubscribe@sourceware.cygnus.com