Unresolved external symbol errors when linking example native c++ code that uses jcc

2010-10-21 Thread Imre András
Hi list,

I intend to use jcc to ease calling Java code from native code. I managed to 
build and install it. Now I try to build my first test code from within MS VS 
2010 Win32 console app project. Despite setting up the libs and includes I 
still get linker errors:

--
Link:
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\link.exe 
/ERRORREPORT:PROMPT 
/OUT:"C:\out\app\PeldaProgram\ZipBe\bin\test\src\Debug\jcc.exe" /INCREMENTAL 
/NOLOGO python27.lib _jcc.lib jvm.lib kernel32.lib user32.lib gdi32.lib 
winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib 
uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib 
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib 
odbc32.lib odbccp32.lib /MANIFEST 
/ManifestFile:"Debug\jcc.exe.intermediate.manifest" 
/MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG 
/PDB:"C:\out\app\PeldaProgram\ZipBe\bin\test\src\Debug\jcc.pdb" 
/SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT 
/IMPLIB:"C:\out\app\PeldaProgram\ZipBe\bin\test\src\Debug\jcc.lib" /MACHINE:X86 
Debug\jcc.exe.embed.manifest.res
Debug\jcc.obj
Debug\stdafx.obj
Debug\__wrap__.obj
Creating library C:\out\app\PeldaProgram\ZipBe\bin\test\src\Debug\jcc.lib and 
object C:\out\app\PeldaProgram\ZipBe\bin\test\src\Debug\jcc.exp
1>jcc.obj : error LNK2001: unresolved external symbol "unsigned long VM_ENV" 
(?VM_ENV@@3KA)
1>stdafx.obj : error LNK2001: unresolved external symbol "unsigned long VM_ENV" 
(?VM_ENV@@3KA)
1>__wrap__.obj : error LNK2001: unresolved external symbol "unsigned long 
VM_ENV" (?VM_ENV@@3KA)
1>jcc.obj : error LNK2001: unresolved external symbol "class JCCEnv * env" 
(?env@@3PAVJCCEnv@@A)
1>stdafx.obj : error LNK2001: unresolved external symbol "class JCCEnv * env" 
(?env@@3PAVJCCEnv@@A)
1>__wrap__.obj : error LNK2001: unresolved external symbol "class JCCEnv * env" 
(?env@@3PAVJCCEnv@@A)
1>C:\out\app\PeldaProgram\ZipBe\bin\test\src\Debug\jcc.exe : fatal error 
LNK1120: 2 unresolved externals
1>Done Building Project 
"C:\out\app\PeldaProgram\ZipBe\bin\test\jcc\jcc.vcxproj" (rebuild target(s)) -- 
FAILED.

Build FAILED.

Time Elapsed 00:00:12.60
--


jni.h and Native2Java.h (jcc generated from the java class I intend to use in 
native c++ code) is added to stdafx.h. Now I have no idea where the above 
symbols come from, and how should I resolve them.


Regards,
András



Re: Unresolved external symbol errors when linking example native c++ code that uses jcc

2010-10-21 Thread Christian Heimes
Am 21.10.2010 13:39, schrieb Imre András:
> Hi list,
> 
> I intend to use jcc to ease calling Java code from native code. I managed to 
> build and install it. Now I try to build my first test code from within MS VS 
> 2010 Win32 console app project. Despite setting up the libs and includes I 
> still get linker errors:

This may not be related to your problem but MS VS 2010 is not supported
by any current Python release. You have to use VS 2008.

Christian


Re: Unresolved external symbol errors when linking example native c++ code that uses jcc

2010-10-21 Thread Andi Vajda


On Oct 21, 2010, at 4:39, Imre András  wrote:


Hi list,

I intend to use jcc to ease calling Java code from native code. I  
managed to build and install it. Now I try to build my first test  
code from within MS VS 2010 Win32 console app project. Despite  
setting up the libs and includes I still get linker errors:


I'm not sure this link line makes sense. To get an idea of what the  
correct link line looks like, get jcc to build a python extension and  
take a close look at the link line it generates as an example for your  
C++ only case.


Andi..




