首页 | 摘要显示 | 1 2 3 4 5 6 7 8 9 10 11 下一页

Developer Archives

August 22, 2006

解决Linux/Unix下OCI程序动态库版本的问题.

    这段时间做了好几个基础OCI的程序,在Windows上编译后,不需要重新编译, 就可以适应8i/9i/10g的客户端,但在Linux/Unix上,编译好后到不同的版本的客户端去运行时, 总会提示找不到动态库libclntsh.., 这时可以用以下办法去解决:

    第一步,修改genclntsh文件,这个文件在Oracle的bin目录下

#
# Library names and locations
CLNT_NAM=clntsh                      # (short) library name
CLNT_VER=9.0                        # library version number
CLNT_LNK=lib${CLNT_NAM}.so          # name of symlink to library
CLNT_LIB=${CLNT_LNK}.${CLNT_VER}    # actual library file name
LIB_DIR=${ORACLE_HOME}/${LIB}        # lib. destination directory

    改为:

#
# Library names and locations
CLNT_NAM=clntsh                      # (short) library name
CLNT_VER=9.0                        # library version number
CLNT_LIB=lib${CLNT_NAM}.so          # name of symlink to library
CLNT_LNK=${CLNT_LNK}.${CLNT_VER}    # actual library file name
LIB_DIR=${ORACLE_HOME}/${LIB}        # lib. destination directory

    第二步,运行genclntsh重新生成客户端的动态库,这一步不要在正在运行的机器上做.

    第三步,用gcc去编译程序时加上以下选项.

gcc -o ocidemo.bin ocidemo.c -I${ORACLE_HOME}/rdbms/demo -L${ORACLE_HOME}/lib -lclntsh -Wl,-Bdynamic

    第四步,编写一个Shell去执行OCI程序(ocidemo.bin)

阅读全文

用C来读取Solaris上的Load Average的三个值

    OS中的Load Average是很有用的信息,在原先的版本中是没有的,今日增加了这个信息.

......
OS Load: 2.37 2.56 2.56
......

    有了这些信息后,可以使这些工具更具有价值. 源程序来自这儿, 在这儿我也抄了一份.

阅读全文

October 16, 2006

如何去掉rsync 2.6.8对iconv库的调用?

    最近rsync (2.6.5)遇到了几次拷贝大文件(8GB)挂起(发起拷贝命令的程序不肯退出)的情况, 于是在网上找新版本, 在2.6.8版本的Bug修复列表中找到了一些和这个有关的修正(也不确定), 于是下载了源代码来自已编译, 希望可以解决我们遇到的问题.

    在编译过程中, 遇到了iconv包的问题, 在2.6.8中引入了一些新功能(还不清楚), 需要用到字符集转换包(iconv)的库, 我们有很多的机器上都没有装这些包, 因此要去掉对这个包的调用, 让rsync程序拷贝到目标机器就可以运行, 下面是移除的步骤:

    1, 在configure程序中将iconv.h改成iconv1.h

for ac_header in sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h \
  unistd.h utime.h grp.h compat.h sys/param.h ctype.h sys/wait.h \
  sys/ioctl.h sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h \
  sys/un.h glob.h mcheck.h arpa/inet.h arpa/nameser.h locale.h \
  netdb.h malloc.h float.h limits.h iconv1.h libcharset.h langinfo.h

    2, 运行configure命令来配置编译选项

./configure --with-included-popt --with-rsh=/usr/bin/rsh --disable-ipv6 --disable-locale --disable-debug

    3, 编辑Makefile文件, 将下面这一行的"-liconv"去掉

LIBS=-liconv -lsocket -lnsl

    4, 运行make命令来编译rsync可执行文件

    5, 用ldd来检查rsync运行需要的库包

