易截截图软件、单文件、免安装、纯绿色、仅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写的3D迷宫

          Boss说,要看OpenGL,看了快一个月,总算出了个像样的东西,用C写了个3D迷宫,
虽然只有350行
       代码,不过边学边写,足足写了一周时间,还是小有成就感的,活活活!
         &n ......

JNI 调用C/C++

JNI调用可以加快JAVA的运行速度,主要是将关键的代码用C/C++ 或者mfc完成,在这里贴上我写的一段代码,有兴趣的可以参考:
头文件:
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class cn_com_wintone_TLConnectJNI */
#ifndef _Included_cn_com_wintone_TLConnectJ ......

C 字符串函数大全

函数名: stpcpy
功 能: 拷贝一个字符串到另一个
用 法: char *stpcpy(char *destin, char *source);
程序例:
#include <stdio.h>
#include <string.h>
int main(void)
{
   char string[10];
   char *str1 = "abcdefghi";
   stpcpy(string, str1);
 & ......

C打印 大数的 阶乘

 6000甚至10000,都可以,但大于6000,就开始滚屏了。。
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
int i,j,*f,tmp,c=0;
long int n,bits;
const double PI=2*asin(1.0),E=exp(1.0);
scanf("%ld",&n);
bits=(long)ceil(n*(log10(n)-log ......

PHP循环语句

循环语句是 为了解决编程中 "需要重复一段指令直到满足特定条件为止" 的一种循环机制
1、while
     while语句指定了一个条件,在其嵌入代码结束执行前,必须满足这个条件。
     语法:
     while(expression){
      & ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号