ʲôÊÇ¿â
¿âÎļþÊÇһЩԤÏȱàÒëºÃµÄº¯ÊýµÄ¼¯ºÏ£¬ÄÇЩº¯Êý¶¼ÊÇ°´ÕÕ¿ÉÔÙʹÓõÄÔÔò±àдµÄ¡£ËüÃÇͨ³£ÓÉÒ»×黥Ïà¹ØÁªµÄÓÃÀ´Íê³ÉijÏî³£¼û¹¤×÷µÄº¯Êý¹¹³É£¬´Ó±¾ÖÊÉÏÀ´Ëµ¿âÊÇÒ»ÖÖ¿ÉÖ´ÐдúÂëµÄ¶þ½øÖÆÐÎʽ£¬¿ÉÒÔ±»²Ù×÷ϵͳÔØÈëÄÚ´æÖ´ÐС£
ÎÞÂÛÔÚWindowsƽ̨»¹ÊÇÔÚLinuxƽ̨϶¼´æÔÚ´óÁ¿µÄ¿â£¬µ«ÓÉÓÚWindowsºÍLinuxµÄ±¾Öʲ»Í¬£¬Òò´Ë¶þÕߵĿâµÄ¶þ½øÖÆÊDz»¼æÈݵġ£
¿âµÄ·ÖÀà
WindowsϵĿâÓÐÁ½ÖÖ£º¾²Ì¬¿â(.lib)ºÍ¶¯Ì¬Á´½Ó¿â(.dll)¡£
LinuxϵĿâÓÐÁ½ÖÖ£º¾²Ì¬¿â(.a)ºÍ¹²Ïí¿â(.so)¡£
Linuxϵľ²Ì¬¿âµÄÃû×ÖÒ»°ãΪlibxxxx.a£¬ÆäÖÐxxxxÊǸÃlibµÄÃû³Æ
LinuxϵĶ¯Ì¬¿âµÄÃû×ÖÒ»°ãΪlibxxxx.so.major.minor£¬xxxxÊǸÃlibµÄÃû³Æ£¬majorÊÇÖ÷°æ±¾ºÅ£¬minorÊǸ±°æ±¾ºÅ¡£
WindowsϵĿâÓëLinuxϵĿâµÄÒìͬ
LinuxµÄ¹²Ïí¿â(.so)¾ÍÏóWindowsµÄ¶¯Ì¬Á´½Ó¿â(.dll)£¬ËüÀïÃæ°üº¬Óкܶà³ÌÐò³£Óõĺ¯Êý¡£ÎªÁË·½±ã³ÌÐò¿ª·¢ºÍ¼õÉÙ³ÌÐòµÄÈßÓ࣬³ÌÐòµ±ÖоͲ»Óðüº¬Ã¿¸ö³£Óú¯ÊýµÄ¿½±´£¬Ö»ÊÇÔÚÐèҪʱµ÷Óù²Ïí¿âÖг£º¯Êý¼´¿É¡£ÕâÖÖ·½Ê½ÎÒÃdzÆ֮Ϊ¶¯Ì¬Á´½Ó(Dynamically Linked)¡£¶øÓÐʱÎÒÃDz»Ï£Íû½Ð³ÌÐòÈ¥µ÷Óù²Ïí¿âµÄº¯Êý£¬¶øÊǰѿ⺯Êý´úÂëÖ±½ÓÁ´½Ó½ø³ÌÐò´úÂëÖУ¬Ò²¾ÍÊÇ˵£¬ÔÚ³ÌÐò±¾ÉíÓµÓÐÒ»·Ý¹²Ïí¿âÖк¯ÊýµÄ¸±±¾¡£ÕâÖÖ·½Ê½ÎÒÃdzÆ֮Ϊ¾²Ì¬Á´½Ó£¨Statically Linked£©¡£
ËùÒÔ£¬¼òµ¥µÄ½²¾²Ì¬¿âºÍ¹²Ïí¿â(¶¯Ì¬¿â)µÄ²»Í¬µãÔÚÓÚ´úÂë±»ÔØÈëµÄʱ¿Ì²»Í¬¡£
¾²Ì¬¿âµÄ´úÂëÔÚ±àÒë¹ý³ÌÖÐÒѾ±»ÔØÈë¿ÉÖ´ÐгÌÐò£¬Òò´ËÌå»ý½Ï´ó¡£
¹²Ïí¿âµÄ´úÂëÊÇÔÚ¿ÉÖ´ÐгÌÐòÔËÐÐʱ²ÅÔØÈëÄÚ´æµÄ£¬ÔÚ±àÒë¹ý³ÌÖнö¼òµ¥µÄÒýÓã¬Òò´Ë´úÂëÌå»ý½ÏС¡£
WindowsϵĶ¯Ì¬Á´½Ó¿â(.dll)ÓëLinuxÏµĹ²Ïí¿â(.so)µÄ²î±ð
.dllÎļþÊÂʵÉϺÍ.exeÎļþÒ»Ñù£¬Í¬Êô PE ¸ñʽµÄÖ´ÐÐÎļþ¡£¶ÔÓÚÒþʽµÄÒýÓÃÍⲿ·ûºÅ£¬ÐèÒª°ÑÍⲿ·ûºÅËùÔÚµÄλÖÃдÔÚPEÍ·ÉÏ¡£PE¼ÓÔØÆ÷½«´ÓPEÍ·ÉÏÕÒµ½ÒÀÀµµÄ·ûºÅ±í£¬²¢¼ÓÔØÒÀÀµµÄÆäËü.dllÎļþ¡£
¶øÔÚLinux Éϲ¢·ÇÈç´Ë£¡.soÎļþ´ó¶àΪelfÖ´ÐÐÎļþ¸ñʽ¡£µ±ËüÃÇÐèÒªµÄÍⲿ·ûºÅ£¬¿ÉÒÔ²»Ð´Ã÷ÕâЩ·ûºÅËùÔÚµÄλÖá£Ò²¾ÍÊÇ˵£¬Í¨³£.soÎļþ±¾Éí²¢²»ÖªµÀËüÒÀÀµµÄÄÇЩ·ûºÅÔÚÄÄЩ.soÀïÃæ¡£ÕâЩ·ûºÅÊÇÓɵ÷ÓÃdlopenµÄ½ø³ÌÔËÐÐʱÌṩµÄ¡£
ÎÒÃÇÔÚWindowsÏÂ×öÒ»¸ö.dllÎļþʱ»¹ÐèҪЯ´øÒ»¸ö.libÎļþ£»¶øÔÚLinuxÏÂÒ»°ãÖ»ÐèÒªÓÐÏàÓ¦µÄÍ·Îļþ¾Í¹»ÁË¡£¶ÔÓÚ±àдеÄ.so£¬ÕÒ²»µ½µÄ·ûºÅ¿ÉÒÔ¾ÍÈÃËüÔÚÄÇÀֱµ½×îÖÕÖ´ÐÐÎļþÀ´°ÑËùÓÐÐèÒªµÄ·ûºÅÁªºÏµ½Ò»Æð¡£windows ¿ÉÒÔ´æÔÚÒ»¸ö.dll¶ÔÁíÒ»¸ö.dllµÄÒþʽÒÀÀµ£»¶øLinuxÏÂÒ»°ã²»ÐèÒªÈÃ.soºÍ.soÓÐÒþʽÒÀÀµ¹Øϵ¡£