Linux shared library Loading class
Linked from: http://www.faqs.org/docs/Linux-mini/C++-dlopen.html
//1.==== main.cpp =============================================================
// How to build?
// g++ main.cpp -ldl
//=============================================================================
#include "polygon.h"
#include <iostream>
#include <dlfcn.h>
int main() {
using std::cout;
using std::cerr;
// load the triangle library
void* triangle = dlopen("./triangle.so", RTLD_LAZY);
if (!triangle) {
cerr << "Cannot load library: " << dlerror() << '\n';
return 1;
}
// load the symbols
create_t* create_triangle = (create_t*) dlsym(triangle, "create");
destroy_t* destroy_triangle = (destroy_t*) dlsym(triangle, "destroy");
if (!create_triangle || !destroy_triangle) {
cerr << "Cannot load symbols: " << dlerror() << '\n';
return 1;
}
// create an instance of the class
polygon* poly = create_triangle();
// use the class
poly->set_side_length(7);
cout << "The area is: " << poly->area() << '\n';
// destroy the class
destroy_triangle(poly);
// unload the triangle library
dlclose(triangle);
}
//2.=====polygon.h======================================
#ifndef POLYGON_HPP
#define POLYGON_HPP
class polygon {
protected:
double side_length_;
public:
Ïà¹ØÎĵµ£º
Äں˼ò½é
¡¡¡¡Äںˣ¬ÊÇÒ»¸ö²Ù×÷ϵͳµÄºËÐÄ¡£Ëü¸ºÔð¹ÜÀíϵͳµÄ½ø³Ì¡¢ÄÚ´æ¡¢É豸Çý¶¯³ÌÐò¡¢ÎļþºÍÍøÂçϵͳ£¬¾ö¶¨×ÅϵͳµÄÐÔÄܺÍÎȶ¨ÐÔ¡£
¡¡¡¡LinuxµÄÒ»¸öÖØÒªµÄÌصã¾ÍÊÇÆäÔ´´úÂëµÄ¹«¿ªÐÔ£¬ËùÓеÄÄÚºËÔ´³ÌÐò¶¼¿ÉÒÔÔÚ/usr/src/linuxÏÂÕÒµ½£¬´ó²¿·ÖÓ¦ÓÃÈí¼þÒ²¶¼ÊÇ×ñÑGPL¶øÉè¼ÆµÄ£¬Ä㶼¿ÉÒÔ»ñÈ¡ÏàÓ¦µÄ ......
ΪVMwareÌí¼ÓÐéÄâÓ²ÅÌ
VMware°²×°linuxµÄʱºòĬÈÏ·ÖÅäµÄ¿Õ¼äÊÇ4GB£¬¿ÉÄܻ᲻¹»£¬Õâ¸öʱºò¿ÉÒÔͨ¹ýÔö¼ÓÒ»¿éÐéÄâÓ²ÅÌ£¬½«/usr»òÆäËûÄÚÈÝ¿½±´¹ýÈ¥½â¾öÕâ¸öÎÊÌ⣺
´´½¨ÐéÄâÓ²ÅÌ
1¡¢¹Ø±ÕV ......
Ê×ÏÈÏÈѧѧ±à¼Æ÷£¬vim, emacsʲôµÄ¶¼ÐС£
È»ºóѧmake fileÎļþ£¬Ö»ÒªÖªµÀÒ»µã¾ÍÐУ¬ÕâÑù¾Í¿ÉÒÔ×¼±¸±à³ÌÐòÁË¡£
È»ºó¿´¿´¡¶C³ÌÐòÉè¼ÆÓïÑÔ¡·K&R£¬ÕâÑùÄØ£¬»ù±¾ÉϾͿÉÒÔ½øÐÐÒ»°ãµÄ±à³ÌÁË£¬Ë³±ãÕÒ±¾Êý¾Ý½á¹¹µÄÊéÀ´¿´¡£
Èç¹ûÏëѧϰUNIX/LINUXµÄ±à³Ì£¬¡¶APUE¡·¾ø¶Ô¾µäµÄ½Ì²Ä£¬¼ÓÉîһϹ¦µ×£¬Ñ§Ï°¡¶UNP¡·µÄµÚ¶þ¾í¡£ÕâÑù»ù ......
²é¿´ÎļþÄÚÈݵÄÌØÊâ·½·¨
¡¡¡¡ÏàÐÅ×î»ù±¾µÄcatºÍless,moreÄãÒѾºÜÊìϤÁË£¬Èç¹ûÓÐÌØÊâµÄÒªÇóÄØ£º
1. Èç¹ûÄãÖ»Ïë¿´ÎļþµÄÇ°5ÐУ¬¿ÉÒÔʹÓÃheadÃüÁÈ磺
head -5 /etc/passwd
2. Èç¹ûÄãÏë²é¿´ÎļþµÄºó10ÐУ¬¿ÉÒÔʹÓÃtailÃüÁÈ磺
tail -10 /etc/passwd
tail -f /var/log/messages
²ÎÊý-fʹtail²»Í£µØÈ¥¶Á×îеÄÄÚÈÝ£ ......
1 ÒýÑÔ
¡¡¡¡Linux²Ù×÷ϵͳÒò¾ßÓÐÔ´´úÂ빫¿ª¡¢±ãÓڲüõ¡¢Óй㷺µÄ´¦ÀíÆ÷Ö§³ÖµÈÓŵ㣬³ÉΪµ±Ç°Ç¶ÈëʽϵͳµÄÈÈÃÅÑ¡Ôñ¡£»ùÓÚI2C×ÜÏߵļüÅÌÀ©Õ¹É豸Ö÷ÒªÓÃÓÚÂú×ãǶÈëʽÉ豸ÖжԶఴ¼üµÄÐèÇó£¬Çý¶¯³ÌÐòÔÚϵͳÆô¶¯Ê±¶ÔÓ²¼þ½øÐгõʼ»¯¡£ÔÚϵͳÆô¶¯ºóʵÏÖÓ²¼þºÍÓ¦ÓóÌÐòÖ®¼äµÄÊý¾Ý½»»¥¡£Õë¶ÔS3C2410΢´¦ÀíÆ÷ºÍ¼üÅÌɨÃè¹ÜÀíÆ÷¼þ£¬ÉîÈ ......