Compile time error, thread local variables, llvm, 10.6


#1

I get the following compile error on Mac OS X, deployment target set to 10.5 and using the (default) Apple LLVM 4.2 compiler in Xcode 4.6.2:

ld: targeted OS version does not support use of thread local variables in __ZNK4juce16ThreadLocalValueIPNS_6ThreadEE3getEv for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Thread local variables are controlled using this code in juce_ThreadLocalValue.h:

// (NB: on win32, native thread-locals aren't possible in a dynamically loaded DLL in XP). #if ! ((JUCE_MSVC && (JUCE_64BIT || ! defined (JucePlugin_PluginCode))) \ || (JUCE_MAC && JUCE_CLANG && defined (MAC_OS_X_VERSION_10_7) \ && MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7)) #define JUCE_NO_COMPILER_THREAD_LOCAL 1 #endif
It seems for the above combination this does not correctly set JUCE_NO_COMPILER_THREAD_LOCAL to 1. Not sure how to fix this preprocessor statement correctly but if I force JUCE_NO_COMPILER_THREAD_LOCAL to 1 everything compiles fine.


#2

huh? If you’re really targeting 10.5, then “MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7” must be false (??)


#3

I found the problem. It was my error. In my app the JUCE code lives in a static library. My main project had a deployment target of 10.5 but the static library had a deployment target of 10.8. Once both were set to 10.5 the compile time error went away.