#67 Fix CPPUNIT_PLUGIN_EXPORT for Linux/Mac OS X

open
nobody
5
2011-07-27
2011-07-27
No

Generally I try to build shared libraries (.so, .dylib) on Linux/Mac OS X with -fvisibility=hidden (or -fvisibility-ms-compat) and add attributes to the public API symbols to export them explicitly.

Building CppUnit test plug-ins on Linux/Mac OS X with -fvisibility=hidden doesn't work because cppunitTestPlugIn isn't exported.

CppUnit already declares this symbol using CPPUNIT_PLUGIN_EXPORT, and uses __declspec(dllexport) to ensure it's exported on Windows.
All that's needed to make this work on Linux/Mac is to #define CPPUNIT_PLUGIN_EXPORT extern "C" __attribute__ ((visibility("default"))) on those platforms.

I attach a diff that makes this work for me, against SelectDllLoader.h from cppunit-1.12.1.

Thanks,
Gareth

Discussion