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

Linuxϵͳ¹²Ïí¿â±à³Ì

Ò»¡¢ËµÃ÷
¡¡¡¡ÀàËÆWindowsϵͳÖеĶ¯Ì¬Á´½Ó¿â£¬LinuxÖÐÒ²ÓÐÏàÓ¦µÄ¹²Ïí¿âÓÃÒÔÖ§³Ö´úÂëµÄ¸´Óá£WindowsÖÐΪ*.dll£¬¶øLinuxÖÐΪ*.so¡£ÏÂÃæÏêϸ½éÉÜÈçºÎ´´½¨¡¢Ê¹ÓÃLinuxµÄ¹²Ïí¿â¡£
¶þ¡¢´´½¨¹²Ïí¿â
ÔÚmytestso.cÎļþÖУ¬´úÂëÈçÏ£º
#include <stdio.h>
#include <stdlib.h>
int GetMax(int a, int b)
{
if (a >= b)
return a;

return b;
}
int GetInt(char* psztxt)
{
if (0 == psztxt)
return -1;

return atoi(psztxt);
}

È»ºóʹÓÃÏÂÁÐÃüÁî½øÐбàÒ룺
gcc -fpic -shared mytestso.c -o mytestso.so
-fpic ʹÊä³öµÄ¶ÔÏóÄ£¿éÊǰ´ÕÕ¿ÉÖØ¶¨Î»µØÖ··½Ê½Éú³ÉµÄ
±àÒë³É¹¦ºó£¬µ±Ç°Ä¿Â¼ÏÂÓÐmytestso.so£¬´ËʱÒѳɹ¦´´½¨¹²Ïí¿âmytestso.so¡£
Èý¡¢Ê¹Óù²Ïí¿â
¡¡¡¡¹²Ïí¿âÖеĺ¯Êý¿É±»Ö÷³ÌÐò¼ÓÔØ²¢Ö´ÐУ¬µ«ÊDz»±Ø±àÒëʱÁ´½Óµ½Ö÷³ÌÐòµÄÄ¿±êÎļþÖС£Ö÷³ÌÐòʹÓù²Ïí¿âÖеĺ¯Êýʱ£¬ÐèÒªÊÂÏÈÖªµÀËù°üº¬µÄº¯ÊýµÄÃû³Æ£¨×Ö·û´®£©£¬È»ºó¸ù¾ÝÆäÃû³Æ»ñµÃ¸Ãº¯ÊýµÄÆðʼµØÖ·£¨º¯ÊýÖ¸Õ룩£¬È»ºó¼´¿ÉʹÓøú¯ÊýÖ¸ÕëʹÓøú¯Êý¡£
ÔÚmytest.cÎļþÖУ¬´úÂëÈçÏ£º
#include <dlfcn.h>
#include <stdio.h>
int main(int argc, char* argv[])
{
void* pdlhandle;
char* pszerror;

int (*GetMax)(int a, int b);
int (*GetInt)(char* psztxt);

int a, b;
char* psztxt = "1024";

// open mytestso.so
pdlhandle = dlopen("./mytestso.so", RTLD_LAZY);
pszerror = dlerror();
if (0 != pszerror) {
printf("%s\n", pszerror);
exit(1);
}

// get GetMax func
GetMax = dlsym(pdlhandle, "GetMax");
pszerror = dlerror();
if (0 != pszerror) {
printf("%s\n", pszerror);
exit(1);
}

// get GetInt func
GetInt = dlsym(pdlhandle, "GetInt");
pszerror = dlerror();
if (0 != pszerror) {
printf("%s\n", pszerror);
exit(1);
}

// call fun
a = 200;
b = 600;
printf("max=%d\n", GetMax(a, b));
printf("txt=%d\n", GetInt(psztxt));

// close mytestso.so
dlclose(pdlhandle);
}

È»ºóʹÓÃÈçÏÂÃüÁî½øÐбàÒ룺
gcc mytest.c -ldl -o mytest
-ldlÑ¡Ï±íʾÉú³ÉµÄ¶ÔÏóÄ£¿éÐèҪʹÓù²Ïí¿â
(1)dlopen()
µÚÒ»¸ö²ÎÊý£ºÖ¸¶¨¹²Ïí¿âµÄÃû³Æ£¬½«»áÔÚÏÂÃæÎ»ÖòéÕÒÖ¸¶¨µÄ¹²Ïí¿â¡£
£­»·¾³±äÁ¿LD_LIBRA


Ïà¹ØÎĵµ£º

Linux °²×°Èí¼þ ͨÓ÷½·¨


°²×°ÊµÀý£ºImageMagickµÄ°²×°·½·¨
ImageMagickµÄ°²×°·½·¨ÓÐRPM·½Ê½ºÍSOURCE·½Ê½¡£Ä¿Ç°×îаæÊÇImageMagick-6.5.5¡£¿ÉÒÔ´ÓÕâ¸öÍøÖ·ÏÂÔØ£º http://www.imagemagick.org
°²×°²½Ö裺
£±£®sshÁ¬½ÓLinux·þÎñÆ÷
£²£®°ÑÏÂÔØµÄ°²×°Îļþ·Åµ½Êʵ±µÄÎļþ¼ÐÏ¡£ÀýÈ磺cd /usr/local/src¡£»òÕßÖ±½ÓÔÚ·þÎñÆ÷ÉÏÏÂÔØ¡£
3£®½âѹÏÂÔØÎļ ......

linuxÏÂtcp·þÎñÆ÷Ô´ÂëʾÀý

#include <errno.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <string.h>
#include <netinet/in.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <s ......

linuxÏÂͳ¼ÆÊ±¼äÀà

class CTimeTickCount
{
public:
CTimeTickCount(int threadIndex, int id )
{
struct timezone tz;
gettimeofday(&m_tvStartTime, &tz);
// m_tmStartTime = ACE_OS::gettimeofday();
m_iThreadIndex ......

SuSE Linux10Éϰ²×°OracleÊý¾Ý¿â

ϵͳҪÇó£º
¡¡¡¡ÄÚ´æ£ºÍÆ¼ö1G
¡¡¡¡Swap·ÖÇø£ºÉèΪÄÚ´æµÄ2±¶
¡¡¡¡/tmp´ÅÅ̿ռ䣺400MBÒÔÉÏÈý
¡¡¡¡´ÅÅ̿ռ䣺Èí¼þ3.5G Êý¾Ý1.2G
¡¡¡¡ËùÐèÈí¼þ£º
¡¡¡¡SuSE Linux10 for x86
¡¡¡¡Oracle database 10gR2 for Linux32
¡¡¡¡Orarun-1.8-109.15.i586.rpmÈí¼þ°ü£¬¿ÉÒÔ´Óhttp://Ftp.novell.com/partners/Oracle/sels-9ÏÂÔØ
&n ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