Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Linux shared library Loading function

Link from: http://www.faqs.org/docs/Linux-mini/C++-dlopen.html
//1. == main.cpp =============================================
// How to build?
// g++ -o main main.cpp -ldl
//=======================================================
#include <iostream>
#include <dlfcn.h>
int main() {
    using std::cout;
    using std::cerr;
    cout << "C++ dlopen demo\n\n";
    // open the library
    cout << "Opening hello.so...\n";
    void* handle = dlopen("./hello.so", RTLD_LAZY);
    if (!handle) {
        cerr << "Cannot open library: " << dlerror() << '\n';
        return 1;
    }
    // load the symbol
    cout << "Loading symbol hello...\n";
    typedef void (*hello_t)();
    hello_t hello = (hello_t) dlsym(handle, "hello");
    if (!hello) {
        cerr << "Cannot load symbol 'hello': " << dlerror() <<
            '\n';
        dlclose(handle);
        return 1;
    }
    // use it to do the calculation
    cout << "Calling hello...\n";
    hello();
    // close the library
    cout << "Closing library...\n";
    dlclose(handle);
}
// 2=====hello.cpp ========================================
// How to build?
// g++ -c -fPIC hello.cpp
// g++ -shared  -o hello.so
-fPIC hello.o
//======================================================
#include <


Ïà¹ØÎĵµ£º

dz̸ÐéÄâ»úϵÄlinuxÓëwindows»¥Áª

ÏëÒªÔÚÐéÄâ»úϵÄlinuxÓëwindows»¥Áª£¬×î¹Ø¼üµÄÖ»ÐèÒª3²½£º
1.Ò»¶¨ÒªÉèÖÃÐéÄâ»úµÄÍø¿¨ÎªÇŽÓģʽ£¬ÕÒ¸öÒ»¶¨²»ÄÜÍü¡£
2.ÉèÖÃlinuxϵÄipµØÖ·£¬ vi /etc/sysconfig/network-scripts/ifcfg-eth0
   DEVICE=eth0   #ÍøÂçÃû³Æ
   BOOTPROTO=static  #¾²Ì¬»ñÈ¡ipµØÖ·
   IPADD ......

LinuxÏÂI2CÉ豸Çý¶¯¿ª·¢ºÍʵÏÖ

¡¡I2C×ÜÏß¾ßÓнṹ¼òµ¥Ê¹Ó÷½±ãµÄÌص㡣±¾ÎÄÃèÊöÁËlinuxÏÂI2CÇý¶¯µÄ½á¹¹£¬²¢ÔÚ´Ë»ù´¡Éϸø³öÁËI2CÉ豸Çý¶¯ºÍÓ¦ÓõÄʵÏÖ¡£
¡¡¡¡1  ÒýÑÔ
¡¡¡¡I2C (Inter£­Integrated Circuit)×ÜÏßÊÇÒ»ÖÖÓÉPHILIPS¹«Ë¾¿ª·¢µÄÁ½Ïßʽ´®ÐÐ×ÜÏߣ¬ÓÃÓÚÁ¬½Ó΢¿ØÖÆÆ÷¼°ÆäÍâΧÉ豸¡£I2C×ÜÏß×îÖ÷ÒªµÄÓŵãÊÇÆä¼òµ¥ÐÔºÍÓÐЧÐÔ¡£ÓÉÓÚ½Ó¿ÚÖ±½ÓÔÚ×é¼þÖ ......

À©´óVMwareÐéÄâ»úÖÐlinuxÓ²ÅÌ¿Õ¼ä

ΪVMwareÌí¼ÓÐéÄâÓ²ÅÌ
               VMware°²×°linuxµÄʱºòĬÈÏ·ÖÅäµÄ¿Õ¼äÊÇ4GB£¬¿ÉÄܻ᲻¹»£¬Õâ¸öʱºò¿ÉÒÔͨ¹ýÔö¼ÓÒ»¿éÐéÄâÓ²ÅÌ£¬½«/usr»òÆäËûÄÚÈÝ¿½±´¹ýÈ¥½â¾öÕâ¸öÎÊÌ⣺
´´½¨ÐéÄâÓ²ÅÌ
        1¡¢¹Ø±ÕV ......

I2C×ÜÏßÔÚLinuxϵͳÖеÄÇý¶¯Éè¼Æ

1 ÒýÑÔ
¡¡¡¡Linux²Ù×÷ϵͳÒò¾ßÓÐÔ´´úÂ빫¿ª¡¢±ãÓڲüõ¡¢Óй㷺µÄ´¦ÀíÆ÷Ö§³ÖµÈÓŵ㣬³ÉΪµ±Ç°Ç¶ÈëʽϵͳµÄÈÈÃÅÑ¡Ôñ¡£»ùÓÚI2C×ÜÏߵļüÅÌÀ©Õ¹É豸Ö÷ÒªÓÃÓÚÂú×ãǶÈëʽÉ豸ÖжԶఴ¼üµÄÐèÇó£¬Çý¶¯³ÌÐòÔÚϵͳÆô¶¯Ê±¶ÔÓ²¼þ½øÐгõʼ»¯¡£ÔÚϵͳÆô¶¯ºóʵÏÖÓ²¼þºÍÓ¦ÓóÌÐòÖ®¼äµÄÊý¾Ý½»»¥¡£Õë¶ÔS3C2410΢´¦ÀíÆ÷ºÍ¼üÅÌɨÃè¹ÜÀíÆ÷¼þ£¬ÉîÈ ......

¸ß¼¶Linux³ÌÐòÉè¼ÆµÚÒ»Õ£ºÈëÃÅ

1¡¢ÓÃGCC±àÒë
1.1¡¢´´½¨Ô´Îļþ
(main.c) C Ô´Îļþ - main.c
#include
#include “reciprocal.hpp”
int main (int argc, char **argv)
{
    int i;
    i = atoi (argv[1]);
    printf (“The reciprocal of %d is %g\n”, i, reciprocal (i ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