When using the "lazy linking" link option "-lazy-lz" referenced in this question to delay the loading of a dependent dynamic library, the linker that's part of Xcode 7.2.1 (Apple LLVM version 7.0.2 (clang-700.1.81)), generates this error:
ld: illegal data reference to __ZN9WBRefSpecD1Ev in lazy loaded dylib
...where the mangled C++ symbol refers to the class destructor in my single-class dylib: _WBRefSpec::~WBRefSpec()
I can't find a direct reference anywhere to indicate what this error could possibly mean -- or what could cause it.
In the .cpp file, the destructor is defined:
EXPORT WBRefSpec::~WBRefSpec(void)
{
ClearEntireRefSpec(); // commenting out this call doesn't affect error message!
}
...where EXPORT is the usual:
#define EXPORT __attribute__((visibility("default")))
...and of course, defined in the header file as a public member of the class:
~WBRefSpec(void);
Anyone ever seen this or have a clue what causes this error?
EDIT / ANSWER:
The answer to the illegal data reference was that there WAS a .cpp file with a class member function defined that declared "static WBRefSpec foo;" Removed that, and bingo, no link error.
(removed link details, since they were not relevant to the issue)