易截截图软件、单文件、免安装、纯绿色、仅160KB

用php的c扩展编程调用 c程序的动态链接库


一.    首先做一个简单的so文件:
    /**
     * hello.c
     * To compile, use following commands:
     *   gcc -O -c -fPIC -o hello.o hello.c
     *   gcc -shared -o libhello.so hello.o
     */
    int hello_add(int a, int b)
    {
        return a + b;
    }
    然后将它编译成.so文件并放到系统中:
    $ gcc -O -c -fPIC -o hello.o hello.c
    $ gcc -shared -o libhello.so hello.o
    $ su
    # echo /usr/local/lib > /etc/ld.so.conf.d/local.conf
    # cp libhello.so /usr/local/lib
    # /sbin/ldconfig
二.    写段小程序来验证其正确性:
    /**
     * hellotest.c
     * To compile, use following commands:
     *   gcc -o hellotest -lhello hellotest.c
     */
    #include <stdio.h>
    int main()
    {
        int a = 3, b = 4;
        printf("%d + %d = %d\n", a, b, hello_add(a,b));
        return 0;
    }
    编译并执行:
    $ gcc -o hellotest -lhello hellotest.c
    $ ./hellotest
    3 + 4 = 7
三.
    然后通过下面的命令建立一个名为 hello 的模块。
    $ ./ext_skel --extname=hello
    执行该命令之后它会提示你应当用什么命令来编译模块,可惜那是将模块集成到php内部的编译方法。如果要编译成可动态加载的 php_hello.so,方法要更为简单。
    $ cd hello
    首先编辑 config.m4 文件,去掉第16行和第18行


相关文档:

[转]C/C++资源大汇总(很好很强大)

1.开发工具下载
TUBER C                     http://www.duote.com/soft/392.html
Turbo C 2.0 汉化版             http://www.programfan.com/showdown.asp?id=306
C-Free 4.0             http:/ ......

c/c++读写文件

#include<stdlib.h>
#include<iostream>
#include<string.h>
using namespace std;
int main(void)
{
FILE *fp, *fp2;
char buf[1024*300];
fp = fopen("in.txt", "rb");
fp2 = fopen("out.txt", "wb+");
fseek(fp, 0, SEEK_END);
int iLen ......

linux 0.11 内核学习 main.c,调用函数而已。

到了main.c,其实main.c中的大部分的内容是调用函数来实现初始化的工作,但是还是将它看完了。下面就是代码了。主要参考的是linux内核完全注释,在一些不太明白的地方,参考网上的介绍。废话少说。还有很长的路啊。努力啊O(∩_∩)O~。
/*
 * main.c功能描述。
 */
//main.c程序的主要功能是利用setup.s ......

linux 下php的安装

    
环境软件版本介绍:
 
   APACHE 2.0.59
   PHP5.2.3
   MYSQL5.0.45
   GD-2.0.35
   Zend Optimizer v3.3.0
  
               &n ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号