--
Link:
C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\link.exe / 
ERRORREPORT:PROMPT /OUT:"C:\out\app\PeldaProgram\ZipBe\bin\test\src 
\Debug\jcc.exe" /INCREMENTAL /NOLOGO python27.lib _jcc.lib jvm.lib  
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib  
advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib  
odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib  
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  
uuid.lib odbc32.lib odbccp32.lib /MANIFEST /ManifestFile:"Debug 
\jcc.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker'  
uiAccess='false'" /DEBUG /PDB:"C:\out\app\PeldaProgram\ZipBe\bin\test 
\src\Debug\jcc.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE / 
NXCOMPAT /IMPLIB:"C:\out\app\PeldaProgram\ZipBe\bin\test\src\Debug 
\jcc.lib" /MACHINE:X86 Debug\jcc.exe.embed.manifest.res

Debug\jcc.obj
Debug\stdafx.obj
Debug\__wrap__.obj
Creating library C:\out\app\PeldaProgram\ZipBe\bin\test\src\Debug 
\jcc.lib and object C:\out\app\PeldaProgram\ZipBe\bin\test\src\Debug 
\jcc.exp
1>jcc.obj : error LNK2001: unresolved external symbol "unsigned long  
VM_ENV" (?VM_ENV@@3KA)
1>stdafx.obj : error LNK2001: unresolved external symbol "unsigned  
long VM_ENV" (?VM_ENV@@3KA)
1>__wrap__.obj : error LNK2001: unresolved external symbol "unsigned  
long VM_ENV" (?VM_ENV@@3KA)
1>jcc.obj : error LNK2001: unresolved external symbol "class JCCEnv  
* env" (?env@@3PAVJCCEnv@@A)
1>stdafx.obj : error LNK2001: unresolved external symbol "class  
JCCEnv * env" (?env@@3PAVJCCEnv@@A)
1>__wrap__.obj : error LNK2001: unresolved external symbol "class  
JCCEnv * env" (?env@@3PAVJCCEnv@@A)
1>C:\out\app\PeldaProgram\ZipBe\bin\test\src\Debug\jcc.exe : fatal  
error LNK1120: 2 unresolved externals
1>Done Building Project "C:\out\app\PeldaProgram\ZipBe\bin\test\jcc 
\jcc.vcxproj" (rebuild target(s)) -- FAILED.


Build FAILED.

Time Elapsed 00:00:12.60
--


jni.h and Native2Java.h (jcc generated from the java class I intend  
to use in native c++ code) is added to stdafx.h. Now I have no idea  
where the above symbols come from, and how should I resolve them.



Regards,
András



Re: Unresolved external symbol errors when linking example native c++ code that uses jcc

2010-10-22 Thread Imre András
Hi,

Ok, thanks. After resolving this I got the following error:
jcc.cpp(294) : error C2039: 'fromJString' : is not a member of 'JCCEnv'

As I see this method is present in JCCEnv.h, but an #ifdef PYTHON directive 
prevents to make it available for the tier code I intended to write which would 
have been based on the jcc generated stub.



I am evaluating JNI wrappers. Our dev team need a layer that would ease calling 
java code from native code. It also must have a clear and documented interface, 
and should work with a trivial minimal example (Only one class, contains a 
static and a normal method.)

No offense, but my opinion is that jcc is nice stuff, and surely makes 
available Lucene for Python developers, but in its current state it seems to be 
not suited for such a general-purpose JNI wrapper. Integration should be 
staright, easy and straightforward, no matter what IDE or compiler used.

I would suggest to go for setting up a minimal non-Python example that 
demonstrates an example C++ code which calls java - in a clear and separate 
environment (simulating the end user's). This will surely bring up the issues - 
some of them I have tackled, but unfortunately I ran out of time...


Thanks for the help. jcc will be on my watch list :)

Best regards,
  András


