易截截图软件、单文件、免安装、纯绿色、仅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行


相关文档:

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/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 ......

C 面试题之找错题


找错题
  试题1:
void test1()
{
 char string[10];
 char* str1 = "0123456789";
 strcpy( string, str1 );
}
  试题2:
void test2()
{
 char string[10], str1[10];
 int i;
 for(i=0; i<10; i++)
 {
  str1[i] = 'a';
 }
 strcpy( string, str1 );
}
  试题3:
void test3( ......

linux 下php的安装

    
环境软件版本介绍:
 
   APACHE 2.0.59
   PHP5.2.3
   MYSQL5.0.45
   GD-2.0.35
   Zend Optimizer v3.3.0
  
               &n ......

PHP 自定义函数实现系统函数功能


PHP 自定义函数实现系统函数功能
总是用别人写好的函数 是不是觉得不爽?好,下面跟着我来写吧~~以下代码全部由自己编写,绝无抄袭之嫌~~现贴上,仅供参考.(可能有些功能没有写全) 
说明一下,写系统函数再拿来使用确实很蠢,但只是作为练习,还有,在面试时确实是算法考得多,网上找来的面试题也大都要靠算法\语法熟练才能 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号