www.digitalmars.com         C & C++   DMDScript  

c++.windows - Problem with header-file

reply davidek <david_w freenet.de> writes:
Hi!

Im a newbie to C++ and have a problem compiling with the DMC.
I included a header-file (.h) into an very simple cpp-programm.

In this file is e.g. a line like this:

int WINAPI CasioIO_RespondToReceive(HCASIOIO handle, BYTE rows, BYTE columns,
double * values);

DMC reports errors cause of an missing "," and errors cause the "*", but the
code should be correct.
Have i to change the lines for DMC? Or is this header-file-line wrong?

greetings
davidek
Jan 15 2007
parent reply Bertel Brander <bertel post4.tele.dk> writes:
davidek skrev:
 Hi!
 
 Im a newbie to C++ and have a problem compiling with the DMC.
 I included a header-file (.h) into an very simple cpp-programm.
 
 In this file is e.g. a line like this:
 
 int WINAPI CasioIO_RespondToReceive(HCASIOIO handle, BYTE rows, BYTE columns,
 double * values);
 
 DMC reports errors cause of an missing "," and errors cause the "*", but the
 code should be correct.
 Have i to change the lines for DMC? Or is this header-file-line wrong?
Do you have a decleration of HCASIOIO? I don't think it is a standard one. -- Just another homepage: http://damb.dk But it's mine - Bertel
Jan 15 2007
parent reply davidek <david_w freenet.de> writes:
The complete Header-File, which was delivered with an CasioIO.dll, is the
following: (casioio.h)

#define HCASIOIO	int

#define IOTYPE_CFX		1

#define ERR_NOTSUPPORTED	2
#define ERR_COMMPORT		4

#define TYPE_VALUE		1
#define TYPE_MATRIX		2
#define TYPE_LIST		3


typedef void (*CASIOIO_EVENT)();

int WINAPI CasioIO_Uninit();
int WINAPI CasioIO_RespondToReceive(HCASIOIO handle, BYTE rows, BYTE columns,
double * values);
int WINAPI CasioIO_AfterReceive(HCASIOIO handle, BYTE * type, BYTE * name);
int WINAPI CasioIO_AfterSend(HCASIOIO handle, BYTE * type, BYTE * name, BYTE *
rows, BYTE * columns, double * values);
int WINAPI CasioIO_Init(BYTE comport, int iotype);
HCASIOIO WINAPI CasioIO_Open(int authorID, int productID, CASIOIO_EVENT
sendproc,
CASIOIO_EVENT receiveproc);
int WINAPI CasioIO_Close(HCASIOIO handle);
Jan 16 2007
parent reply Bertel Brander <bertel post4.tele.dk> writes:
davidek skrev:
 The complete Header-File, which was delivered with an CasioIO.dll, is the
 following: (casioio.h)
 
[snip code] Do you include windows.h before casioio.h ? If not, try it. Do you have a .lib file for the dll? -- Just another homepage: http://damb.dk But it's mine - Bertel
Jan 16 2007
parent reply davidek <david_w freenet.de> writes:
Yes, i included windows.h before casioio.h.

Yes, i have a .lib file too. (It was delivered with the .dll too.)


davidek
Jan 17 2007
parent reply Bertel Brander <bertel post4.tele.dk> writes:
davidek skrev:
 Yes, i included windows.h before casioio.h.
 
 Yes, i have a .lib file too. (It was delivered with the .dll too.)
Strange. I wrote this: #include <windows.h> #include "casioio.h" HCASIOIO Handle; void SendFunc() { } void RecvFunc() { double X[] = {1, 2}; CasioIO_RespondToReceive(Handle, 2, 3, X); } int main() { CasioIO_Init(1, 0); Handle = CasioIO_Open(123, 321, SendFunc, RecvFunc); } It compiles without problems. casioio.h is a file with the content you posted. Can you post a complete example that show the problem? Can I download casioio.h/.dll/.lib ? -- Just another homepage: http://damb.dk But it's mine - Bertel
Jan 17 2007
parent reply davidek <david_w freenet.de> writes:
Hi!

The background to my problem: I started to learn java-programming. Now i want to
call functions of this dll out of java. For that i use the JNI (Java Native
Interface), which allows to use DLLs in java.

I have to call the CasioIO.dll out of an new DLL, that i try to create
(Wrapper).
But i simply dont get the DLLs functions in the cpp-programm.

At he current state the Optlink reports "Error 42: Symbol Undefined" about the
CasioIO-methods.

Here is a link to the CasioIO-download:
http://users.pandora.be/gp/casio/casioio/casioio_sdk.zip

My files are in the attachment.

Greetings
davidek
begin 644 files.zip