ldd rsync
        libsocket.so.1 =>        /usr/lib/libsocket.so.1
        libnsl.so.1 =>   /usr/lib/libnsl.so.1
        libc.so.1 =>     /usr/lib/libc.so.1
        libdl.so.1 =>    /usr/lib/libdl.so.1
        libmp.so.2 =>    /usr/lib/libmp.so.2
        /usr/platform/SUNW,Sun-Fire-880/lib/libc_psr.so.1

    我在Sun Solaris 5.8下编译成功的.

October 17, 2006

MS VC中如何调用其他DLL中的函数?

    用下面的命令看在oracommon10.dll中有那些函数是可以调用的:

C:\TEMP> dumpbin /EXPORTS oracommon10.dll
   ordinal hint RVA      name

          1    0 000C37C4 DBMSBKRS
          2    1 000012C0 OCITypeCollExtTypeCode
   ......
         65   40 00005FD0 kcbhxoro
   ......

    接下来远择你需要的函数, 比如kcbhxoro函数, 编辑一个oracommon.def文件:

EXPORTS
  kcbhxoro @ 65
  ......

    然后用LIB命令来生成一个oracommon.lib文件, 这个文件在编译时需要用到:

C:\TEMP>LIB /DEF:oracommon.def
Microsoft (R) Library Manager Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

LIB : warning LNK4068: /MACHINE not specified; defaulting to IX86
   Creating library oracommon.lib and object oracommon.exp

    在程序中可以调用kcbhxoro函数了, 当然你要知道函数的参数了, 然后编译程序:

阅读全文

October 18, 2006

修改rsync中TCP Socket的SNDBUF和RCVBUF的大小

    rsync 2.6.8中的"--sockopts"并不能真正起作用, 所以只有自已改了. 在sender.c中加上如下红色部分代码:

if (is_a_socket(f_out))
{
   set_socket_options(f_out, "SO_SNDBUF=524288");
   set_socket_options(f_out, "SO_RCVBUF=524288");
   if (verbose)
   {
     int sndbuf,rcvbuf,len;
     len = sizeof(sndbuf);
     getsockopt(f_out, SOL_SOCKET, SO_SNDBUF,&sndbuf, &len);
     len = sizeof(rcvbuf);
     getsockopt(f_out, SOL_SOCKET, SO_RCVBUF,&rcvbuf, &len);
     rprintf(FINFO, "Sender TCP options : SO_SNDBUF = %d, SO_RCVBUF=%d\n",  sndbuf, rcvbuf);
   }
}

if (!do_xfers) { /* log the transfer */
        if (!am_server && log_format)

    在receiver.c中加上如下红色部分代码:

if (is_a_socket(f_in))
{
   set_socket_options(f_in, "SO_RCVBUF=524288");
    set_socket_options(f_in,"SO_SNDBUF=524288");
   if (verbose)
   {
     int sndbuf,rcvbuf,len;
     len = sizeof(sndbuf);
     getsockopt(f_in, SOL_SOCKET, SO_SNDBUF,&sndbuf, &len);
     len = sizeof(rcvbuf);
     getsockopt(f_in, SOL_SOCKET, SO_RCVBUF,&rcvbuf, &len);
     rprintf(FINFO, "Receiver TCP options : SO_SNDBUF = %d, SO_RCVBUF=%d\n",  sndbuf, rcvbuf);
   }
}
while ((i = recv_token(f_in, &data)) != 0) {

    在rsync.h中将以下两个的值改为256KB:

#define WRITE_SIZE (256*1024)
#define CHUNK_SIZE (256*1024)

    在rsync中用-alvvvv检验更改结果:

阅读全文

1 2 3 4 5 6 7 8 9 10 11 下一页

当前分类: Developer

Creative Commons License
本站版权: 共用创作 CC
署名-非商业性-相同方式分享
本站基于MT-3.36免费版
(©)版权所有, 2004 - 2008, www.AnySQL.net, 保留所有权利.
MSN: loufangxin(a)msn.com, Mail: anysql(at)126.com/support(at)iamdba.com, Skype ID:anysql