Operating System - OpenVMS
1753544 Members
5687 Online
108795 Solutions
New Discussion юеВ

Problem creating Shared image in C++

 
SOLVED
Go to solution
Malav
Occasional Contributor

Problem creating Shared image in C++

Hi,

I am trying to use JNI to call C++ code and it runs fine.But it gives many UNDEFINED SYMBOLS and UNDEFINED SYMBOL REFERENCES errors while linking the shared image.

I tried creating the.opt file after making changes in the Batch file available with the
JNI_EXAMPLES.BCK which is available from the Java website but still it is giving the same linking errors.

Inspite of the linking warnings the image file is created but whn i try to load it from java application it is giving an error "ident mismatch with shareable image"

can anyone help me in telling where m i going wrong ?


Programming Platform:
OpenVMS 7.3-1
Compaq C++ V6.3-020
java version 1.4.2


Regards
Malav
8 REPLIES 8
Bojan Nemec
Honored Contributor

Re: Problem creating Shared image in C++

Malav,

I have not a system with java and c++ handy, so I cant do any testing. Any way (from common VMS linking problems)you should first get rid of UNDEFINED SYMBOLS errors. These errors are most times because you forgot to link an object or shareable image into yours image. Can you give us a listing of these errors?

The "ident mismatch with shareable image" error is when the program is linked with a newest shareable image and then run with an older version of that image. Maybe you have more than one Java version on the machine?

Bojan
Ian Miller.
Honored Contributor

Re: Problem creating Shared image in C++

just a guess but you may need to specify /PREFIX=ALL when compiling.
____________________
Purely Personal Opinion
John Gillings
Honored Contributor

Re: Problem creating Shared image in C++

Malav,

Could you please post some sample messages. If the names are strange, you may have a "mangling" issue. External names for shareable images need to be unmangled.

Start with a very simple case. Just a C++ shareable image with one routine that does something like print "Hello World". Try calling that from java.

If you can't get that working, post your source code and commands here.
A crucible of informative mistakes
Hein van den Heuvel
Honored Contributor

Re: Problem creating Shared image in C++


Hi,

Be sure to check out the following topic in this conference:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=718061

Hope that helps,
Hein.
Malav
Occasional Contributor

Re: Problem creating Shared image in C++

Hi,

Thanks for ur replies. But still the problem persists.
I'll just answer all the previous posts first.

Bojan : I m using a .com file provided with JNI_EXAMPLES.BCK to create the .opt file. Also i tried manually creating the .opt file by editing the " CXX$DEMANGLER_DB. " as suggested in one of the other posts on the forum. But still the problem of Undefined Symbol remains.
Regarding Java. I have only one version installed.

Ian Miller: Yes i have included /PREFIX=ALL option while compiling.

John Gillings : I have created a sample Program and it is working fine. But in actual case there are lot many function and many more c++ files for creating the Image.

Hein: I have used the mentioned URL for creating the Shared Image.

***********************************
Following is the .Com file i use for compiling and creating the .opt file. it has reference to scan_globals_for_option.com which is the .com file provided with the JNI_EXAMPLE. and it works fine with the sample program.
************************************
$ opts = "/prefix=all /float=ieee /ieee=denorm/define=JIT_OPTION " + -
"/nowarnings /names=(short,as_is) /reentrancy=multithread /define=__US
$ cxx 'opts' 'INCL' abc.cpp
$ cxx 'opts' 'INCL' def.cpp
$ cxx 'opts' 'INCL' xyz.cpp
$ cxx 'opts' 'INCL' mno.cpp
$ GLB_OPT:= global_symbol_option
$ LIB_OPT:= library_option
$ @scan_globals_for_option *.obj 'GLB_OPT'.opt
$ OPEN/WRITE library_opt_file 'LIB_OPT'.opt
$ write library_opt_file "GSMATCH=LEQUAL,1,1"
$ write library_opt_file "abc.obj"
$ write library_opt_file "def.obj"
$ write library_opt_file "xyz.obj"
$ write library_opt_file "mno.obj"
$ write library_opt_file "SYS$SHARE:JAVA$JAVA_SHR/SHARE"
$ close library_opt_file
$ DEBUG_SWITCH := /nodebug/notrace
$ IMAGE_NAME := SharedImage
$ cxxlink 'DEBUG_SWITCH'/SHARE='IMAGE_NAME'.exe -
'LIB_OPT /OPT,'GLB_OPT /opt
*******************************************

Some of the Errors:
**************************************
%LINK-W-NUDFSYMS, 85 undefined symbols:

%LINK-I-UDFSYM, JavaLogger::JavaLogger(JNIEnv_ *, _jobject *)
%LINK-I-UDFSYM, bool JavaLogger::log(const std::basic_stringchar_traits, std::allocator > &)
%LINK-I-UDFSYM, JavaLogger::~JavaLogger()
****************************************

Regards
Malav
Craig A Berry
Honored Contributor

Re: Problem creating Shared image in C++

Malav,

You probably have more than one version of Java installed whether you know it or not. I think VMS 7.3-1 shipped with 1.1.8 or something like that, so when you installed 1.4.2 you then had two versions. Double check that you are running JAVA$SETUP.COM appropriately to get the version you want.

There are a *lot* of Java-related shareable images in SYS$SHARE. It could well be that a simple example works fine linked against nothing but JAVA$JAVA_SHR.EXE, but for your real code you may need to link against one or more other images. For example, to find which image has the JavaLogger symbol, try this:

$ search/format=nonulls sys$share:java*.exe javalogger

If you find it in an image you are not currently linking against, then add another line to your options file to include that image.

And now that I think of it, you probably want to check the logical name JAVA$JAVA_SHR and see where it's pointing. Most likely you should change your options file to simply say

JAVA$JAVA_SHR/SHARE

instead of

SYS$SHARE:JAVA$JAVA_SHR.EXE/SHARE

The latter links against a hard-coded path and very likely gives you the version of the library from system installation time rather than the latest Java upgrade. Using the logical name should give you whatever is current, plus your code should still work without relinking after a Java upgrade.

This is all somewhat speculative since I have not built any JNI applications, but just working from first principles of how shareable images are typically referenced on VMS, I think you are probably getting the wrong version of the main image or missing an auxiliary image.
Craig A Berry
Honored Contributor
Solution

Re: Problem creating Shared image in C++

OK, I've now checked on my home system where I have Java 1.4.2 installed and can confirm that if you link against the image in SYS$SHARE you are definitely getting the wrong one.

$ pipe anal/image sys$share:java$java_shr.exe | search sys$input "file ident"
image file identification: "V 1.1.8-1"
$ pipe anal/image java$java_shr | search sys$input "file ident"
image file identification: "JAVA 1.4.2-2"

$ show logical java$java_shr
"JAVA$JAVA_SHR" = "SYS$COMMON:[JAVA$142.JRE.LIB.ALPHA]JAVA$JAVA_SHR.EXE;" (LNM$PROCESS_TABLE)

So do change your .COM file as indicated in my previous post. There may be other problems but this is definitely at least part of your trouble and is causing the ident mismatch error and very likely the unresolved symbols as well.
Malav
Occasional Contributor

Re: Problem creating Shared image in C++

Thanks Craig,

I made the change in the com file and yes the "ident mismatch error" is solved.

Thank You again for ur help.

-Malav