bilbobaggio
Technical User
Hi,
I have a class called myClass and i compile for use with jni using the following 'cl -Ic:\program*\Java\jdk1.5.0_01\include -Ic:\program*\Java\jdk1.5.0_01\include\win32 -LD myClassImpl.cpp -FemyClass.dll'
myClassImpl.cpp implements the native call to getNum.
class myClass {
private:
int num;
public:
myClass() { num = 7; }
~myClass() {}
int getNum() { return num; }
};
My problem is that when myClass is implemented in a single file as above everything works fine. But when i separate myClass to have a header file (myClass.h) and a .cpp file implementing the constructor and getNum methods I get the following error when compiling with 'cl' as above:
/dll
/implib:myClass.lib
/out:myClass.dll
myClassImpl.obj
Creating library myClass.lib and object myClass.exp
myClassImpl.obj : error LNK2001: unresolved external symbol "public: __thiscall myClass::myClass(void)" (??0SingleInt@@QAE@XZ)
myClass.dll : fatal error LNK1120: 1 unresolved externals
I have looked for an answer on the web and what people seem to say is that this is plainly a c/c++ linker problem and nothing to do with the jni part.
Thanks for any assistance.
I have a class called myClass and i compile for use with jni using the following 'cl -Ic:\program*\Java\jdk1.5.0_01\include -Ic:\program*\Java\jdk1.5.0_01\include\win32 -LD myClassImpl.cpp -FemyClass.dll'
myClassImpl.cpp implements the native call to getNum.
class myClass {
private:
int num;
public:
myClass() { num = 7; }
~myClass() {}
int getNum() { return num; }
};
My problem is that when myClass is implemented in a single file as above everything works fine. But when i separate myClass to have a header file (myClass.h) and a .cpp file implementing the constructor and getNum methods I get the following error when compiling with 'cl' as above:
/dll
/implib:myClass.lib
/out:myClass.dll
myClassImpl.obj
Creating library myClass.lib and object myClass.exp
myClassImpl.obj : error LNK2001: unresolved external symbol "public: __thiscall myClass::myClass(void)" (??0SingleInt@@QAE@XZ)
myClass.dll : fatal error LNK1120: 1 unresolved externals
I have looked for an answer on the web and what people seem to say is that this is plainly a c/c++ linker problem and nothing to do with the jni part.
Thanks for any assistance.