Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef HELLO_WORLD_CALCULATOR_H
- #define HELLO_WORLD_CALCULATOR_H
- class Calculator {
- public:
- double add(double first, double second);
- };
- #endif
- #include "Calculator.h"
- double Calculator::add(double first, double second) {
- return first + second;
- }
- #include <iostream>
- #include <tr1/memory>
- #include "Calculator.h"
- using namespace std;
- double add1(double first, double second){
- shared_ptr<Calculator>calculater(new Calculator());
- return calculater->add(first, second);
- }
- extern "C"
- {
- double add(double f, double s){
- return add1(f,s);
- }
- }
- # coding=utf-8
- import ctypes
- from ctypes import *
- if __name__ == "__main__":
- lib = ctypes.CDLL("./test.so")
- lib.add.argstype = [c_double, c_double]
- lib.add.restype = c_double
- print lib.add(c_double(12), c_double(36))
- Traceback (most recent call last):
- File "test.py", line 9, in <module>
- lib = ctypes.CDLL("./test.so")
- File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__
- self._handle = _dlopen(self._name, mode)
- OSError: ./test.so: undefined symbol: _ZN10Calculator6devideEdd
Add Comment
Please, Sign In to add comment