4

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)
Community
  • 1
  • 1
Beginner
  • 5,277
  • 6
  • 34
  • 71
  • The Solaris linker does not know the `--version-script-information` flag. Try to use `-M` instead. – fuz Jul 20 '15 at 17:20

2 Answers2

1

I had the same error message when building openldap version 2.4.39 on solaris 10.

Indeed, double dashes "--", as said in previous answer, is not supported by the linker provided by solaris. But you have to find the option parameter which is used with two dashes whereas is not explicitly mentionned in the error message.

To find the corresponding option, you must look in the link command displayed in the console and look into configure files or in your project configuration files where it is defined.

Particularly for openldap, I used configure files delivered within the library. But the problem was that the linker option rpath was used with two dashes to set the following variable like this:

  • hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'

The problem has been fixed in some aclocal.m4 files (in different folders) and in the libtool script by removing the extra dash.

The library has also been built on linux without modifying any other file.

0

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)

Beginner
  • 5,277
  • 6
  • 34
  • 71
  • Not using it has some downsides (of course), however I found that although the GNU documentation states that the format of the version scripts is equal they really are not. There are apparently some differences that make it easy to introduce incompatibilities, e.g. the GNU variants seems to support `/**/` comments but Solaris does not. – stefanct Mar 08 '16 at 01:09