How to compile shared Xyce

66 views
Skip to first unread message

Murat Eskiyerli

unread,
Jun 14, 2020, 3:10:15 PM6/14/20
to xyce-users
Hello,

I am trying to compile Xyce with  shared-enabled in serial mode. I use the following options for configure after "./bootstrap".

./configure --prefix=/usr \
    --enable-shared \
    --enable-xyce-shareable \
    CXXFLAGS="-O3  -std=c++11 -fPIC  -fno-var-tracking" \
    CFLAGS="-O3 -fPIC -fno-var-tracking"

However, the linking fails with the following message. I suspect that I might be doing something wrong in the compiler options. Any ideas what could it be?
  CXX      Xyce.o
  CCLD     libxyce.la
/usr/bin/ld: /lib/libloca.a(LOCA_Abstract_Group.C.o): relocation R_X86_64_PC32 against symbol `_ZTIN4LOCA8Abstract5GroupE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status

Regards,

xyce-users

unread,
Jun 14, 2020, 3:20:46 PM6/14/20
to xyce-users

Yes, this means your Trilinos was not compiled with PIC options.

Our building guide's example Trilinos CMake invocation does add these options and should have produced a Trilinos usable with a shared library build. 
In that example script, by adding "-fPIC" to the FLAGS variable and then using the FLAGS variable in all the CMake compiler flags options, we get a library that supports linkage into shared objects.  Here's what that looks like:


Example "reconfigure" script (cmake invocation):


#!/bin/sh
SRCDIR
=$HOME/Trilinos12.12/Trilinos-trilinos-release-12-12-1
ARCHDIR
=$HOME/XyceLibs/Serial
FLAGS
="-O3 -fPIC"
cmake
\
-G "Unix Makefiles" \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_Fortran_COMPILER=gfortran \
-DCMAKE_CXX_FLAGS="$FLAGS" \
-DCMAKE_C_FLAGS="$FLAGS" \
-DCMAKE_Fortran_FLAGS="$FLAGS" \
-DCMAKE_INSTALL_PREFIX=$ARCHDIR \
-DCMAKE_MAKE_PROGRAM="make" \
-DTrilinos_ENABLE_NOX=ON \
 
-DNOX_ENABLE_LOCA=ON \
-DTrilinos_ENABLE_EpetraExt=ON \
 
-DEpetraExt_BUILD_BTF=ON \
 
-DEpetraExt_BUILD_EXPERIMENTAL=ON \
 
-DEpetraExt_BUILD_GRAPH_REORDERINGS=ON \
-DTrilinos_ENABLE_TrilinosCouplings=ON \
-DTrilinos_ENABLE_Ifpack=ON \
-DTrilinos_ENABLE_Isorropia=ON \
-DTrilinos_ENABLE_AztecOO=ON \
-DTrilinos_ENABLE_Belos=ON \
-DTrilinos_ENABLE_Teuchos=ON \
 
-DTeuchos_ENABLE_COMPLEX=ON \
-DTrilinos_ENABLE_Amesos=ON \
 
-DAmesos_ENABLE_KLU=ON \
-DTrilinos_ENABLE_Sacado=ON \
-DTrilinos_ENABLE_Kokkos=OFF \
-DTrilinos_ENABLE_ALL_OPTIONAL_PACKAGES=OFF \
-DTrilinos_ENABLE_CXX11=ON \
-DTPL_ENABLE_AMD=ON \
-DAMD_LIBRARY_DIRS="/usr/lib" \
-DTPL_AMD_INCLUDE_DIRS="/usr/include/suitesparse" \
-DTPL_ENABLE_BLAS=ON \
-DTPL_ENABLE_LAPACK=ON \
$SRCDIR

If you didn't do something like this, you probably need to rebuild Trilinos taking care to force "-fPIC" into all the compile options.  If you DID do something like this, then something went wrong.  Post your Trilinos configuration process and maybe we can spot it.

The above example CMake invocation for Trilinos often needs customization for your system , but if you got Trilinos built before, rebuilding it with the -fPIC options shouldn't really be a difficult task.

xyce-users

unread,
Jun 14, 2020, 3:23:19 PM6/14/20
to xyce-users
Oh, and you do NOT need to add "-fPIC" to the Xyce configure invocation --- libtool takes care of putting that into the compiler flags for you as soon as you select "--enable-shared".  The problem is that it was not in the compiler flags when you built Trilinos for whatever reason.  Once you rebuild Trilinos with -fPIC, you can reconfigure Xyce without explicitly adding that option to Xyce's flags.

Murat Eskiyerli

unread,
Jun 15, 2020, 10:29:15 AM6/15/20
to xyce-users
Thanks. This solved the problem. I also compiled Xyce-7.1 the same way. It coughed at some point at ADMS folder but it finished fine when I went through make process again.
Reply all
Reply to author
Forward
0 new messages