Visibility Settings

Hi,

On a fresh checkout of v4.13.0, on High Sierra using the system compiler & Ninja, I am getting the following at the end of my build:

[2181/2181] Linking CXX executable bin/itkTestDriver
ld: warning: direct access in function 'itk::ThreadPool::GetGlobalDefaultNumberOfThreads()' from file 'lib/libITKCommon-4.13.a(itkThreadPool.cxx.o)' to global weak symbol 'std::__1::__cxx03_bool::__true_value()' from file 'lib/libitksys-4.13.a(SystemTools.cxx.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'vnl_vector<unsigned short>::read_ascii(std::__1::basic_istream<char, std::__1::char_traits<char> >&)' from file 'lib/libITKVNLInstantiation-4.13.a(vnl_vector+ushort-.cxx.o)' to global weak symbol 'std::__1::__cxx03_bool::__true_value()' from file 'lib/libitksys-4.13.a(SystemTools.cxx.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'vnl_vector<char>::read_ascii(std::__1::basic_istream<char, std::__1::char_traits<char> >&)' from file 'lib/libITKVNLInstantiation-4.13.a(vnl_vector+char-.cxx.o)' to global weak symbol 'std::__1::__cxx03_bool::__true_value()' from file 'lib/libitksys-4.13.a(SystemTools.cxx.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'vnl_vector<double>::read_ascii(std::__1::basic_istream<char, std::__1::char_traits<char> >&)' from file 'lib/libitkvnl-4.13.a(vnl_vector+double-.cxx.o)' to global weak symbol 'std::__1::__cxx03_bool::__true_value()' from file 'lib/libitksys-4.13.a(SystemTools.cxx.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'vnl_vector<float>::read_ascii(std::__1::basic_istream<char, std::__1::char_traits<char> >&)' from file 'lib/libitkvnl-4.13.a(vnl_vector+float-.cxx.o)' to global weak symbol 'std::__1::__cxx03_bool::__true_value()' from file 'lib/libitksys-4.13.a(SystemTools.cxx.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'vnl_vector<int>::read_ascii(std::__1::basic_istream<char, std::__1::char_traits<char> >&)' from file 'lib/libitkvnl-4.13.a(vnl_vector+int-.cxx.o)' to global weak symbol 'std::__1::__cxx03_bool::__true_value()' from file 'lib/libitksys-4.13.a(SystemTools.cxx.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'vnl_vector<long>::read_ascii(std::__1::basic_istream<char, std::__1::char_traits<char> >&)' from file 'lib/libitkvnl-4.13.a(vnl_vector+long-.cxx.o)' to global weak symbol 'std::__1::__cxx03_bool::__true_value()' from file 'lib/libitksys-4.13.a(SystemTools.cxx.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'vnl_vector<long long>::read_ascii(std::__1::basic_istream<char, std::__1::char_traits<char> >&)' from file 'lib/libitkvnl-4.13.a(vnl_vector+longlong-.cxx.o)' to global weak symbol 'std::__1::__cxx03_bool::__true_value()' from file 'lib/libitksys-4.13.a(SystemTools.cxx.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'vnl_vector<unsigned long>::read_ascii(std::__1::basic_istream<char, std::__1::char_traits<char> >&)' from file 'lib/libitkvnl-4.13.a(vnl_vector+ulong-.cxx.o)' to global weak symbol 'std::__1::__cxx03_bool::__true_value()' from file 'lib/libitksys-4.13.a(SystemTools.cxx.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.
ld: warning: direct access in function 'vnl_vector<unsigned long long>::read_ascii(std::__1::basic_istream<char, std::__1::char_traits<char> >&)' from file 'lib/libitkvnl-4.13.a(vnl_vector+ulonglong-.cxx.o)' to global weak symbol 'std::__1::__cxx03_bool::__true_value()' from file 'lib/libitksys-4.13.a(SystemTools.cxx.o)' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

A Google search shows this is probably because the -fvisibility=hidden setting is being set differently for parts of the ITK build. Is this something that I can fix with a CMake setting?

Thanks.

1 Like

A Google search shows this is probably because the -fvisibility=hidden
setting is being set differently for parts of the ITK build. Is this
something that I can fix with a CMake setting?

Those warnings have been on my nightly dashboard submissions too, for months/years in fact, ex:

https://open.cdash.org/viewBuildError.php?type=1&buildid=5223236

Sean

1 Like

That’s interesting. For me, they have only recently started to appear (and in my client programs that link against ITK as well). I’ve been building on Mac for a few years and not seen them before.

These warnings can be misleading and tricky to interpret.

This:

file 'lib/libitksys-4.13.a(SystemTools.cxx.o)'

indicates the visibility specification should be checked in itksys, aka KWSys, SystemTools.

and

global weak symbol 'std::__1::__cxx03_bool::__true_value()'

indicates that the visibility declaration for this function should be checked.

Since project’s using ITK can have their visibility flags to any value when the relevant header files are used, the functions require default visibility on macOS to work in the general case.

Thanks Matt. I actually wrote the below a few days ago, but clearly didn’t press the Reply button. However, Discourse has saved it somehow! Anyway -

This appears to be some kind of odd C++11 issue. I rebuilt ITK with -DCMAKE_CXX_FLAGS=-std=c++11, and these warnings have now disappeared, both when building itkTestDriver and my own programs (which are built with C++11).

@spinicist That’s great to know – thanks for the follow-up!

Then, with ITK 5.0, the issue will be resolved in the default configuration.

@spinicist, I am encountering the same problem. Could you tell me where you added that command? I have tried a few different locations with no success.

Many thanks!

Hello @nklicks, which version of ITK are you building?

I’ve moved onto ITK 5 (in fact I usually stick at HEAD), which requires C++11, so I don’t need to specify this flag anymore. I think I gave that flag during the initial configure, i.e. I ran cmake -GNinja -DCMAKE_CXX_FLAGS=-std=c++11 path/to/itk but my memory is a little hazy. You can also set CMAKE_CXX_FLAGS in ccmake after you have done an initial configure.

2 Likes