Do you own a Debenu Quick PDF Library version 7, 8, 9, 10, 11, 12, 13 or iSEDQuickPDF license? Upgrade to Debenu Quick PDF Library 14 today!
![]() |
Setting c++ project. |
Post Reply ![]() |
Author | |
AlexA_B ![]() Beginner ![]() Joined: 08 Sep 14 Status: Offline Points: 18 |
![]() ![]() ![]() ![]() ![]() Posted: 10 Sep 14 at 6:26PM |
I have a problem creating a wrapper dll around the supplied DebenuPDFLibraryDLL1016.dll (DebenuPDFLibrary64DLL1016.dll ?)
I want to build 64 bit version.
Here's my setting, which I did according to examples provided by Debenu: 1. copy the three files shown below into the same directory as this README.txt file and add the .cpp and .h files to your project. I added * DebenuPDFLibraryDLL1016.cpp * DebenuPDFLibraryDLL1016.h into my project. 2. Add DebenuPDFLibraryDLL1016.dll into the same directory (?). Which one should I add DebenuPDFLibraryDLL1016.dll or DebenuPDFLibrary64DLL1016.dll ? 2.1. While creating the DebenuPDFLibraryDLL1016 class should I call: DebenuPDFLibraryDLL1016 QP(L"DebenuPDFLibraryDLL1016.dll"); or DebenuPDFLibraryDLL1016 QP(L"DebenuPDFLibrary64DLL1016.dll"); for 64 bit version? I think the second one. 3. I created the function, which I will call from Java: JNIEXPORT jboolean JNICALL Java_com_ricoh_mdm_mie_jniconnector_JniManager_ping (JNIEnv *env, jobject obj) { writeToLog("Ping started"); //create the library and release it // Declare and load Quick PDF Library DLL DebenuPDFLibraryDLL1016 QP(L"DebenuPDFLibrary64DLL1016.dll"); writeToLog("QP created - go to unlock"); writeToLog("Unlocked: " + QP.Unlocked()); // Library key int iResult = QP.UnlockKey(L"MY_KEY_"); writeToLog("QP unlocked"); if (iResult == 1) { writeToLog("The Debenu has been loaded. Loaded:" + QP.LibraryLoaded()); return JNI_TRUE; } else { writeToLog("The Debenu has NOT been loaded. The result is " + iResult); return JNI_FALSE; } //the library is closed in destructor } The function crushes and crush the JVM as well as soon as it came to first call of the QP. The output is: Ping started QP created - go to unlock if I comment out: //writeToLog("Unlocked: " + QP.Unlocked()); The function crushes on the next line: int iResult = QP.UnlockKey(L"MY_KEY_"); Which probably means that the DebenuPDFLibrary64DLL1016.dll was not loaded. I did not find instructions how to set the C++ project for using the Debenu DLL's. Can you please point me to the document which describes using the Debenu DLL from other DLL. Setting the C++ project, using the Debenu DLL. What compiler options I have to use to compile and run the Debenu DLL from my C++ project. I use eclipse with CDT plugin and minGW-w64 for compiling/Tool Chain Editor. |
|
![]() |
|
AlexA_B ![]() Beginner ![]() Joined: 08 Sep 14 Status: Offline Points: 18 |
![]() ![]() ![]() ![]() ![]() |
here are the linker and compiler commands, which run without problems and create the libwinwrapper.dll.
The libwinwrapper.dll is [amd64/le], as expected. g++ "-IC:\\Program Files\\Java\\jdk1.7.0_21\\include" "-IC:\\Program Files\\Java\\jdk1.7.0_21\\include\\win32" -O0 -g3 -Wall -m64 -c -fmessage-length=0 -Wno-write-strings -o DebenuPDFLibraryDLL1016.o "..\\DebenuPDFLibraryDLL1016.cpp" g++ "-IC:\\Program Files\\Java\\jdk1.7.0_21\\include" "-IC:\\Program Files\\Java\\jdk1.7.0_21\\include\\win32" -O0 -g3 -Wall -m64 -c -fmessage-length=0 -Wno-write-strings -o com_ricoh_mdm_mie_jniconnector_JniManager.o "..\\com_ricoh_mdm_mie_jniconnector_JniManager.cpp" g++ -shared -o libwinwrapper.dll com_ricoh_mdm_mie_jniconnector_JniManager.o DebenuPDFLibraryDLL1016.o |
|
![]() |
|
AlexA_B ![]() Beginner ![]() Joined: 08 Sep 14 Status: Offline Points: 18 |
![]() ![]() ![]() ![]() ![]() |
I dropped both files into System32 :
DebenuPDFLibrary64DLL1016.dll DebenuPDFLibraryDLL1016.dll and it works just fine. Unfortunately I can not drop these files into the System32 mashine, but should keep it in my own directory. So here's the problem as I understand it now: 1. My wrapper dll file and the DebenuPDFLibrary64DLL1016.dll in the same directory. 1.1. It mostly works fine , because the program checks CURRENT directory, but not in the JNI case. 1.2. In JNI case the current directory is not the one the DLL's are, BUT the directory they are called from - the directory of the Java. 1.3. In this case the call: DebenuPDFLibraryDLL1016 QP(L"DebenuPDFLibrary64DLL1016.dll"); would come to: DebenuPDFLibraryDLL1016::DebenuPDFLibraryDLL1016(const std::wstring& dllFileName) { loadError = false; instanceID = 0; dllHandle = LoadLibraryW(dllFileName.c_str()); if (dllHandle > 0) { ..... } else { loadError = true; } } No exception or error displayed to the user and this will be exactly the case I see. |
|
![]() |
|
AndrewC ![]() Moderator Group ![]() ![]() Joined: 08 Dec 10 Location: Geelong, Aust Status: Offline Points: 841 |
![]() ![]() ![]() ![]() ![]() |
Alex,
DebenuPDFLibrary64DLL1016 is the 64bti version of the DLL. It can go into C:\Windows\System32 in all cases. DebenuPDFLibraryDLL1016 is the 32bit version of the DLL and on 32bit Windows can go into C:\Windows\System32 or C:\Windows\SysWoW64 on a 64bit Windows machine. The constructor takes a full path so if you know the correct directory where the DLL is located then you will need to specify it especially if something like the JNI changes the current directory. There are some good article in the Knowledge Base on Debenu.com explaining 32 and 64 Bit DLL's and C++ etc. http://www.debenu.com/kb/category/debenu-quick-pdf-library/ The library doesn't throw exceptions which means you should check the return values of each call. QP.LibraryLoaded() is a function you may need to call. QP.LibraryVersion is helpful also. We cannot display an error message as each developer wants control over the message and language it is displayed in and doesn't go down well on a Server which is why we leave it to the developer to check return values. Andrew.
|
|
![]() |
|
AlexA_B ![]() Beginner ![]() Joined: 08 Sep 14 Status: Offline Points: 18 |
![]() ![]() ![]() ![]() ![]() |
Thanks Andrew,
I got it. I just did not know that the constructor needs the full path to the DLL. I started to investigate and sow that the JNI uses Java directory as current directory and this is why my wrapper dll could not find the DebenuPDFLibrary64DLL1016. In order to find the dll from the wrapper I used: const std::string MY_DLL_NAME("myJniWrapper.dll"); const std::string DEBENU_DLL_NAME("DebenuPDFLibrary64DLL1016.dll"); /** * Convert char* to wstring */ std::wstring ctow(const char* src) { return std::wstring(src, src + strlen(src)); } std::wstring getDllPath() { wchar_t buffer[MAX_PATH]; int size = GetModuleFileNameW(GLOBAL_CURRENT_HANDLER, buffer, MAX_PATH); char cPath[++size]; for (int i=0; i < size; i++) { cPath = buffer; if (cPath == '\\') { cPath = '/'; } } std::string sPath(cPath); int strtDll = sPath.find(MY_DLL_NAME); sPath = sPath.substr(0, strtDll); sPath.append(DEBENU_DLL_NAME); return ctow(sPath.c_str()); } Obviously my wrapper dll and the debenu dll should be always in the same directory. |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |
Copyright © 2017 Debenu. Debenu Quick PDF Library is a PDF SDK. All rights reserved. About — Contact — Blog — Support — Online Store