I am trying to compile Apache Qpid on a Solaris machine, but it failes during linking:
Scanning dependencies of target qpidtypes
[ 0%] Building CXX object src/CMakeFiles/qpidtypes.dir/qpid/types/Exception.cpp.o
[ 0%] Building CXX object src/CMakeFiles/qpidtypes.dir/qpid/types/Uuid.cpp.o
[ 0%] Building CXX object src/CMakeFiles/qpidtypes.dir/qpid/types/Variant.cpp.o
Linking CXX shared library libqpidtypes.so
ld: fatal: unrecognized option '--'
ld: fatal: use the -z help option for usage information
*** Error code 1
The following command caused the error:
cd /export/home/user/qpid-cpp-0.34/build/src && /opt/csw/bin/cmake -E cmake_link_script CMakeFiles/qpidtypes.dir/link.txt --verbose=
make: Fatal error: Command failed for target `src/libqpidtypes.so.1.0.0'
Current working directory /export/home/user/qpid-cpp-0.34/build
*** Error code 1
The command file which is invoked by the -E option is CMakeFiles/qpidtypes.dir/link.txt and it contains:
/usr/bin/gcc -fPIC -fno-visibility-inlines-hidden -fvisibility=hidden -Wl,--version-script=/export/home/user/qpid-cpp-0.34/src/qpid.linkmap -m64 -pthread -shared -Wl,-hlibqpidtypes.so.1 -o libqpidtypes.so.1.0.0 CMakeFiles/qpidtypes.dir/qpid/types/Exception.cpp.o CMakeFiles/qpidtypes.dir/qpid/types/Uuid.cpp.o CMakeFiles/qpidtypes.dir/qpid/types/Variant.cpp.o -L/usr/local/lib -L/usr/lib/mps -luuid -Wl,-R/usr/local/lib:/usr/lib/mps:
The problem seems to be the -Wl,--version-script=/export/home/user/qpid-cpp-0.34/src/qpid.linkmap
This question got around using the option with two dashes, but I don't see how I could do that.
Question: how can I get ld to accept the --version-script information?
Some info on the ld version:
$ gcc -print-prog-name=ld
/usr/ccs/bin/ld
$ /usr/ccs/bin/ld -V
ld: Software Generation Utilities - Solaris Link Editors: 5.10-1.1514
Some info on the gcc version:
Target: sparc-sun-solaris2.10
Configured with: /home/dam/mgar/pkg/gcc4/trunk/work/solaris10-sparc/build-isa-sparcv8plus/gcc-4.9.2/configure --prefix=/opt/csw --exec_prefix=/opt/csw --bindir=/opt/csw/bin --sbindir=/opt/csw/sbin --libexecdir=/opt/csw/libexec --datadir=/opt/csw/share --sysconfdir=/etc/opt/csw --sharedstatedir=/opt/csw/share --localstatedir=/var/opt/csw --libdir=/opt/csw/lib --infodir=/opt/csw/share/info --includedir=/opt/csw/include --mandir=/opt/csw/share/man --enable-cloog-backend=isl --enable-java-awt=xlib --enable-languages=ada,c,c++,fortran,go,java,objc --enable-libada --enable-libssp --enable-nls --enable-objc-gc --enable-threads=posix --program-suffix=-4.9 --with-cloog=/opt/csw --with-gmp=/opt/csw --with-included-gettext --with-ld=/usr/ccs/bin/ld --without-gnu-ld --with-libiconv-prefix=/opt/csw --with-mpfr=/opt/csw --with-ppl=/opt/csw --with-system-zlib=/opt/csw --with-as=/usr/ccs/bin/as --without-gnu-as
Thread model: posix
gcc version 4.9.2 (GCC)
The problem is that the Solaris linker does not recognize many of the options starting with two dashes.
Solaris ld: fatal: unrecognized option '--'
Can be solved by using
ld -z help
and finding the correct replacement.
In my particular case I found a solution in the qpid mailing list, which is not to use --version-script at all:
On SunOs (at least on my machine) this does not work:
/usr/bin/gcc -fPIC -fno-visibility-inlines-hidden -fvisibility=hidden
-Wl,--version-script=/export/home/noname/install/qpid-0.28_tmptest/cpp/src/qpid.linkmap
-shared -Wl,-hlibqpidtypes.so.1 -o libqpidtypes.so.1.0.0 CMakeFiles/qpidtypes.dir/qpid/types/Exception.cpp.o CMakeFiles/qpidtypes.dir/qpid/types/Uuid.cpp.o CMakeFiles/qpidtypes.dir/qpid/types/Variant.cpp.o -L/usr/local/lib -L/usr/lib/mps -luuid -Wl,-R/usr/local/lib:/usr/lib/mps
The problem is:
"-Wl,--version-script=/export/home/noname/install/qpid-0.28_tmptest/cpp/src/qpid.linkmap"So the following needs to be inserted into cpp/src/CMakeLists.txt:
184 if (GCC_VERSION VERSION_EQUAL 4.1.2) 185 message (STATUS "Cannot restrict library symbol export on gcc 4.1.2") 186 set (HIDE_SYMBOL_FLAGS "-fno-visibility-inlines-hidden") 187 else (GCC_VERSION VERSION_EQUAL 4.1.2) 188 set (HIDE_SYMBOL_FLAGS "-fno-visibility-inlines-hidden -fvisibility=hidden") 189 set (QPID_LINKMAP ${CMAKE_CURRENT_SOURCE_DIR}/qpid.linkmap) 190 191 # --------------------- the following three lines need to be inserted for Solaris 192 if (NOT CMAKE_SYSTEM_NAME STREQUAL SunOS) 193 set (LINK_VERSION_SCRIPT_FLAG "-Wl,--version-script=${QPID_LINKMAP}") 194 endif (NOT CMAKE_SYSTEM_NAME STREQUAL SunOS) 195 196
endif (GCC_VERSION VERSION_EQUAL 4.1.2)