Reputation: 109
This is the structure of my program:
I'm trying to bind my program in C++ with a GUI in python. I'm using pybind11 and I have a python_binding.cpp file for the bind and some ".h" and ".cpp" with the methods in other directories. I include the ".h" files but somehow the python_binding.cpp it's not able to recognize them.
The file config.cpp only has one void method, "cargar_configuracion()" and this is how it looks like in the binding:
#include "Ejemplo/config.h"
PYBIND11_MODULE(Example, m) {
m.doc() = "Binding"; // optional module docstring
m.def("cargar_configuracion", &cargar_configuracion);
The result of this is the following error:
undefined reference to `cargar_configuracion()'
What am I doing wrong? Should I have my .cpp and .h with the binding.cpp in the same directory?
Thanks in advance!
Upvotes: 0
Views: 508
Reputation: 967
Your pybind11 looks fine, this is a linker error. It looks like config.cpp
is in another project within your solution, and is being built within a separate executable. You have two options here, either copy config.cpp into the same directory or reconfigure Ejemplo
to be a static library and specify it as a dependency in the properties of the python wrapper project.
Upvotes: 2
Reputation: 2814
Change your code from:
bViewResult = QtWidgets.QPushButton('View Results', self)
bViewResult.clicked.connect(self.openCSV)
to:
bViewResult = QtWidgets.QPushButton('View Results', self)
bViewResult.clicked.connect(cargar_configuracion())
Upvotes: 0