Andi Vajda  írta:
>>
On Thu, 21 Oct 2010, Imre András wrote:>
>
> JCCEnv.h has the following:>
>>
> ...>
> #ifdef _jcc_shared>
> _DLL_IMPORT extern JCCEnv *env;>
> _DLL_IMPORT extern DWORD VM_ENV;>
> #else>
> _DLL_EXPORT extern JCCEnv *env;>
> _DLL_EXPORT extern DWORD VM_ENV;>
> #endif>
> ...>
>>
> I suspect here is the root of my linker problem. Where should this *env >
> get resolved?>
>
These are in JCCEnv.cpp and jcc.cpp which gets linked with your shared >
library either dynamically (when using --shared) or statically.>
>
You need to link a piece of jcc itself with your code. To get an example >
link line, ask jcc to create a python extension for you, a correct link line >
flies by.>
>
Andi..>
>
>>
>>
> Thanks,>
>  András>
>>
>>
> "Imre András"  írta:>
>> Hi list,>>
>>>
> I intend to use jcc to ease calling Java code from native code. I managed to 
> build and install it. Now I try to build my first test code from within MS VS 
> 2010 Win32 console app project. Despite setting up the libs and includes I 
> still get linker errors:>>
>>>
> -->>
> Link:>>
> C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\link.exe 
> /ERRORREPORT:PROMPT 
> /OUT:"C:\out\app\PeldaProgram\ZipBe\bin\test\src\Debug\jcc.exe" /INCREMENTAL 
> /NOLOGO python27.lib _jcc.lib jvm.lib kernel32.lib user32.lib gdi32.lib 
> winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib 
> uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib 
> winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib 
> uuid.lib odbc32.lib odbccp32.lib /MANIFEST 
> /ManifestFile:"Debug\jcc.exe.intermediate.manifest" 
> /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /DEBUG 
> /PDB:"C:\out\app\PeldaProgram\ZipBe\bin\test\src\Debug\jcc.pdb" 
> /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT 
> /IMPLIB:"C:\out\app\PeldaProgram\ZipBe\bin\test\src\Debug\jcc.lib" 
> /MACHINE:X86 Debug\jcc.exe.embed.manifest.res>>
> Debug\jcc.obj>>
> Debug\stdafx.obj>>
> Debug\__wrap__.obj>>
> Creating library C:\out\app\PeldaProgram\ZipBe\bin\test\src\Debug\jcc.lib and 
> object C:\out\app\PeldaProgram\ZipBe\bin\test\src\Debug\jcc.exp>>
> 1>jcc.obj : error LNK2001: unresolved external symbol "unsigned long VM_ENV" 
> (?VM_ENV@@3KA)>>
> 1>stdafx.obj : error LNK2001: unresolved external symbol "unsigned long 
> VM_ENV" (?VM_ENV@@3KA)>>
> 1>__wrap__.obj : error LNK2001: unresolved external symbol "unsigned long 
> VM_ENV" (?VM_ENV@@3KA)>>
> 1>jcc.obj : error LNK2001: unresolved external symbol "class JCCEnv * env" 
> (?env@@3PAVJCCEnv@@A)>>
> 1>stdafx.obj : error LNK2001: unresolved external symbol "class JCCEnv * env" 
> (?env@@3PAVJCCEnv@@A)>>
> 1>__wrap__.obj : error LNK2001: unresolved external symbol "class JCCEnv * 
> env" (?env@@3PAVJCCEnv@@A)>>
> 1>C:\out\app\PeldaProgram\ZipBe\bin\test\src\Debug\jcc.exe : fatal error 
> LNK1120: 2 unresolved externals>>
> 1>Done Building Project 
> "C:\out\app\PeldaProgram\ZipBe\bin\test\jcc\jcc.vcxproj" (rebuild target(s)) 
> -- FAILED.>>
>>>
> Build FAILED.>>
>>>
> Time Elapsed 00:00:12.60>>
> -->>
>>>
>>>
> jni.h and Native2Java.h (jcc generated from the java class I intend to use in 
> native c++ code) is added to stdafx.h. Now I have no idea where the above 
> symbols come from, and how should I resolve them.>>
>>>
>>>
> Regards,>>
> András>>
>>>
>>
>


Re: Unresolved external symbol errors when linking example native c++ code that uses jcc

2010-10-24 Thread Imre András
Hi Andi,

Sorry, I do not get your point. There was no error for jcc generating the code 
that wraps Native2Java.class. The problem occurs during linking some client 
code which uses this generated wrapper. Do I miss something here?

Any tips where these symbols may emerge from? I really could not track or see 
them referenced in JCCEnv.cpp, really.

Thanks,
  András


