Print Page | Close Window

use Debenu PDF library with eclipse CDT plugin

Printed From: Debenu Quick PDF Library - PDF SDK Community Forum
Category: For Users of the Library
Forum Name: I need help - I can help
Forum Description: Problems and solutions while programming with the Debenu Quick PDF Library and Debenu PDF Viewer SDK
URL: http://www.quickpdf.org/forum/forum_posts.asp?TID=2967
Printed Date: 06 May 25 at 7:29AM
Software Version: Web Wiz Forums 11.01 - http://www.webwizforums.com


Topic: use Debenu PDF library with eclipse CDT plugin
Posted By: AlexA_B
Subject: use Debenu PDF library with eclipse CDT plugin
Date Posted: 08 Sep 14 at 8:58PM
I try to create JNI wrapper around the Debenu/PDF Library/DLL/Import/CPlusPlus.
I use the CDT plugin for eclipse with MinGW for linking and compiling my code.
All the examples I've found are done with WinAPI. 
I try very simple thing:
com_mdm_mie_jniconnector_JniManager.H file:
#include <jni.h>
/* Header for class com_ricoh_mdm_mie_jniconnector_JniManager */

#ifndef _Included_com_mdm_mie_jniconnector_JniManager
#define _Included_com_mdm_mie_jniconnector_JniManager
#ifdef __cplusplus
extern "C" {
#endif
/*
 * Class:     com_mdm_mie_jniconnector_JniManager
 * Method:    ping
 * Signature: ()Z
 */
JNIEXPORT jboolean JNICALL Java_com_mdm_mie_jniconnector_JniManager_ping
  (JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
=================
com_mdm_mie_jniconnector_JniManager.CPP file:

#include "com_ricoh_mdm_mie_jniconnector_JniManager.h"

#include "DebenuPDFLibraryDLL1016.h"
#include <string>
#include <iostream>


using namespace std;




/*
 * Class:     com_mdm_mie_jniconnector_JniManager
 * Method:    ping
 * Signature: ()Z
 */
JNIEXPORT jboolean JNICALL Java_com_mdm_mie_jniconnector_JniManager_ping
  (JNIEnv *env, jobject obj)
{
//create the library and release it
// Declare and load Quick PDF Library DLL
std::string str = "DebenuPDFLibraryDLL1016.dll";
std::wstring temp(str.length(),L' ');
std::copy(str.begin(), str.end(), temp.begin());

DebenuPDFLibraryDLL1016 QP(temp);



return JNI_TRUE;
}

Error is:
>undefined reference to `DebenuPDFLibraryDLL1016::DebenuPDFLibraryDLL1016(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)'

I tried:

DebenuPDFLibraryDLL1016 QP("DebenuPDFLibraryDLL1016.dll");
> no matching function for call to 'DebenuPDFLibraryDLL1016::DebenuPDFLibraryDLL1016(const char [28])'

DebenuPDFLibraryDLL1016 QP(L"DebenuPDFLibraryDLL1016.dll");
>undefined reference to `DebenuPDFLibraryDLL1016::DebenuPDFLibraryDLL1016(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)'

I did not find a way to link and compile the DebenuPDFLibraryDLL1016 into my application (which is dll).
Here is the command I use:
g++ "-IC:\\Program Files\\Java\\jdk1.7.0_21\\include" "-IC:\\Program Files\\Java\\jdk1.7.0_21\\include\\win32" "-IC:\\Program Files (x86)\\Debenu\\PDF Library\\DLL\\Import\\CPlusPlus" -O0 -g3 -Wall -c -fmessage-length=0 -o com_mdm_mie_jniconnector_JniManager.o "..\\com_mdm_mie_jniconnector_JniManager.cpp" 
g++ -shared -o libwinwrapper.dll com_mdm_mie_jniconnector_JniManager.o 

For now it seems I can not create the const std::wstring as it is declared by the constractor:
DebenuPDFLibraryDLL1016(const std::wstring& dllFileName);

Please help.





Replies:
Posted By: AlexA_B
Date Posted: 08 Sep 14 at 9:14PM
I tried the following:
std::wstring lib;
lib.append(L"DebenuPDFLibraryDLL1016.dll");

DebenuPDFLibraryDLL1016 QP(lib);

still no luck:
>>
C:\Tmp\Osgi\winwrapper\Debug/../com_mdm_mie_jniconnector_JniManager.cpp:37: undefined reference to `DebenuPDFLibraryDLL1016::DebenuPDFLibraryDLL1016(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)'
C:\Tmp\Osgi\winwrapper\Debug/../com_mdm_mie_jniconnector_JniManager.cpp:37: undefined reference to `DebenuPDFLibraryDLL1016::~DebenuPDFLibraryDLL1016()'
collect2.exe: error: ld returned 1 exit status



Posted By: AlexA_B
Date Posted: 09 Sep 14 at 2:14PM
I believe that the problem is linking the dll's into my project.
Here's the steps I did:
1. copied 
C:\Program Files (x86)\Debenu\PDF Library\DLL
into
C:\Debenu
directory, so the path does not have any white spaces.
2. created the following link command:
g++ "-LC:\\Debenu\\DLL" -shared -o libwinwrapper.dll com_ricoh_mdm_mie_jniconnector_JniManager.o -lDebenuPDFLibraryDLL1016

I did it according to the following page:
http://www.mingw.org/wiki/Specify_the_libraries_for_the_linker_to_use" rel="nofollow - http://www.mingw.org/wiki/Specify_the_libraries_for_the_linker_to_use

Unfortunately it still does not work. I got the following error:

C:\Tmp\Osgi\winwrapper\Debug/../com_mdm_mie_jniconnector_JniManager.cpp:37: undefined reference to `DebenuPDFLibraryDLL1016::DebenuPDFLibraryDLL1016(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&)'
C:\Tmp\Osgi\winwrapper\Debug/../com_ricoh_mdm_mie_jniconnector_JniManager.cpp:37: undefined reference to `DebenuPDFLibraryDLL1016::~DebenuPDFLibraryDLL1016()'
collect2.exe: error: ld returned 1 exit status

Can I find the setting for the C++ debenu dll libraries ? Should I include both:
DebenuPDFLibrary64DLL1016  and DebenuPDFLibraryDLL1016 with "-l" option ?
Should I include the directory "-L" option ?



Posted By: AlexA_B
Date Posted: 09 Sep 14 at 4:04PM
Found my problem.
Add the 
* DebenuPDFLibraryDLL1016.cpp
* DebenuPDFLibraryDLL1016.h
into your project. Do not just include them in the compiler , but physically copy them in the same dirsctory.

PS: during compilation it gives hundreds of warnings:

"warning: deprecated conversion from string constant to ‘char*’"

you will have to add the following option to compiler to suppress them all:

-Wno-write-strings

Regards

  




Print Page | Close Window

Forum Software by Web Wiz Forums® version 11.01 - http://www.webwizforums.com
Copyright ©2001-2014 Web Wiz Ltd. - http://www.webwiz.co.uk