Aug 302012
 

2015-06-16 更新:
这里讲的方法可能已经不管用了,至少在我使用Solaris 10 的VirtualBox Image的时候,下面的方法行不通。

Install Solaris 10 and install R under Solaris
最近的写的一个R package vcf2geno不能在Solaris 10 下编译。
为了解决这个问题,我决定重复CRAN上Solaris 10的测试环境
下面写个流水账

1.安装Virtual Box
下载,安装。

2.安装Solaris 10 和 Guest OS
一定要注意的是手动分区,把/tmp的容量设置到5G以上。不然默认的/tmp只有512M,这样就不方便安装Solaris Studio (第3步)。
安装virtualBox的Guest OS 软件后,Solaris的屏幕分辨率增加。

3.安装Solaris Studio 12.3
下载,解压,安装 (就是特别慢)

4.安装OpenSolaris
Solaris里面没有ubuntu的apt和fedora的yum,但是有个类似的软件叫做OpenCSW Link.
参考OpenCSW的手册Getting Start.
然后用pkgutil安装tetex, gcc4g++, iconv, readline

5.下载R
去R的主页下载源代码,然后解压

6.配置环境参数,安装

export CC=suncc
export CFLAGS="-xO5 -xc99 -xlibmil -nofstore"
export CPICFLAGS=-Kpic
export F77=sunf95
export FFLAGS="-O5 -libmil -nofstore"
export FPICFLAGS=-Kpic
export CXX="sunCC -library=stlport4"
export CXXFLAGS="-xO5 -xlibmil -nofstore -features=tmplrefstatic"
export CXXPICFLAGS=-Kpic
export FC=sunf95
export FCFLAGS=$FFLAGS
export FCPICFLAGS=-Kpic
export LDFLAGS=-L/opt/sunstudio12.1/rtlibs/amd64
export SHLIB_LDFLAGS=-shared
export SHLIB_CXXLDFLAGS=-G
export SHLIB_FCLDFLAGS=-G
export SAFE_FFLAGS="-O5 -libmil"

export CPPFLAGS=’-I/opt/csw/include -I/opt/csw/include/readline’
export LDFLAGS=’-L/opt/sunstudio12.1/rtlibs/amd64 -L/opt/csw/lib’

export PATH=/usr/xpg4/bin:$PATH
export PATH=/usr/sfw/bin/:$PATH

之后我们依次执行:
./configure
gmake #(Solaris下面的GNU make)
gmake install

经验:

    Solaris下自带的软件很少,常用软件要到OpenCSW下载
    Solaris的路径设置和Linux很不同,不在/usr/bin, /usr/local/bin等等。这时候可以用glocate来快速查找, 见【2】

主要参考:
【1】http://cran.r-project.org/doc/manuals/R-admin.html#Solaris
【2】Solaris下的locate工具. Link
【3】http://www.opencsw.org/get-it/packages/

Aug 282012
 

查看gcc build-in specs

gcc -dumpspecs
-dumpspecs
Print the compiler's built-in specs---and don't do anything else. (This is used when GCC itself is being built.)

看gcc到哪些目录查找头文件:

gcc -print-search-dirs
-print-search-dirs
Print the name of the configured installation directory and a list of program and library directories gcc will search---and don't do anything else.

This is useful when gcc prints the error message installation problem, cannot exec cpp0: No such file or directory. To resolve this you either need to put cpp0 and the other compiler components where gcc expects to find them, or you can set the environment variable
GCC_EXEC_PREFIX to the directory where you installed them. Don't forget the trailing /.

看gcc编译到那个平台

gcc -Q -v
-Q Makes the compiler print out each function name as it is compiled, and print some statistics about each pass when it finishes.
zhanxw@host10-41.sph.umich.edu: ~/temp> gcc -Q -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin10/4.7.1/lto-wrapper
Target: x86_64-apple-darwin10
Configured with: ../gcc-4.7.1/configure --prefix=/opt/local --build=x86_64-apple-darwin10 --enable-languages=c,c++,objc,obj-c++,lto,fortran,java --libdir=/opt/local/lib/gcc47 --includedir=/opt/local/include/gcc47 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-4.7 --with-libiconv-prefix=/opt/local --with-local-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.7 --with-gxx-include-dir=/opt/local/include/gcc47/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-ppl=/opt/local --with-cloog=/opt/local --enable-cloog-backend=isl --enable-stage1-checking --disable-multilib --enable-lto --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --disable-ppl-version-check --with-pkgversion='MacPorts gcc47 4.7.1_2'
Thread model: posix
gcc version 4.7.1 (MacPorts gcc47 4.7.1_2)

看gcc默认开启了哪些FLAG(定义了哪些macro)

$cpp -dM <(echo "") #define __DBL_MIN_EXP__ (-1021) #define __FLT_MIN__ 1.17549435e-38F #define __DEC64_DEN__ 0.000000000000001E-383DD #define __CHAR_BIT__ 8 #define __WCHAR_MAX__ 2147483647 #define __DBL_DENORM_MIN__ 4.9406564584124654e-324 #define __FLT_EVAL_METHOD__ 0 #define __DBL_MIN_10_EXP__ (-307) #define __FINITE_MATH_ONLY__ 0 #define __DEC64_MAX_EXP__ 384 ... ...

和MacPorts 相关的——如何选择gcc

sudo port select --list gcc
sudo port select --set gcc gcc42 # default gcc in Mac Snow Leopard
sudo port select --set gcc mp-gcc47 # MacPorts GNU GCC 4.7

和平台相关的Macro定义:

其他参考
【1】StackOverflow上的讨论:哪个macro可以区分Mac和Linux Link
【2】SourceForge上Pre-defined C/C++ Compiler Macros,包括以下方面:
Standards
Compilers
Libraries
Operating Systems
Architectures
Devices
Link