Coder Social home page Coder Social logo

cpp_python_wrapping's Introduction

cpp_python_wrapping

NOTE

must set primary source in .cpp


python3 setup.py build
  1. build 폴더안의 so 파일을 꺼내온다
  2. 파이썬에서 import (so 파일의 이름을 A.so 로 바꿨다 하고)
import A
B = A.PyA(0,0,5,5)
B.getArea()
25

cpp_python_wrapping's People

Contributors

koobh avatar

Watchers

James Cloos avatar

cpp_python_wrapping's Issues

Windows 에러

  File ".\test.py", line 5, in <module>
    f = A(5)
  File "C:\project\cpp_python_wrapping\ctype_2d\a.py", line 13, in __init__
    lib.A_new.argtypes = [ctypes.c_int]
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.752.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 386, in __getattr__
    func = self.__getitem__(name)
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.752.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 391, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'A_new' not found

Cython compiled C extension: ImportError: dynamic module does not define init function

https://stackoverflow.com/questions/8024805/cython-compiled-c-extension-importerror-dynamic-module-does-not-define-init-fu

I've found that a frequent cause of this problem is, when using a distutils setup file to compile the code, that the .pyx base name does not match the extension name, e.g:

ext = Extension(name='different', sources=['cython_ext.pyx']) # Won't work
To avoid the problem the extension name should be exactly the same, in this case, cython_ext.

더블 포인터

pyx에서 멤버 변수를 선언 해야하는데. 이건 파이썬 타입인데. 여기서 더블 포인터를 사용 가능한가?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.