In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Python embedded in c should be linked to the library what, I believe that many inexperienced people are helpless, for this reason this article summarizes the causes and solutions of the problem, through this article I hope you can solve this problem.
//------------------------------------------ //cppobj.h // #include using namespace std; class cppobj { private : string s; public : cppobj(string a): s(a) {}; string show() {return s;} }; //----------------------------------------- //------------------------------------------ //cppobj.i %module cppobj %include "std_string.i" %{ #include "cppobj.h" %} %include "cppobj.h" //------------------------------------------ //------------------------------------------ // Makefile _cppobj.so: cppobj_wrap.o g++ -o $@ $
< -shared -fpic -lpython24 cppobj_wrap.cxx: cppobj.i cppobj.h swig -c++ -python cppobj.i cppobj_wrap.o: cppobj.h cppobj_wrap.cxx g++ -c cppobj_wrap.cxx -fpic -IC:/Python24/include clean: rm -rf cppobj_wrap.cxx _cppobj.so *.o cppobj.py cppobj.pyc //------------------------------------------ 把Python嵌入c中时应该链接库的相关代码的前部分介绍做完之后还要 $ mv _cppobj.so _cppobj.pyd 然后就可以 >>> from cppobj import cppobj >>> c = cppobj('Hello') >>> c.show() 'Hello' After reading the above, do you know what libraries Python should link to when embedded in c? If you still want to learn more skills or want to know more related content, welcome to pay attention to the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.