Daniel Verkamp
2015-Oct-22 01:38 UTC
[opus] [PATCH] win32: only use dllexport when building DLL
If building a static library, marking symbols as dllexport causes them
to be exported from the final executable. For example, run
objdump -x opus_demo.exe on a --disabled-shared build and look for the
export table; there should not be one in a normal Win32 .exe file, but
when linking static libopus, the exe exports all of the opus_* public
functions.
Use the libtool-defined DLL_EXPORT flag to determine whether we are
building a DLL and only specify __declspec(dllexport) in that case.
---
include/opus_defines.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/opus_defines.h b/include/opus_defines.h
index 10ff838..11b172d 100644
--- a/include/opus_defines.h
+++ b/include/opus_defines.h
@@ -65,7 +65,7 @@ extern "C" {
#ifndef OPUS_EXPORT
# if defined(WIN32)
-# ifdef OPUS_BUILD
+# if defined(OPUS_BUILD) && defined(DLL_EXPORT)
# define OPUS_EXPORT __declspec(dllexport)
# else
# define OPUS_EXPORT
--
2.1.4
On 22.10.2015 4:38, Daniel Verkamp wrote:> If building a static library, marking symbols as dllexport causes them > to be exported from the final executable. For example, run > objdump -x opus_demo.exe on a --disabled-shared build and look for the > export table; there should not be one in a normal Win32 .exe file, but > when linking static libopus, the exe exports all of the opus_* public > functions. > > Use the libtool-defined DLL_EXPORT flag to determine whether we are > building a DLL and only specify __declspec(dllexport) in that case.Works for me (as in "doesn't break anything"; i don't do static builds). -- O< ascii ribbon - stop html email! - www.asciiribbon.org -------------- next part -------------- A non-text attachment was scrubbed... Name: 0x922360B0.asc Type: application/pgp-keys Size: 1702 bytes Desc: not available Url : http://lists.xiph.org/pipermail/opus/attachments/20151022/1a2d90ac/attachment.key -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 473 bytes Desc: OpenPGP digital signature Url : http://lists.xiph.org/pipermail/opus/attachments/20151022/1a2d90ac/attachment.pgp
Daniel Verkamp
2016-Apr-09 22:01 UTC
[opus] [PATCH] win32: only use dllexport when building DLL
On Wed, Oct 21, 2015 at 6:38 PM, Daniel Verkamp <daniel at drv.nu> wrote:> If building a static library, marking symbols as dllexport causes them > to be exported from the final executable. For example, run > objdump -x opus_demo.exe on a --disabled-shared build and look for the > export table; there should not be one in a normal Win32 .exe file, but > when linking static libopus, the exe exports all of the opus_* public > functions. > > Use the libtool-defined DLL_EXPORT flag to determine whether we are > building a DLL and only specify __declspec(dllexport) in that case.Any updates on this patch (attached again just to be sure)? It still applies to the current master branch. Thanks, -- Daniel -------------- next part -------------- A non-text attachment was scrubbed... Name: 0001-win32-only-use-dllexport-when-building-DLL.patch Type: application/octet-stream Size: 1166 bytes Desc: not available Url : http://lists.xiph.org/pipermail/opus/attachments/20160409/0fff1978/attachment.obj
Ralph Giles
2016-Apr-20 17:38 UTC
[opus] [PATCH] win32: only use dllexport when building DLL
Pushed. Thanks for the patch! -r On 09/04/16 03:01 PM, Daniel Verkamp wrote:> On Wed, Oct 21, 2015 at 6:38 PM, Daniel Verkamp <daniel at drv.nu> wrote: >> If building a static library, marking symbols as dllexport causes them >> to be exported from the final executable. For example, run >> objdump -x opus_demo.exe on a --disabled-shared build and look for the >> export table; there should not be one in a normal Win32 .exe file, but >> when linking static libopus, the exe exports all of the opus_* public >> functions. >> >> Use the libtool-defined DLL_EXPORT flag to determine whether we are >> building a DLL and only specify __declspec(dllexport) in that case. > > Any updates on this patch (attached again just to be sure)? > > It still applies to the current master branch. > > Thanks, > -- Daniel > > > > _______________________________________________ > opus mailing list > opus at xiph.org > http://lists.xiph.org/mailman/listinfo/opus >
Possibly Parallel Threads
- [PATCH] win32: only use dllexport when building DLL
- make dllimport/dllexport attributes work with mingw (and others)
- make dllimport/dllexport attributes work with mingw (and others)
- [LLVMdev] Problems linking shared library with __declspec(dllexport)
- [LLVMdev] Feedback required on proper dllexport/import implementation