ʵս¹¹½¨PythonºÍC++»ìºÏϵͳ
¹ØÓÚC++ºÍPythonÖ®¼ä»¥Ïàµ÷ÓõÄÎÊÌ⣬¿ÉÒÔ²éÕÒµ½ºÜ¶à×ÊÁÏ¡£±¾ÎĽ«Ö÷Òª´Ó½â¾öʵ¼ÊÎÊÌâµÄ½Ç¶È¿´ÈçºÎ¹¹½¨Ò»¸öPythonºÍC++»ìºÏϵͳ¡£
Á¦Îª 2009
Ò»¡¢¸ÅÄî
»ìºÏϵͳ£º²ÉÓöàÖÖÓïÑÔ¹¹½¨µÄϵͳ¡£±ÈÈçNative C++ºÍdotNetµÄ»ìºÏϵͳ£¬Python/LuaºÍC++µÄ»ìºÏϵͳ¡£
PythonºÍC++¸÷Óи÷µÄÓÅȱµã£¬¹¹½¨Á½Õß»ìºÏϵͳµÄÖ÷ҪĿµÄ¾ÍÊÇÀûÓÃPythonµÄÁé»îÐÔºÍC++¸ßЧÐÔ£¬Ôö¼Ó³ÌÐòµÄÀ©Õ¹ÐÔ¡£µ±È»»¹ÓÐÆäËûºÃ´¦£¬´Ë´¦¾Í²»Õ¹¿ªÌ¸ÁË¡£½Å±¾ÓïÑÔÓкܶ࣬ÖÁÓÚΪʲô²»²ÉÓÃÆäËûµÄ£¨ÈçLua¡¢RubyµÈ£©£¬ÕâÀïÒ²²»¿¼ÂÇ¡£½Å±¾ÓïÑԵIJÉÓÃÖ÷ÒªÊǸöÈËϲºÃµÄÎÊÌâ¡£²ÉÓÃLua¿ÉÒԲ鵽ºÜ¶à×ÊÁÏ£¬ÒÔÇ°Ò²ÔøÓÃLuaBindʵÏÖ¹ý¡£
¶þ¡¢ÏµÍ³¼Ü¹¹
»ìºÏϵͳ¿ÉÒÔ¼ò»¯³ÉÈçÏÂÄ£ÐÍ£º
ϵͳµÄÔËÐйý³ÌΪ£º
Ê×ÏÈÔÚÓ¦ÓóÌÐòÖÐǶÈë½Å±¾ÓïÑÔ½âÎöÆ÷£¬È»ºóÓýű¾ÓïÑÔÌṩµÄC/C++ API·â×°ÒÑÓеÄC++¹¦Äܿ⣬ÔÙÓýű¾µ÷Ó÷â×°µÄ·þÎñ¡£´Ëºó£¬Ó¦Óòã±ã¿ÉÒÔÖ´Ðнű¾ÀïµÄÄÚÈÝ£¬ÆäЧ¹ûÓëÓ¦ÓòãÖ±½Óµ÷Ó÷þÎñ²ãÀàËÆ¡£
Èý¡¢ÊµÏÖ
±¾ÀýÖвÉÓýű¾ÓïÑÔPython£¬Òò´ËÖ÷Òª¹¤×÷ΪÔÚÓ¦ÓòãǶÈëPython½âÎöÆ÷£¬ÓÃPython·â×°·þÎñ²ã¡£ÎªÁË˵Ã÷ÎÊÌ⣬ӦÓòãµÄʵÏÖΪPythonConsole.ex£¬·þÎñ²ãµÄʵÏÖΪMythma.dll£¬·â×°²ãΪMythmaPy.dll¡£
1¡¢¼Ù¶¨Mythma.dllÖеÄÒ»¸öÀàΪCHelloWorld£º
class MythmaAPI CHelloWorld
{
public:
CHelloWorld(void);
~CHelloWorld(void);
void SetId(int nId) { m_Id = nId;}
int GetId() const { return m_Id; }
private:
int m_Id;
};
2¡¢ÏÖÔÚÓÃBoost.Python·â×°¸ÃÀࣺ
#include "HelloWorld.h"
#include <boost/python.hpp>
using namespace boost::python;
BOOST_PYTHON_MODULE(My
Ïà¹ØÎĵµ£º
Python ³ÌÐòÖеÄÒ»ÇÐÊý¾Ý¶¼ÊǶÔÏ󡣶ÔÏó°üÀ¨×Ô¶¨Òå¶ÔÏó¼°»ù±¾µÄÊý¾ÝÀàÐÍÈçÊýÖµ¡¢×Ö·û´®¡¢ÁÐ±í¡¢×ÖµäµÈ¡£ÄãÄܹ»ÒÔÀà»òÀ©Õ¹ÀàÐ͵ķ½Ê½´´½¨×Ô¶¨Òå¶ÔÏó¡£±¾ÕÂÖ÷ÒªÃèÊö Python¶ÔÏóÄ£Ðͼ°µÚËÄÕÂ--ÔËËã·ûÓë±í´ïʽÖÐÒªÓõ½µÄһЩԤ±¸ÖªÊ¶¡£
1.1. ÊõÓï
³ÌÐòÖеÄÒ»ÇÐÊý¾Ý¶¼ÊǶÔÏó£¬Ã¿¸ö¶ÔÏó¶¼ÓÐÈý¸ö»ù±¾ÊôÐÔ£¬¼´±êʶ(ÀàË ......
ѧϰC++Äã±ØÐëÁ˽âÒÔÏÂ֪ʶ£º
C++Ö»ÊÇÒ»ÖÖÓïÑÔ¹¤¾ß£¬ÄãÒª±à³ÌÐò£¬×öÏîĿʵÏÖ×Ô¼ºµÄÏë·¨µ¥¿¿APIÊǺܷѾ¢µÄ£¬ÌرðÊÇÕë¶ÔÖØÁ¿¼¶µÄÏîÄ¿¡£ËùÒÔÔÚʵ¼Ê¹¤×÷ʱ£¬Äã±ØÐë»áÖÁÉÙ1ÖÖC++¿ª·¢¿â£¬ÕâÑùÄã»á¸ü¿ì¸üÓŵØÍê³ÉÒ»ÏîÈÎÎñ¡£
------------------------------------------------------------------------------------
ժ¼ÓÚ:http ......
C++Àà¿â½éÉÜ
ÔÙ´ÎÌåÏÖÁËC++±£³ÖºËÐÄÓïÑÔµÄЧÂÊͬʱ´óÁ¦·¢Õ¹Ó¦ÓÿâµÄ·¢Õ¹Ç÷ÊÆ!!ÔÚC++ÖУ¬¿âµÄµØλÊǷdz£¸ßµÄ¡£C++Ö®¸¸ Bjarne
StroustrupÏÈÉú¶à´Î±íʾÁËÉè¼Æ¿âÀ´À©³ä¹¦ÄÜÒªºÃ¹ýÉè¼Æ¸ü¶àµÄÓï·¨µÄÑÔÂÛ¡£ÏÖʵÖУ¬C++µÄ¿âÃÅÀà·±¶à£¬½â¾öµÄÎÊÌâÒ²ÊǼ«Æä¹ã·º£¬¿â´ÓÇáÁ¿¼¶µ½ÖØ
Á¿¼¶µÄ¶¼Ó ......
½ñÌìÔÚ¿´ LippmanµÄ¡¶Éî¶È̽Ë÷C++¶ÔÏóÄ£ÐÍ¡·£¬ºöÈ»ÏëgoogleÒ»ÏÂLippmanÓëBjarne StroustrupµÄ¸öÈ˹ØϵÈçºÎ¡£ÒòΪÎÒ¿´BSдµÄTCPLµÄÇ°ÑÔÖдÓÀ´Ã»ÓÐÌáµ½¹ýLippman£¬ÊDz»ÊÇLippmanÔÚBSÑÛÖв¢Ã»ÓÐʲôµØλÄØ£¿½á¹ûûÓв鵽ʲôÓÐÓõÄÐÅÏ¢£¬µ¹ÊÇ¿´µ½ÃÏÑÒµÄһƪ2004ÄêµÄ²©¿Í——¡¶ ......