[Insight-developers] The source of the linking errors on gcc 4.0 (-fvisibility)
Bradley Lowekamp
blowekamp at mail.nih.gov
Fri Dec 16 15:07:00 EST 2011
Hello,
I have narrowed down the cause of the linking errors to the addition of GCC feature "-fvisibility=hidden" in the Module/Core/Common/src/CMakeLists.txt file:
if(NOT WIN32 AND CMAKE_COMPILER_IS_GNUCXX AND BUILD_SHARED_LIBS)
set(ITKCommon_CXX_FLAGS "-fvisibility=hidden -fvisibility-inlines-hidden")
ITK_CHECK_CXX_COMPILER_FLAG(${ITKCommon_CXX_FLAGS} ITKCommon_HAS_GCC_VISIBILITY_FLAGS)
if(ITKCommon_HAS_GCC_VISIBILITY_FLAGS)
set_target_properties(ITKCommon PROPERTIES
COMPILE_FLAGS "${ITKCommon_CXX_FLAGS}"
)
endif(ITKCommon_HAS_GCC_VISIBILITY_FLAGS)
endif()
And then in itkDataObject.cxx the following is added, which should specify the correct linkage:
#include "itkSmartPointerForwardReference.hxx"
// Manual instantiation is necessary to prevent link errors
template class ITK_ABI_EXPORT itk::SmartPointerForwardReference< itk::ProcessObject >;
So the like errors are reproducible with gcc4.0 (i686-apple-darwin10-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build 5494)) and SHARED libraries turned on, for the mac.
Luis,
You have a linux box with gcc 4.0.1, I would be quite curious if shared libraries work on that system!
I am digging through gcc documentation now trying to find out the histry of these options and if this was a known bug or something.
If anyone knows something helpful about this issue or has a suggested resolution, please share.
Thanks,
Brad
========================================================
Bradley Lowekamp
Medical Science and Computing for
Office of High Performance Computing and Communications
National Library of Medicine
blowekamp at mail.nih.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20111216/e4cc8cf0/attachment.htm>
More information about the Insight-developers
mailing list