python_example icon indicating copy to clipboard operation
python_example copied to clipboard

[Question] ImportError: DLL load failed while importing

Open mquasar opened this issue 4 years ago • 2 comments

I'm getting this error trying to use a C++ module that calls a third-party library to return a boolean value. If I simply return true all works well. But when I call the thid-party function I get the ImportError.

#include <RecFusion.h>
#include <pybind11/pybind11.h>

using namespace RecFusion;

bool isValidLicense() {
	return RecFusionSDK::setLicenseFile("License.dat");
	//return true;
}

namespace py = pybind11;

PYBIND11_MODULE(recfusionbind, m) {
	m.def("isValidLicense", &isValidLicense, R"pbdoc(
		Check if there is a valid license file.
	)pbdoc");

#ifdef VERSION_INFO
	m.attr("__version__") = VERSION_INFO;
#else
	m.attr("__version__") = "dev";
#endif
}

Here is the header of setLicenseFile:

static bool setLicenseFile (const char *filename)

I'm using VS 2019. Any help would be greatly appreciated.

mquasar avatar Mar 18 '21 01:03 mquasar

You need to link with dependencies. There's probably some DLL or static lib in RecFusionSDK that you need to link to. Something like this: https://stackoverflow.com/a/49139257/2402816 perhaps.

henryiii avatar Mar 19 '21 13:03 henryiii

You need to link with dependencies. There's probably some DLL or static lib in RecFusionSDK that you need to link to. Something like this: https://stackoverflow.com/a/49139257/2402816 perhaps.

Thanks, I was already investigating along those lines. The thing is that, like you said, the RecFusionSDK, in order to work, needs a lot of DLLs to be put in the same folder as the python script. And I had removed a few of them because I thought they'd only be required if you actually used them in your code, Qt5, for instance.

Anyway, thanks for your reply, it really helped me close in on the problem and solve it.

mquasar avatar Mar 22 '21 00:03 mquasar