sattu
6th May 2011, 12:34
Hi everyone,
I am creating a simple shared library which contains the following files:
mylib.h and mylib.cpp
the code for mylib.pro is:
QT -= gui
TARGET = myLIB
TEMPLATE = lib
SOURCES += mylib.cpp
HEADERS += mylib.h
the code for mylib.h is:
#ifndef MYLIB_H
#define MYLIB_H
extern "C"{
__declspec(dllexport) int __stdcall hello();
}
#endif // MYLIB_H
the code for mylib.cpp is:
#include "mylib.h"
__declspec(dllexport) int __stdcall hello()
{
return 56;
hello() is a simple function which returns 56
}
After building the project, i am getting a myLIB.dll file in debug directory. I am able to use this DLL in a visual C# project by referencing to the DLL in C# code.
But i am not able to use the hello() function of the DLL in java.
So, can anyone please tell me the correct way of creating a DLL in Qt, which i can further use in Java? :confused:
Thanks in advance,
With regards,
Satya Prakash.
I am creating a simple shared library which contains the following files:
mylib.h and mylib.cpp
the code for mylib.pro is:
QT -= gui
TARGET = myLIB
TEMPLATE = lib
SOURCES += mylib.cpp
HEADERS += mylib.h
the code for mylib.h is:
#ifndef MYLIB_H
#define MYLIB_H
extern "C"{
__declspec(dllexport) int __stdcall hello();
}
#endif // MYLIB_H
the code for mylib.cpp is:
#include "mylib.h"
__declspec(dllexport) int __stdcall hello()
{
return 56;
hello() is a simple function which returns 56
}
After building the project, i am getting a myLIB.dll file in debug directory. I am able to use this DLL in a visual C# project by referencing to the DLL in C# code.
But i am not able to use the hello() function of the DLL in java.
So, can anyone please tell me the correct way of creating a DLL in Qt, which i can further use in Java? :confused:
Thanks in advance,
With regards,
Satya Prakash.