Csound Csound-dev Csound-tekno Search About

[CSOUND-DEV:3797] Re: Csound GNU build system lessons learned

Date2003-12-17 22:40
From"Michael Gogins"
Subject[CSOUND-DEV:3797] Re: Csound GNU build system lessons learned
I think that's correct. I never had to use __declspec(dllimport) however; I
think that is only required for importing entire classes or data variables -
not for dealing with just functions, as I do.

============================================
Michael Gogins
gogins at pipeline period com
Irreducible Productions
CsoundVST, an extended version of Csound for programming music and sound
Available at http://sourceforge.net/projects/csound/
============================================


----- Original Message ----- 
From: "John D. Ramsdell" 
To: "Csound Developers Discussion List" 
Sent: Wednesday, December 17, 2003 12:50 PM
Subject: [CSOUND-DEV:3791] Re: Csound GNU build system lessons learned


> "Michael Gogins"  writes:
>
> > Pardon me if you already know this, as I suspect you do, and I'm missing
the
> > point of your question...
>
> Actually, I don't have a good question for you at this time, as I can
> build a DLL that links with -lwinmm in a small test case, but doing
> the "same thing" with Csound causes a linking failure.  Why the linker
> can find the DLL in the test case, but not with Csound is still a
> mystery, but I will continue to look for an explanation.
>
> I did a lot of reading of info files on Cygwin.  My conclusion is that
> the automake file in the directory used to build libcsound should
> define BUILDING_LIBCSOUND when compiling files used to build
> libcsound, and csound.h should start with:
>
> #if defined HAVE_CONFIG_H && (defined _WIN32 || defined __CYGWIN__)
> #  if !defined PIC
> #    define PUBLIC
> #  elif defined BUILDING_LIBCSOUND
> #    define PUBLIC __declspec(dllexport)
> #  else
> #    define PUBLIC __declspec(dllimport)
> #  endif
> #  define LIBRARY_CALL WINAPI
> #elif defined WIN32
> #define PUBLIC __declspec(dllexport)
> #define LIBRARY_CALL WINAPI
> #else
> #define PUBLIC
> #define LIBRARY_CALL
> #endif
>
> This way, PUBLIC has an empty definition when used with static
> libraries or programs, is defined to be __declspec(dllexport) when
> compiling libcsound as a DLL, and is defined to be
> __declspec(dllimport) when using libcsound within another library
> being compiled as a DLL.
>
> By the way, what is LIBRARY_CALL used for?  I don't see it in any
> source code.
>
> John
>
> [ramsdell@couch csound]$ sfcvs csound diff -u
> ramsdell@cvs.csound.sourceforge.net's password:
> Index: csound/Makefile.am
> ===================================================================
> RCS file: /cvsroot/csound/csound/csound/Makefile.am,v
> retrieving revision 1.13
> diff -u -r1.13 Makefile.am
> --- csound/Makefile.am 15 Dec 2003 11:08:49 -0000 1.13
> +++ csound/Makefile.am 17 Dec 2003 15:34:08 -0000
> @@ -87,7 +87,9 @@
>  winFLTK.c FL_graph.cpp widgets.cpp wincwin.c winBe.c winSGI.c winwat.c \
>  winbor.c windin.h cwin.cpp cwin.h
>
> -libcsound_la_CFLAGS = -DXMGDIR=\"$(pkgdatadir)\" -DUSE_CSOUND_YIELD
> +libcsound_la_CFLAGS = -DXMGDIR=\"$(pkgdatadir)\" -DUSE_CSOUND_YIELD \
> +-DBUILDING_LIBCSOUND
> +libcsound_la_CXXFLAGS = $(AM_CXXFLAGS) -DBUILDING_LIBCSOUND
>  libcsound_la_LDFLAGS = -version-info 0:0:0 -no-undefined
>  libcsound_la_LIBADD = $(AUDOBJS) $(winobjs) $(AUDLIBS)
>  libcsound_la_DEPENDENCIES = $(AUDOBJS) $(winobjs)
> Index: csound/csound.h
> ===================================================================
> RCS file: /cvsroot/csound/csound/csound/csound.h,v
> retrieving revision 1.1
> diff -u -r1.1 csound.h
> --- csound/csound.h 29 Nov 2003 18:33:20 -0000 1.1
> +++ csound/csound.h 17 Dec 2003 15:34:08 -0000
> @@ -33,7 +33,16 @@
>          /*
>          * Platform-dependent definitions and declarations.
>          */
> -#ifdef WIN32
> +#if defined HAVE_CONFIG_H && (defined _WIN32 || defined __CYGWIN__)
> +#  if !defined PIC
> +#    define PUBLIC
> +#  elif defined BUILDING_LIBCSOUND
> +#    define PUBLIC __declspec(dllexport)
> +#  else
> +#    define PUBLIC __declspec(dllimport)
> +#  endif
> +#  define LIBRARY_CALL WINAPI
> +#elif defined WIN32
>  #define PUBLIC __declspec(dllexport)
>  #define LIBRARY_CALL WINAPI
>  #else
>