-
-
Save mattbierbaum/1193397 to your computer and use it in GitHub Desktop.
| #include <stdio.h> | |
| #include "kitty.h" | |
| kitty::kitty(){ | |
| printf("Constructor\n"); | |
| variable = 100; | |
| } | |
| kitty::~kitty(){ | |
| printf("Destructor\n"); | |
| variable = 0; | |
| } | |
| void kitty::speak(){ | |
| printf("I'm a cat.\n"); | |
| } |
| #include <stdio.h> | |
| class kitty { | |
| public: | |
| kitty(); | |
| ~kitty(); | |
| void speak(); | |
| void speak2(){ printf("totes works\n"); } | |
| private: | |
| int variable; | |
| }; |
| %module kitty | |
| %{ | |
| #include "kitty.h" | |
| %} | |
| %include "kitty.h" |
| # standard compile options for the c++ executable | |
| FLAGS = -fPIC | |
| # the python interface through swig | |
| PYTHONI = -I/usr/include/python2.6/ | |
| PYTHONL = -Xlinker -export-dynamic | |
| # default super-target | |
| all: | |
| g++ -fPIC -c kitty.cc -o kitty.o | |
| swig -c++ -python -o kitty_wrap.cxx kitty.i | |
| g++ $(FLAGS) $(PYTHONI) -c kitty_wrap.cxx -o kitty_wrap.o | |
| g++ $(PYTHONL) $(LIBFLAGS) -shared kitty.o kitty_wrap.o -o _kitty.so |
I love u
I love you
I.. I love you
I ❤️ you
After banging my head helplessly against the walls of swig and g++, this repository showed me there was an open door I was ignoring. I love you
why is this not there in the documentation? I feel like a couple of examples this would just make life so much easier
I don't see a definition of LIBFLAGS in the makefile. Could anyone elaborate on what that should have for a value here?
Would that just have something like "-L PathToLibsHere" as a value?
I Love you.
I love you.
One more remark:
all:
swig -c++ -python demo.i
g++ $(FLAGS) $(PYTHONI) -c demo.cpp -o demo.o
g++ $(FLAGS) $(PYTHONI) -c demo_wrap.cxx -o demo_wrap.o
g++ $(PYTHONL) -shared demo.o demo_wrap.o $(LIBFLAGS) -o _demo.so
(pay attention to the position of $(LIBFLAGS)!)
A response to partyman66: your understanding is correct. E.g. LIBFLAGS = -L/usr/local/lib -lgmpxx -lgmp at the beginning
I don't see a definition of LIBFLAGS in the makefile. Could anyone elaborate on what that should have for a value here?
Would that just have something like "-L PathToLibsHere" as a value?
i love you
i love you
I Love you.
I love u