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:
Ïà¹ØÎĵµ£º
´´½¨×ÀÃæͼ±ê
Ä¿Ç°½«ÍøÂçÓ¦ÓÃÀ©Õ¹µ½×ÀÃæÊÇÒ»¸öÇ÷ÊÆ£¬´æÔÚןܶà½â¾ö·½°¸£¬±¾ÎÄÒÔ Mozilla Prism ΪÀý£¬ÀàËƵķ½·¨Í¬ÑùÊÊÓÃÓÚ Google Chrome ¡£
1. µ½ Mozilla Prism µÄÍøÕ¾ÉÏÏÂÔØ Prism£¬µã»÷ Download Now Ö®ºó»áÌáʾÓÐÁ½ÖÖ£¬Ò»ÖÖÊÇÒÔ Mozilla Firefox À©Õ¹µÄ·½Ê½£¬ÊʺÏÒѾ°²×°ÓÐ Firefox µÄÅóÓÑ£»Ò»Ö ......
ÏëÒªÔÚÐéÄâ»úϵÄlinuxÓëwindows»¥Áª£¬×î¹Ø¼üµÄÖ»ÐèÒª3²½£º
1.Ò»¶¨ÒªÉèÖÃÐéÄâ»úµÄÍø¿¨ÎªÇŽÓģʽ£¬ÕÒ¸öÒ»¶¨²»ÄÜÍü¡£
2.ÉèÖÃlinuxϵÄipµØÖ·£¬ vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0 #ÍøÂçÃû³Æ
BOOTPROTO=static #¾²Ì¬»ñÈ¡ipµØÖ·
IPADD ......
Äں˼ò½é
¡¡¡¡Äںˣ¬ÊÇÒ»¸ö²Ù×÷ϵͳµÄºËÐÄ¡£Ëü¸ºÔð¹ÜÀíϵͳµÄ½ø³Ì¡¢ÄÚ´æ¡¢É豸Çý¶¯³ÌÐò¡¢ÎļþºÍÍøÂçϵͳ£¬¾ö¶¨×ÅϵͳµÄÐÔÄܺÍÎȶ¨ÐÔ¡£
¡¡¡¡LinuxµÄÒ»¸öÖØÒªµÄÌصã¾ÍÊÇÆäÔ´´úÂëµÄ¹«¿ªÐÔ£¬ËùÓеÄÄÚºËÔ´³ÌÐò¶¼¿ÉÒÔÔÚ/usr/src/linuxÏÂÕÒµ½£¬´ó²¿·ÖÓ¦ÓÃÈí¼þÒ²¶¼ÊÇ×ñÑGPL¶øÉè¼ÆµÄ£¬Ä㶼¿ÉÒÔ»ñÈ¡ÏàÓ¦µÄ ......
Ê×ÏÈÏÈѧѧ±à¼Æ÷£¬vim, emacsʲôµÄ¶¼ÐС£
È»ºóѧmake fileÎļþ£¬Ö»ÒªÖªµÀÒ»µã¾ÍÐУ¬ÕâÑù¾Í¿ÉÒÔ×¼±¸±à³ÌÐòÁË¡£
È»ºó¿´¿´¡¶C³ÌÐòÉè¼ÆÓïÑÔ¡·K&R£¬ÕâÑùÄØ£¬»ù±¾ÉϾͿÉÒÔ½øÐÐÒ»°ãµÄ±à³ÌÁË£¬Ë³±ãÕÒ±¾Êý¾Ý½á¹¹µÄÊéÀ´¿´¡£
Èç¹ûÏëѧϰUNIX/LINUXµÄ±à³Ì£¬¡¶APUE¡·¾ø¶Ô¾µäµÄ½Ì²Ä£¬¼ÓÉîһϹ¦µ×£¬Ñ§Ï°¡¶UNP¡·µÄµÚ¶þ¾í¡£ÕâÑù»ù ......