ParaView Compiled Statically

Compiling ParaView with static libraries is an exercise in patience. The reason that one would want to compile ParaView statically is so that it can be transferred from one system to another without having to worry about missing libraries. You may need to compile or install GCC, binary utilities such as ar and ld, and have static libraries such as pthread.a. If that is the case, then use the Compiling Static Libraries tutorial. Otherwise it may be skipped.

1. Build Mesa for its offscreen support. Version 6.5.2 was used in this example.

$ gmake -j12 linux-x86-64-static

2. Now, finally, download and install the latest version of ParaView (version 3.2.1 was used in this case).

$ ccmake ../ParaView3.2.1

Press c to have it configure -- that is, to find the location of various libraries, compiler, etc. If ccmake cannot find Qt, it will complain. Simply ignore the complaints and continue.

Change the following variables:

BUILD_SHARED_LIBS               OFF
CMAKE_BUILD_TYPE                Release
CMAKE_INSTALL_PREFIX            /tmp/work/local
PARAVIEW_BUILD_QT_GUI           OFF
VTK_NO_PYTHON_THREADS           ON

Press t to toggle the advanced mode.

BUILD_TESTING                    OFF
PARAVIEW_TESTING_WITH_PYTHON     OFF
VTK_OPENGL_HAS_OSMESA            ON
VTK_USE_DISPLAY                  OFF
VTK_USE_GUISUPPORT               OFF
VTK_USE_QVTK                     OFF

Press c to have it configure.

OPENGL_INCLUDE_DIR               /tmp/work/Mesa-6.5.2/include
OPENGL_gl_LIB                    /tmp/work/Mesa-6.5.2/lib64/libGL.a
OSMESA_INCLUDE_DIR               /tmp/work/Mesa-6.5.2/include
OSMESA_LIBRARY                   /tmp/work/Mesa-6.5.2/lib64/libOSMesa.a
VTK_USE_OFFSCREEN                ON

Press c to have it configure.

Press g to have it generate the makefiles.

$ gmake -j12  $ gmake install

3. Now that you have compiled ParaView, you can see that it is not yet compiled statically. You can use either ldd or nm to see this:

$ ldd bin/pvserver
libhistory.so.4 => /usr/lib64/libhistory.so.4 (0x0000003499100000)
libXt.so.6 => /usr/X11R6/lib64/libXt.so.6 (0x000000349d700000)
libSM.so.6 => /usr/X11R6/lib64/libSM.so.6 (0x000000349ac00000)
libICE.so.6 => /usr/X11R6/lib64/libICE.so.6 (0x000000349ae00000)
libX11.so.6 => /usr/X11R6/lib64/libX11.so.6 (0x000000349a600000)
libXext.so.6 => /usr/X11R6/lib64/libXext.so.6 (0x000000349a800000)
libpthread.so.0 => /lib64/tls/libpthread.so.0 (0x000000349aa00000)
libm.so.6 => /lib64/tls/libm.so.6 (0x000000349a200000)
libdl.so.2 => /lib64/libdl.so.2 (0x000000349a400000)
libc.so.6 => /lib64/tls/libc.so.6 (0x0000003499f00000)
/lib64/ld-linux-x86-64.so.2 (0x0000003498f00000)

A longer version of this can be seen using the command.

$ nm -D bin/pvserver | grep -i " U "

4. To compile ParaView statically you need to use the following command. You will notice that several libraries are repeated several times. This is to take care of any unresolved symbols. Since we are using static linking (and GNU libraries that were designed for dynamic linking), this causes problems. We need to explicitly link against the nss libraries for static linking. The repetition of these libraries is intentional.

$ cd /tmp/work/ParaView/Servers/Executables && /tmp/work/local/bin/g++ -static -UHAVE_PTHREAD_H -DVTK_USE_X=0 -Wno-deprecated -O3 -DNDEBUG -DVTK_USE_X=0 -UHAVE_PTHREAD_H -fPIC /tmp/work/ParaView/Servers/Executables/CMakeFiles/pvserver.dir/pvserver.o -o ../../bin/pvserver -L/tmp/work//local/lib64 -L/tmp/work/local/lib -L/tmp/work/Mesa-6.5.2/lib64 -L/usr/X11R6/lib64 -Wl,-Bstatic -lnss_files -lnss_dns -lresolv -lc -lvtkPVServerCommon -lvtkPVFilters -lvtkPVServerManager -lvtkPVFiltersCS -lvtkPVFilters -lvtkPVServerCommonCS -lvtkPVServerCommon -lvtkInfovisCS -lvtkInfovis -lvtkPVCommandOptions -lvtkParallelCS -lvtkHybridCS -lvtkVolumeRenderingCS -lvtkVolumeRendering -lvtkWidgetsCS -lvtkWidgets -lvtkHybrid -lKWCommon -lvtkXdmfCS -lvtkRenderingCS -lvtkGenericFilteringCS -lvtkGenericFiltering -lvtkGraphicsCS -lvtkImagingCS -lvtkIOCS -lvtkFilteringCS -lvtkCommonCS -lvtkClientServer -lvtkXdmf -lXdmf -lvtkhdf5 -lvtklibxml2 -lhistory -lm -lvtkParallel -lvtkRendering -lvtkGraphics -lverdict -lvtkImaging -lvtkftgl -lvtkfreetype -lGL -lOSMesa -lXt -lSM -lICE -lX11 -lXext -lvtkIO -lvtkFiltering -lvtkCommon -lpthread -lm -lvtkDICOMParser -lvtkmetaio -lvtksqlite -lvtkpng -lvtktiff -lvtkzlib -lvtkjpeg -lvtkexpat -lvtksys -lvtkexoIIc -lvtkNetCDF -lnss_files -lnss_dns -lresolv -lc -lnss_files -lnss_dns -lresolv -lpthread -Wl,-Bdynamic -ldl

Several warnings may appear with this compile line. The warnings will look similar to the following (some of the text of the warning message has been removed for clarity).

warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking   
warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking  
warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking  
warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking  
warning: Using 'gethostbyaddr' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking  
warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking  
warning: Using 'getservbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking  
warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

However, when looking at the symbols, they are included in the binary. These error messages may be safely ignored.

$ nm -a bin/pvserver | grep -i getaddrinfo  
00000000023bf4f0 T getaddrinfo  
0000000000000000 a getaddrinfo.c

ParaView is now compiled statically. This can be seen with the following commands.

$ ldd bin/pvserver
      not a dynamic executable  
$ nm -D bin/pvserver
      nm: bin/pvserver: No symbols

Back to ParaView