[Portaudio] Depricating def for exporting functions to lib/dll.

Alexander Moldenhauer alatnet1 at gmail.com
Sat Nov 17 18:00:38 EST 2018


Modified port audio to be able to compile and export all functions to a dll/lib file.

Have a file named “portaudiodll.h” and have this inside it:
#pragma once
/*
Additional defines added by alatnet
*/
//check which platform we are compiling to.
#if defined(__WIN32__) || defined(_WIN32) || defined(_WIN64)
    #define PA_WIN_PLATFORM
#elif defined(__APPLE__) || defined(__APPLE_CC__)
    #define PA_APPLE_PLATFORM
#elif defined(__GNUC__) && (!(defined(__WIN32__) || defined(_WIN32)) && !(defined(__APPLE__) || defined(__APPLE_CC__)))
    #define PA_NIX_PLATFORM
#else
    #error No Recognized Platform!
#endif

//see if we are using propriotary compilers.
#ifdef _MSC_VER
    #define PA_VISUAL_C
#elif defined(__BORLANDC__)
    #define PA_BORLANDC
#elif defined(__GNUC__) && (defined(__WIN32__) || defined(_WIN32))
    #define PA_MINGW
    #define PA_GNUC
#elif defined(__GNUC__)
    #define PA_GNUC
#endif

//check if we are compiling to 32 or 64 bit.
#if defined(__x86_64__) || defined(_M_X64) || defined(_WIN64)
    #define PA_ARCH_64
#else
    #define PA_ARCH_32
#endif

//see if we are compiling with unicode support.
#if defined(_UNICODE) || defined(UNICODE)
	#define PA_UNICODE
#endif

#if defined(PA_BUILD_DLL) || defined (PA_BUILD_SO) //set exports for building a dynamic library
    #ifdef PA_WIN_PLATFORM
        #if defined(PA_MINGW) || defined(PA_VISUAL_C)
            #define PA_DLL_DECLARE __declspec(dllexport)
            #define PA_DLL_EXTERN extern
            #define PA_DLL_C_EXTERN extern "C"
        #else
            #define PA_DLL_DECLARE __attribute__ ((dllexport))
            #define PA_DLL_EXTERN extern
            #define PA_DLL_C_EXTERN extern "C"
        #endif
    #else
        #ifdef PA_USE_DECLSPEC
            #define PA_DLL_DECLARE __declspec(dllexport)
            #define PA_DLL_EXTERN extern
            #define PA_DLL_C_EXTERN extern "C"
        #else
            #if defined __GNUC__ && __GNUC__ >= 4
                #define PA_DLL_DECLARE __attribute__ ((visibility ("default")))
            #else
                #define PA_DLL_DECLARE __attribute__ ((dllexport))
            #endif
            #define PA_DLL_EXTERN extern
            #define PA_DLL_C_EXTERN extern "C"
        #endif
    #endif
#elif defined (PA_IMPORT_DLL) || defined (PA_IMPORT_SO) //set exports for importing a dynamic library
    #ifdef PA_WIN_PLATFORM
        #if defined(PA_MINGW) || defined(PA_VISUAL_C)
            #define PA_DLL_DECLARE __declspec(dllimport)
            #define PA_DLL_EXTERN
            #define PA_DLL_C_EXTERN
        #else
            #define PA_DLL_DECLARE __attribute__ ((dllimport))
            #define PA_DLL_EXTERN
            #define PA_DLL_C_EXTERN
        #endif
    #else
        #ifdef PA_USE_DECLSPEC
            #define PA_DLL_DECLARE __declspec(dllimport)
            #define PA_DLL_EXTERN
            #define PA_DLL_C_EXTERN
        #else
            #if defined __GNUC__ && __GNUC__ >= 4
                #define PA_DLL_DECLARE __attribute__ ((visibility ("default")))
            #else
                #define PA_DLL_DECLARE __attribute__ ((dllimport))
            #endif
            #define PA_DLL_EXTERN
            #define PA_DLL_C_EXTERN
        #endif
    #endif
#else	//don't set exports, compile to a .lib file
    #define PA_DLL_DECLARE
    #define PA_DLL_EXTERN
    #define PA_DLL_C_EXTERN
#endif

>From there, have each of the function listed in the def file be appended with “PA_DLL_DECLARE” at the beginning of it and enable the “PA_BUILD_DLL” declaration.
There’s also a few extra defines if anyone wants to use it.

Sent from Mail for Windows 10

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.columbia.edu/pipermail/portaudio/attachments/20181117/58f17d2e/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: portaudiodll.h
URL: <https://lists.columbia.edu/pipermail/portaudio/attachments/20181117/58f17d2e/attachment.h>


More information about the Portaudio mailing list