数值计算

星期三, 五月 24, 2006

HP-UX-64.97上的编译链接(1)

64.97上,想写个动态链接库,动态链接,并且自动查找动态链接库:



1、生成动态链接

ld -b -o libcip.so cipcsl2.o cipcsl3.o slope.o cip.o cipcsl4.o +h libcip.so



2、使用

f90 -L/home/math/mathcf/lib -L. -o cip pdedata.o pdedata2d.o main.o calculate.o calculate2d.o init.o init2d.o cip2d.o cipcsl2d.o departpoint2d.o -lcip -lsl -lnr





好象 -L 选项要放在前面,否则就会出错,试了好久 :-《

Makefile写法,在CSDN上

前往

hp-ux多语言链接

HP的参考手册上: (http://docs.hp.com/hpux/onlinedocs/B3909-90014/B3909-90014.html)



32-bit PA-RISC 1.1 code

-L/opt/fortran90/lib/ -lF90 -lisamstub



32-bit PA-RISC 2.0 code

-L/opt/fortran90/lib/pa2.0/ -lF90 -lisamstub



64-bit PA-RISC 2.0 code

-L/opt/fortran90/lib/pa20_64/ -lF90 -lisamstub



还没有试验,等有空试试,然后再说



>man f90

在末端,可以看到,http://www.hp.com/go/hpfortran,然后点 " Documentation

"

同样可以看到aCC的文档:

http://docs.hp.com/hpux/onlinedocs/5076/index.htm

一个较好的.bash_profile文件

在Linux系统下为.bash_profile(/bin/bash),HP-UX下为.profile(/bin/sh):



# .bash_profile



# Get the aliases and functions

if [ -f ~/.bashrc ]; then

. ~/.bashrc

fi



# User specific environment and startup programs



PS1='\u@\h:$PWD> '

PS1='\u@\h>'

alias cp='cp -ipr'

alias mv='mv -i'

alias rm='rm -i'

alias ls='ls -F --color=tty'

alias ll='ls -Flrt --color=tty'



unset USERNAME



# set PATH so it includes user's private bin if it exists

# PATH=~/bin:"${PATH}"

if [ -d ~/bin ] ; then

if [ -z "${PATH}" ] ; then

PATH=~/bin

else

PATH=~/bin:"${PATH}"

fi

export PATH

fi



# do the same with MANPATH

# MANPATH=~/man:"${MANPATH}"

if [ -d ~/man ]; then

if [ -z "${MANPATH}" ] ; then

MANPATH=~/man:$(man -w)

else

MANPATH=~/man:"${MANPATH}"

fi

export MANPATH

fi



# do the same with LD_LIBRARY_PATH

if [ -d ~/lib ]; then

if [ -z "${LD_LIBRARY_PATH}" ]; then

LD_LIBRARY_PATH=~/lib

else

LD_LIBRARY_PATH=~/lib:"${LD_LIBRARY_PATH}"

fi

export LD_LIBRARY_PATH

fi

mkl库LAPACK包的使用

ifort -o sl solve.o -L/opt/intel/mkl/lib/64 -lmkl_lapack -lmkl_itp



由于使用了动态链接,增加了如下命令:

ln -s /opt/intel/mkl/lib/64/libmkl_itp.so ~/lib/libmkl_itp.so

ln -s /opt/intel/mkl/lib/64/libmkl_lapack.so ~/lib/libmkl_lapack.so



~/lib 在环境变量 LD_LIBRARY_PATH 中



搞定 。 :-》



C语言调用LAPACK包:

ln -s /opt/intel/mkl/include ~/include/mkl



#include "mkl/mkl.h"