Commit 4bf58fa7 authored by Jørgen Lien Sellæg's avatar Jørgen Lien Sellæg
Browse files

add sum example in pybind11

parent cf323913
[submodule "pybind/sum_example/lib/pybind11"]
path = pybind/sum_example/lib/pybind11
url = git@github.com:pybind/pybind11
cmake_minimum_required(VERSION 2.8)
set(project_name pybind-example)
project(project_name)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -Wall -Wextra")
add_subdirectory("lib/pybind11")
pybind11_add_module("Maths" module.cpp)
Subproject commit 9bb3313162c0b856125e481ceece9d8faa567716
#include <pybind11/pybind11.h>
int sum(int a, int b) {
return a + b;
}
PYBIND11_MODULE(Maths, m) {
m.def("sum", &sum);
}
from sys import path
path.append("./build") # sorry
from Maths import sum
result = sum(3, 2)
print(result)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment