0

I have created a small library in c++ to use it with python through ctypes. I have no problem compiling a dll, but I would like to get only a dll. In stead, I get dll, exp, iobj, ipdb, lib and pdb files. If I don't have them in the same directory, I get an error with ctypes:

Could not find module 'module_name.dll' (or one of its dependencies)

How can I make it so I only need the dll and not the other files?

Låne Book
  • 71
  • 5
  • Are you compiling in Release mode? – Casey Mar 25 '21 at 16:56
  • @Casey yes, it's on Release in the toolbar, Properties - Configuration and Properties - Configuration Manager. The result is also in a Release directory. It's x64 if that matters. – Låne Book Mar 25 '21 at 18:53
  • There should not be `.pdb` files in Release mode. The other files should exist however. – drescherjm Mar 25 '21 at 19:10
  • 2
    @LåneBook None of those other files is required at runtime. If you move the DLL to another directory and get a "*could not find module*" error, then that's probably about another DLL ("*one of its dependencies*") that you have in the build directory, or elsewhere in the PATH used when compiling. – dxiv Mar 25 '21 at 19:13
  • @dxiv When I do `DLL_PATH = "module.dll"; clib = CDLL(DLL_PATH)` it does not work, even if the dll is in the same directory, but if `DLL_PATH = "path\\to\\Release\\module.dll"` it does work – Låne Book Mar 25 '21 at 19:21
  • 1
    @LåneBook That seems to be passing the .dll name without a path, so it's a matter of how python resolves relative paths. This has nothing to do with the other .exp/.iobj/etc build files. – dxiv Mar 25 '21 at 19:27
  • @dxiv that seems to be the problen, yes. Adding the current directory makes it work. – Låne Book Mar 25 '21 at 19:31
  • The question as it is now doesn't make much sense. Those are files, some intermediary - generated during build (*.i\**), some generated by some linker settings (*.pdb* - debug information enabled), and some by the fact that your library exports something (*.lib*, *.exp*) hence you could call some function from it. If you don't need them simply ignore them (or delete them), they don't have anything to do with your problem. Please provide more details (code, other libraries that yours needs). Check https://stackoverflow.com/questions/58631512/pywin32-and-python-3-8-0, might be the same issue. – CristiFati Mar 30 '21 at 20:40

0 Answers0