Getting Started
Hello, <br /><br />I just started to look at the SDK and to be honest my C/C++ Programming skills have not been used in years (do majority of my work in Java these days). I was thinking of taking a crack at using JNI wrappers so that I could use the SDK via Java. However, I seem to get some linking errors when writting even a basic C++ program that calls some of the PM3 functions? <br /><br />#include <stdio.h><br />#include "PM3DDI.h"<br />#include "PM3USB.h"<br /><br />void getVersionNumber(void) {<br /><br /> tkcmdsetDDI_init();<br /> printf("hello");<br /> return;<br />}<br /><br />void main() {<br /><br /> getVersionNumber();<br />}<br /><br />When I compile this (using Borland bcc32) I get the following linking errors.<br /><br />C:\Java\Concept2\PC\PM3API_Release_1.22>bcc32 test.cpp<br />Borland C++ 5.5.1 for Win32 Copyright © 1993, 2000 Borland<br />test.cpp:<br />Turbo Incremental Link 5.00 Copyright © 1997, 2000 Borland<br />Error: Unresolved external 'tkcmdsetDDI_init()' referenced from C:\JAVA\CONCEPT2\PC\PM3API_RELEASE_1.22\TEST.OBJ<br /><br />I do have the paths setup correctly I believe.<br /><br />My bcc32.cfg file has these two entries<br />-I"C:\Program Files\Borland\Bcc55\include;C:\Java\Concept2\PC\PM3API_Release_1.22;C:\Java\j2sdk1.4.2_05\include;C:\Java\j2sdk1.4.2_05\include\win32"<br />-L"C:\Program Files\Borland\Bcc55\lib;C:\Java\Concept2\PC\PM3API_Release_1.22"<br /><br />Can anyone point me in the right direction (I apologize in advance if I'm doing something dumb).<br /><br />Joe<br /><br />
There will be a lib file for the sdk that you need to include as an input to the linker.<br /><br />That is what it is complaining about,<br /><br /><!--QuoteBegin--><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><div class='genmed'><b>QUOTE</b></div></td></tr><tr><td class='quote'><!--QuoteEBegin-->Error: Unresolved external 'tkcmdsetDDI_init() </td></tr></table><br /><br />It's saying that it's external and unresolvable. It does not know where the function 'tkcmdsetDDI_init()' lives, and you need to tell it via the lib file.<br /><br />Sorry, don't know Borland compiler very well.<br />
<!--QuoteBegin-jmcmaster+Jan 25 2005, 10:33 PM--><table border='0' align='center' width='95%' cellpadding='3' cellspacing='1'><tr><td><div class='genmed'><b>QUOTE(jmcmaster @ Jan 25 2005, 10:33 PM)</b></div></td></tr><tr><td class='quote'><!--QuoteEBegin-->I do have the right directories referenced for the lib files.<br /> </td></tr></table><br /><br />Unlike Java, you'll need to explicitly tell the C++ linker which libraries to link your code with. As "#include" isn't as automatic as Java's "import".<br /><br />"bcc32 pm3.cpp RPPM3DDI.lib"<br /><br /><br />Assuming, you have your directories set up, you shouldn't get the unresolved external symbol error. You probably WILL get an error about OMF and COFF. <br /><br />The PM3 SDK was built using Visual C++ and as a result its library files are in a format (COFF) that isn't compatible with Borland C++ 5.5 (OMF). There are utilities to convert (coff2omf.exe), but I've always found them to work intermittently if ever.<br /><br />I would try going the Visual C++ route if you can, as I think it will save you a lot of headaches. You can usually find a copy of Visual C++ 5 or 6 cheap on eBay.<br /><br />Other options are to research using COFF libraries with Borland, or see if a gcc port like MinGW will work.
-
- Posts: 0
- Joined: March 18th, 2006, 10:32 pm
Hi,<br /><br />Look at both the PM3DDI.h and the PM3Csafe.h, in those files there is a microsoft specific define required to make the DLL function in borland.<br /><!--c1--><table width='95%' cellspacing='1' cellpadding='3' border='0' align='center'><tr><td><b><div class='genmed'>CODE</div></b></td></tr><tr><td class='code'><div><!--ec1--><br />#ifdef _MSC_VER<br /> #ifdef PM3USB_EXPORTS<br /> #define PM3USB_API extern "C" __declspec(dllexport)<br /> #else<br /> #define PM3USB_API extern "C" __declspec(dllimport)<br /> #endif<br />#else<br /> #define PM3USB_API<br />#endif<br /><!--c2--></div></td></tr></table><br />To let it work with borland you'll have to define the <b>_MSC_VER</b> and the <b>PM3CSAFE_EXPORTS</b> variabele (the latter for DLL functionality). The code (for the DDI code) would look something like this:<br /><!--c1--><table width='95%' cellspacing='1' cellpadding='3' border='0' align='center'><tr><td><b><div class='genmed'>CODE</div></b></td></tr><tr><td class='code'><div><!--ec1--><br />#ifndef _MSC_VER<br /> #define _MSC_VER<br />#endif<br />#ifndef PM3CSAFE_EXPORTS<br /> #define PM3CSAFE_EXPORTS<br />#endif<br />#include "PM3DDI.h"<br /><!--c2--></div></td></tr></table><br />If you want to use Borland you also have to convert the library files (RPPM3DDI.LIB and RPPM3Csafe.LIB) to the borland format using the COFF2OMF.EXE in the BIN directory of the Borland compiler.<br /><br />Hope this helps... and makes sense...<br /><br />cheers, Herman van Hovell