This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

readline build questions


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm trying to resolve a bash bug caused by relying on auto-import rather
than __declspec(dllimport): http://cygwin.com/ml/cygwin/2008-11/msg00340.html

I've managed to mark up the readline headers with:

#ifdef READLINE_NO_IMPORT
# ifdef RL_SHARED
#  define RL_IMPORT __declspec(dllexport)
# else
#  define RL_IMPORT
# endif
#else
# define RL_IMPORT __declspec(dllimport)
#endif

then adding RL_IMPORT to every extern declaration, along with appropriate
definitions for READLINE_NO_IMPORT and RL_SHARED in the makefiles that
build the dynamic and static readline libraries.  This appears to solve
the shared library issue, such that bash dynamically linked against this
library does the right thing.  But where I used to be able to link a
single .o both dynamically and statically, I'm now getting failures with
the static link:

make[1]: Entering directory `/home/eblake/readline-5.2.13-11/build/examples'
gcc -g -L../shlib -L..  -o fileman.exe fileman.o ../shlib/cygreadline6.dll
- -lcurses
gcc -g -L../shlib -L..  -o fileman-stat.exe fileman.o ../libreadline.a
- -lcurses
fileman.o:fileman.c:(.text+0x42): undefined reference to
`__imp__rl_readline_name'

Am I still doing something wrong?

I noticed that the ld info pages suggest the following idiom:

    /* Note: auto-export is assumed (no __declspec(dllexport)) */
    #if (defined(_WIN32) || defined(__CYGWIN__)) && \
      !(defined(FOO_BUILD_DLL) || defined(FOO_STATIC))
    #define FOO_IMPORT __declspec(dllimport)
    #else
    #define FOO_IMPORT
    #endif

Is it still possible to allow clients to choose between static and dynamic
readline at link-time without supplying any compile-time flags, or does
the fact that I am conditionally using __declspec mean that I have to
adjust my conditions in readline.h, and that clients that want to link
statically now have to define READLINE_STATIC in their own source?

One other idea I had was to quit distributing a static libreadline.a, and
only offer the dynamic version.  Does anyone see any problems with the
idea of no longer providing a static library?

- --
Don't work too hard, make some time for fun as well!

Eric Blake             ebb9@byu.net
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkkuxggACgkQ84KuGfSFAYAnxQCffLRZh/9i5kqqYfqJSZlub/m1
PzYAn17xac68Ct3+P+uhNdJC2FRCF9aN
=eRkO
-----END PGP SIGNATURE-----


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]