Andi Vajda  írta:
>>
On Oct 21, 2010, at 4:39, Imre András  wrote:>
>
> Hi list,>
>>
> I intend to use jcc to ease calling Java code from native code. I  >
> managed to build and install it. Now I try to build my first test  >
> code from within MS VS 2010 Win32 console app project. Despite  >
> setting up the libs and includes I still get linker errors:>
>
I'm not sure this link line makes sense. To get an idea of what the  >
correct link line looks like, get jcc to build a python extension and  >
take a close look at the link line it generates as an example for your  >
C++ only case.>
>
Andi..>
>
>
>>
> -->
> Link:>
> C:\Program Files\Microsoft Visual Studio 10.0\VC\bin\link.exe / >
> ERRORREPORT:PROMPT /OUT:"C:\out\app\PeldaProgram\ZipBe\bin\test\src >
> \Debug\jcc.exe" /INCREMENTAL /NOLOGO python27.lib _jcc.lib jvm.lib  >
> kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib  >
> advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib  >
> odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib  >
> comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib  >
> uuid.lib odbc32.lib odbccp32.lib /MANIFEST /ManifestFile:"Debug >
> \jcc.exe.intermediate.manifest" /MANIFESTUAC:"level='asInvoker'  >
> uiAccess='false'" /DEBUG /PDB:"C:\out\app\PeldaProgram\ZipBe\bin\test >
> \src\Debug\jcc.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE / >
> NXCOMPAT /IMPLIB:"C:\out\app\PeldaProgram\ZipBe\bin\test\src\Debug >
> \jcc.lib" /MACHINE:X86 Debug\jcc.exe.embed.manifest.res>
> Debug\jcc.obj>
> Debug\stdafx.obj>
> Debug\__wrap__.obj>
> Creating library C:\out\app\PeldaProgram\ZipBe\bin\test\src\Debug >
> \jcc.lib and object C:\out\app\PeldaProgram\ZipBe\bin\test\src\Debug >
> \jcc.exp>
> 1>jcc.obj : error LNK2001: unresolved external symbol "unsigned long  >
> VM_ENV" (?VM_ENV@@3KA)>
> 1>stdafx.obj : error LNK2001: unresolved external symbol "unsigned  >
> long VM_ENV" (?VM_ENV@@3KA)>
> 1>__wrap__.obj : error LNK2001: unresolved external symbol "unsigned  >
> long VM_ENV" (?VM_ENV@@3KA)>
> 1>jcc.obj : error LNK2001: unresolved external symbol "class JCCEnv  >
> * env" (?env@@3PAVJCCEnv@@A)>
> 1>stdafx.obj : error LNK2001: unresolved external symbol "class  >
> JCCEnv * env" (?env@@3PAVJCCEnv@@A)>
> 1>__wrap__.obj : error LNK2001: unresolved external symbol "class  >
> JCCEnv * env" (?env@@3PAVJCCEnv@@A)>
> 1>C:\out\app\PeldaProgram\ZipBe\bin\test\src\Debug\jcc.exe : fatal  >
> error LNK1120: 2 unresolved externals>
> 1>Done Building Project "C:\out\app\PeldaProgram\ZipBe\bin\test\jcc >
> \jcc.vcxproj" (rebuild target(s)) -- FAILED.>
>>
> Build FAILED.>
>>
> Time Elapsed 00:00:12.60>
> -->
>>
>>
> jni.h and Native2Java.h (jcc generated from the java class I intend  >
> to use in native c++ code) is added to stdafx.h. Now I have no idea  >
> where the above symbols come from, and how should I resolve them.>
>>
>>
> Regards,>
> András>
>>



Re: Unresolved external symbol errors when linking example native c++ code that uses jcc

2010-10-27 Thread Imre András


Andi Vajda  írta:
>
Using JCC in your project is a two-step process. First get JCC to generate >
the C++ wraper code for the Java code you want access to. This is, >
hopefully, well documented on the JCC site [1]. Then take that generated >
code tree and the necessary JCC runtime source files [2] and add them to >
your project's build. Any file that includes  unconditionally is >
not part of the code you should include.>

This step is ok.


>
The last problem you found has to do with the fact that the env global >
variable is declared in a file only needed by the Python runtime; jcc.cpp >
should not be included in your project and you need to declare that global >
in code of yours instead.>
>

In addition to files mentioned under [2], it seems that JArray.h is also needed.
As I see JCCEnv.h dllexports JCCEnv *env (_jcc_shared is not defined). The link 
target for my code is an exe, and I keep getting unresolved external symbol 
errors for "class JCCEnv * env".

At first I tried to hack around, and modify the *env ptr definition (strip the 
dll export), but that resulted in "already defined" errors. I guess the last 
chance is to create a separate project for jcc runtime and its generated code 
with a dll target. Then I would use that with dllimport in the code that uses 
that layer.


Regards,
  András

...
Cheers !>
>
Andi..>
>
[1] http://lucene.apache.org/pylucene/jcc/documentation/readme.html>
[2] JObject.cpp, JCCEnv.cpp, JCCEnv.h>
[3] http://java.sun.com/docs/books/jni/html/invoke.html