M;&%S<VU06TL"01 ]HZZ7S=(L[7[1"M:"I.<DB")8D`2W>O$A5IUD9)V5=1/\


MIWE9MAE2YP\A#QPN.PP+EMUTIK\VT]K\6:8\Y<1OI9JNAQ,U+CQ_2!DQRU8T

M\RNA%IGO27$?\F%XK,K2B"-!R5]B`J4T]K!/"\^ZUEL]W Y_2<YX&/(^PYSG
MNYV::`5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z&/1",G.L*2X6$\O&V']?XOH%VJUVBH;DY)P\



M`S.4JTRP()MAA'R-9=SG"T%5D6,/VL3WYX-+8L8U_'A*AB]/WBR`)1<*=-?M
M3R8PIFM: MZ8-<*:HM`VJ6(-3 >6I2N=LH1^RR3+#UN6%:\I]O.<?ES>&K].
M5]./M1N^-J$J8^YO[J9B#FO^I:*$/KWS7Z5']\P(/4?FZ?M5U=-4P;/  JL*
M>T/L794J<%, -\UDC9<- ;95CAG8E(K4F>0WI2+'3#KX[\Z`\U8HJHXUA=M4

M``````````` `````````&IA=F$O:FYI7W1E<W0N8VQA<W-02P$"%`L4````
M"`!W>C(VR:-O-H(!```A! ``$ `````````!`"````"F`0``:F%V82]J;FE?
M=&5S="YJ879A4$L!`A0+%````` `D(HR- )*MU81` ````<``!``````````
M`0` ````6`,``&-P<"]J;FE?=&5S="YC<'!02P$"%`L4````"``&>S(V9?__


`
end
Jan 18 2007
parent reply Bertel Brander <bertel post4.tele.dk> writes:
davidek skrev:
 Hi!
 
 The background to my problem: I started to learn java-programming. Now i want
to
 call functions of this dll out of java. For that i use the JNI (Java Native
 Interface), which allows to use DLLs in java.
 
 I have to call the CasioIO.dll out of an new DLL, that i try to create
(Wrapper).
 But i simply dont get the DLLs functions in the cpp-programm.
 
 At he current state the Optlink reports "Error 42: Symbol Undefined" about the
 CasioIO-methods.
You could do: #include <windows.h> #include <iostream> #include "../SDK/vc/casioio.h" #include "jni_test.h" //This includes the JNI. It is an header file created by a java-sdk-tool. typedef int WINAPI (*CasioIO_UninitPtrT)(); CasioIO_UninitPtrT CasioIO_UninitPtr; typedef int WINAPI (* CasioIO_InitPtrT)(BYTE comport, int iotype); CasioIO_InitPtrT CasioIO_InitPtr; JNIEXPORT jint JNICALL Java_jni_1test_Uninit(JNIEnv *env, jclass) { return CasioIO_UninitPtr(); } JNIEXPORT jint JNICALL Java_jni_1test_Init(JNIEnv *env, jclass cl, jshort comport, jint iotype) { return CasioIO_InitPtr(comport, iotype); } void InitPointers() { HINSTANCE Library = LoadLibrary("CasioIO.dll"); CasioIO_UninitPtr = (CasioIO_UninitPtrT )GetProcAddress(Library, "CasioIO_Uninit"); if(!CasioIO_UninitPtr) { std::cout << "Failed to find CasioIO_Uninit" << std::endl; } CasioIO_InitPtr = (CasioIO_InitPtrT )GetProcAddress(Library, "CasioIO_Init"); if(!CasioIO_InitPtr) { std::cout << "Failed to find CasioIO_Init" << std::endl; } } __declspec(dllexport) BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: InitPointers(); break; case DLL_THREAD_ATTACH: case DLL_THREAD_DETACH: case DLL_PROCESS_DETACH: break; } return TRUE; } The above code compiles and creates a jni_test.DLL with this command line: dmc -I\j2sdk1.4.2_10\include -I\j2sdk1.4.2_10\include\win32 -mn -WD jni_test.cpp kernel32.lib You need to do something else than stc::cout << "..." in case of errors. -- Just another homepage: http://damb.dk But it's mine - Bertel
Jan 18 2007
parent reply davidek <david_w freenet.de> writes:
Hi!

Thank you very much! That solution works fine! I got an value back from the
DLL-Method to the Java-App!

Thanks for the answers you wrote and for the effort!

Greetings
davidek
Jan 19 2007
parent "Terrymarfy" <terry phototocanvasprint.co.uk> writes:
On Friday, 19 January 2007 at 15:25:15 UTC, davidek wrote:
 Hi!

 Thank you very much! That solution works fine! I got an value 
 back from the
 DLL-Method to the Java-App!

 Thanks for the answers you wrote and for the effort!

 Greetings
 davidek
Just simple runway, QUAA vs ANS no relation. that's fine. ----------------------------------- [url="http://www.tocanvas.net"]cheap canvas print[/url] | [url="http://www.tocanvas.net"]photos to canvas print[/url] | [url="http://www.tocanvas.net"]canvas from photo[/url] | [url="http://www.tocanvas.net"]photos in canvas[/url]
Nov 28 2012