Open RedMindZ opened 2 years ago
Hey @RedMindZ, can you run with options.Verbose = true
and post the output?
There you go:
Parsing libraries...
Parsed 'qpdf.lib'
Parsing code...
Compiler argument: -xc++
Compiler argument: -std=gnu++14
Compiler argument: -fno-rtti
Compiler argument: -fms-extensions
Compiler argument: -fms-compatibility
Compiler argument: -fdelayed-template-parsing
Target triple: x86_64-pc-windows-msvc
#include "..." search starts here:
#include <...> search starts here:
D:\Programing Stuff\Libraries\Qpdf\qpdf-cpp-10.6.3\include
lib\clang\14.0.0\include
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\atlmfc\include
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\winrt
End of search list.
Parsed 'qpdf\QPDF.hh'
Processing code...
Generating code...
Generated 'Std.cs'
Just to make sure, did you activate options.Verbose
or parserOptions.Verbose
, because they are two different options.
I would expect to see more output with the former, like the passes being run, which I am not seeing.
Sorry, that was parserOptions.Verbose
. This is the output:
https://gist.github.com/RedMindZ/cda8d487fc0057a171fd4628c3ca15ff
(edit: moved to gist)
Well all the QPDF C++ types are getting ignored for some reason, it may be simple but at this point I would need to set it all up and debug to figure out whats happening.
If you dont need the entire API it may be easier to write your own small wrapper / header which you can bind with CppSharp more easily. That's the approach I always recommend since binding complex C++ APIs that depend on C++ standard library is usually complex to do and takes more time.
I actually tested replacing QPDF.hh with a minimal header:
#ifndef QPDF_HH
#define QPDF_HH
class QPDF
{
public:
__declspec(dllexport) QPDF();
__declspec(dllexport) void processFile(char const* filename, char const* password = 0);
__declspec(dllexport) ~QPDF();
};
#endif // QPDF_HH
When I run the same driver with this header, ~I actually don't see any output~ no file is generated, but the output of the driver looks fine:
Parsing libraries...
Parsed 'qpdf.lib'
Parsing code...
Compiler argument: -xc++
Compiler argument: -std=gnu++14
Compiler argument: -fno-rtti
Compiler argument: -fms-extensions
Compiler argument: -fms-compatibility
Compiler argument: -fdelayed-template-parsing
Target triple: x86_64-pc-windows-msvc
#include "..." search starts here:
#include <...> search starts here:
D:\Programing Stuff\Libraries\Qpdf\qpdf-cpp-10.6.3\include
lib\clang\14.0.0\include
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\include
C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.32.31326\atlmfc\include
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\shared
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\um
C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\winrt
End of search list.
Parsed 'qpdf\QPDF-test.hh'
Processing code...
Pass 'CppSharp.Passes.ResolveIncompleteDeclsPass'
Pass 'CppSharp.Passes.IgnoreSystemDeclarationsPass'
Pass 'CppSharp.Passes.MatchParamNamesWithInstantiatedFromPass'
Pass 'CppSharp.Passes.EqualiseAccessOfOverrideAndBasePass'
Pass 'CppSharp.Passes.FlattenAnonymousTypesToFields'
Pass 'CppSharp.Passes.CheckIgnoredDeclsPass'
Pass 'CppSharp.Passes.MarkUsedClassInternalsPass'
Pass 'CppSharp.Passes.TrimSpecializationsPass'
Pass 'CppSharp.Passes.CheckAmbiguousFunctions'
Pass 'CppSharp.Passes.GenerateSymbolsPass'
Pass 'CppSharp.Passes.CheckIgnoredDeclsPass'
Pass 'CppSharp.Passes.MoveFunctionToClassPass'
Pass 'CppSharp.Passes.ValidateOperatorsPass'
Pass 'CppSharp.Passes.FindSymbolsPass'
Pass 'CppSharp.Passes.CheckMacroPass'
Pass 'CppSharp.Passes.CheckStaticClass'
Pass 'CppSharp.Passes.CheckAmbiguousFunctions'
Pass 'CppSharp.Passes.ConstructorToConversionOperatorPass'
Pass 'CppSharp.Passes.MarshalPrimitivePointersAsRefTypePass'
Pass 'CppSharp.Passes.CheckOperatorsOverloadsPass'
Pass 'CppSharp.Passes.CheckVirtualOverrideReturnCovariance'
Pass 'CppSharp.Passes.CleanCommentsPass'
Pass 'CppSharp.Passes.CheckAbiParameters'
Pass 'CppSharp.Passes.CleanInvalidDeclNamesPass'
Pass 'CppSharp.FastDelegateToDelegatesPass'
Pass 'CppSharp.Passes.FieldToPropertyPass'
Pass 'CppSharp.Passes.CheckIgnoredDeclsPass'
Pass 'CppSharp.Passes.CheckFlagEnumsPass'
Pass 'CppSharp.Passes.MakeProtectedNestedTypesPublicPass'
Pass 'CppSharp.Passes.GenerateAbstractImplementationsPass'
Pass 'CppSharp.Passes.MultipleInheritancePass'
Pass 'CppSharp.Passes.DelegatesPass'
Pass 'CppSharp.Passes.GetterSetterToPropertyPass'
Pass 'CppSharp.Passes.StripUnusedSystemTypesPass'
Pass 'CppSharp.Passes.SpecializationMethodsWithDependentPointersPass'
Pass 'CppSharp.Passes.ParamTypeToInterfacePass'
Pass 'CppSharp.Passes.CheckDuplicatedNamesPass'
Pass 'CppSharp.Passes.CaseRenamePass'
Pass 'CppSharp.Passes.CheckKeywordNamesPass'
Pass 'CppSharp.Passes.HandleVariableInitializerPass'
Pass 'CppSharp.MarkEventsWithUniqueIdPass'
Generating code...
I am not sure if I am doing something wrong here, but I believe this should be valid header that would generate at least 3 functions. How should I proceed from here?
I actually tested replacing QPDF.hh with a minimal header:
I am not sure if I am doing something wrong here, but I believe this should be valid header that would generate at least 3 functions. How should I proceed from here?
You need to make the class __declspec(dllexport), not the functions.
Brief Description
I am trying to generate C# bindings for the library qpdf but the resulting file contains non of the exported functions and classes.
OS: Windows 10 (version 10.0.19044)
Used headers
qpdf offers both a C header (with C functions) and a C++ header (with C++ classes), and both result in essentially empty files. The headers look like this:
DLL.h (shared header with dll export definitions):
qpdf-c.h (the C header, summary):
QPDF.hh (the C++ header, summary):
Used settings
My driver implementation is as follows:
Generated code
When I run my driver with the C header (qpdf-c.h) I get a nearly empty file (this is the entire file):
When I run my driver with the C++ header (QPDF.hh) only some classes from the standard library get generated, but nothing from qpdf (this is not the full file. it also contains some other classes and empty Std namespaces that I omitted):
To summarize, I don't know why my resulting files are empty. I assume I might need to add some passes to the driver, but I am not sure which, if any. If anyone could help me with this, it would be greatly appreciated.