Total Pageviews

Saturday, March 5, 2011

Compile Opensees on CentOS

Here is a record of compiling OpenSees in CentOS. I edit my Makefile based on Makefile.def.LINUX_RedHat_ENTERPRISE and then start compiling. I posted my Makefile.def.CentOS in another blog.

First Error is:

/home/GL/OpenSees/SRC/system_of_eqn/linearSOE/sparseGEN/SuperLU.h:78: error: ‘superlu_options_t’ does not name a type
/home/GL/OpenSees/SRC/system_of_eqn/linearSOE/sparseGEN/SuperLU.h:79: error: ‘SuperLUStat_t’ does not name a type
make[2]: *** [commands.o] Error 1
make[2]: Leaving directory `/home/GL/OpenSees/SRC/tcl'
make[1]: *** [tk] Error 2
make[1]: Leaving directory `/home/GL/OpenSees/SRC/modelbuilder/tcl'
make: *** [all] Error 2

After googling, I find SuperLU.h is a old version, change :

SUPERLUdir   = $(HOME)/OpenSees/OTHER/SuperLU
to
SUPERLUdir   = $(HOME)/OpenSees/OTHER/SuperLU_3.0/SRC

Second Error:

cc1plus: warning: -f[no-]force-mem is nop and option will be removed in 4.2
make[2]: Leaving directory `/home/GL/OpenSees/SRC/tcl'
g++: /home/GL/lib/libOpenSees.a: No such file or directory
make[1]: *** [tk] Error 1
make[1]: Leaving directory `/home/GL/OpenSees/SRC/modelbuilder/tcl'
make: *** [all] Error 2

It seems to get stuck at /home/GL/OpenSees/SRC/tcl , so I go to this directory and type make, after making sure all '.o's are generated, I go back to opensees, type make. The error has gone.

Then I get the error about BJtensor.

cc1plus: warning: -f[no-]force-mem is nop and option will be removed in 4.2
BJtensor.cpp: In member function ‘BJtensor BJtensor::operator*(BJtensor&)’:
BJtensor.cpp:1174: error: unable to find a register to spill in class ‘DIREG’
BJtensor.cpp:1174: error: this is the insn:
.......
BJtensor.cpp:1174: confused by earlier errors, bailing out

I googled it and find it has something to do with C++Flags, which I don't know much about it so far.  I change the flag to this:

C++FLAGS        = -Wall -D_LINUX -D_UNIX -D_MYSQL -D_TCL84 $(GRAPHIC_FLAG) $(RELIABILITY_FLAG)\
 $(DEBUG_FLAG) $(PROGRAMMING_FLAG) -O3 -ffloat-store -D_HTTPS

Then I go back to home directory and type make. This time it compiled for a few minutes. After that, the compiler says all libraries are built and it is going to link them. While linking, some errors occur:

/home/GL/OpenSees/SRC/tcl/tkMain.o: In function `Tk_MainOpenSees(int, char**, int (*)(Tcl_Interp*), Tcl_Interp*)':
tkMain.cpp:(.text+0x561): undefined reference to `TkpDisplayWarning'
......tkAppInit.cpp:(.text+0x37): undefined reference to `Tk_Init'

It has something to do with Tk library, since these functions are implemented in Tk. So just add TK library (libtk8.4.so) into this variable:

TCL_LIBRARY  = /usr/local/tcl/lib/libtcl8.4.so
so it is now:
TCL_LIBRARY  = /usr/lib64/libtcl8.4.so /usr/lib64/libtk8.4.so

Another error is:

/home/GL/lib/libOpenSees.a(AMDNumberer.o): In function `AMD::number(Graph&, int)':
AMDNumberer.cpp:(.text+0x37b): undefined reference to `amd_order'

`amd_order' function is implemented in AMD library, which needs to be compiled. Do things below to get rid of this error:

1)add a line:
AMDdir = $(HOME)/OpenSees/OTHER/AMD
2)add  $(AMDdir) to DIRS
3)add a line:
AMD_LIBRARY = $(HOME)/lib/libAMD.a
4) add $(AMD_LIBRARY) to MACHINE_NUMERICAL_LIBS


/home/GL/lib/libOpenSees.a(HTTP.o): In function `httpsSEND_File(char const*, char const*, char const*, char const*, char const*, unsigned int, bool, bool, char**)':
HTTP.cpp:(.text+0x21a): undefined reference to `SSL_library_init'
HTTP.cpp:(.text+0x21f): undefined reference to `SSLv2_client_method'
......
/home/GL/lib/libOpenSees.a(HTTP.o): In function `httpsGET_File(char const*, char const*, char const*, unsigned int, char const*)':
HTTP.cpp:(.text+0x653): undefined reference to `SSL_library_init'
HTTP.cpp:(.text+0x658): undefined reference to `SSLv2_client_method'
......
collect2: ld returned 1 exit status
make[1]: *** [tk] Error 1
make[1]: Leaving directory `/home/GL/OpenSees/SRC/modelbuilder/tcl'
make: *** [all] Error 2

The error above tell us OpenSSL library needs to be linked. By adding -lssl to MACHINE_SPECIFIC_LIBS to get rid of the error. i.e:

MACHINE_SPECIFIC_LIBS = -lssl -ldl  -lieee -lm -lc -lg2c -Wl,-rpath,/usr/local/lib \
/usr/local/mysql/lib/libmysqlclient.a

The above is a brief record of the main compiling process. But there are many other tricky things:

My CentOS do have tcl/tk at 8.4 version. But it does not comtain a tk.h file, very strange... So I download it manually from some website and put it into the TCL_INCLUDES directory. Then the compiler report 'Tk_SafeInit' is not declared... So I edit the tk.h and declare 'Tk_SafeInit', although I have no idea what it is. I just copy the way they declare 'Tk_Init' and change the name. Then it will work.

Another tricky thing is when you use command g++ -l(library) to specify the library you want to link, it can only search for something with the file named *.so, it can not find something like *.so.0.0, so if the library file's name is *.so.0.0, you have to make a link *.so pointing to it. Use the command:
ln -s libraryname.so.0.0 libraryname.so.

No comments:

Post a Comment