For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

package structure and Java Native "UnsatisfiedLinkError" problem

Davis's picture
Forums: 

hi;

I'm a student trying to use OCC for my graduate research work. I'm having a problem loading OCC DLL's and property files in my application. I am working in a Windows environment with the latest version of OCC, and Java 1.5.0-6.

I started my work with OCC by taking the sources from the sample OCC Java application and moved them into an empty Netbeans project structure. Many of the Java classes and properties files provided in the OCC samples are in the "default package". If I leave the Java classes as they were provided, I can compile and run the application without any problem. However, if I move the Java classes into a proper package heirarchy, I am no longer able to run the application because Java can not load the OCC DLLs or find the properties files.

For example ... I start with the Java samples as they are provided, then move the subfolder "SamplesTopologyJni" into org.opencascade.SamplesTopologyJni. When I run the application, it is no longer able to find the Native library referenced by SamplesTopologyPackage.java

Exception in thread "main" java.lang.UnsatisfiedLinkError: CreateViewer
at org.opencascade.SamplesTopologyJni.SamplesTopologyPackage.CreateViewer(Native Method)
at SampleTopologyPrimitivesPanel.createViewPanel(SampleTopologyPrimitivesPanel.java:90)
at SamplePanel.jbInit(SamplePanel.java:56)
at SamplePanel.(SamplePanel.java:33)
at SamplePanel.(SamplePanel.java:26)
at SampleTopologyPrimitivesPanel.(SampleTopologyPrimitivesPanel.java:68)
at SamplesTopologyPanel.(SamplesTopologyPanel.java:38)
at SamplesStarter.(SamplesStarter.java:85)
at SamplesStarter.main(SamplesStarter.java:235)

I've spent a number of days now trying to figure this out but have hit a wall. It doesn't stop me from continuing work with the code structure as it is but, I would like to understand what the source of this problem is. Any insite you may provide would be appreciated.

Davis

Davis's picture

Following on my prior posting, I made a few modifications to the source structure: I moved all the property files into an existing package called "properties" and likewise updated all the references to those property files, and I moved all the classes in the default package into a new package called "opencascade". So, everything is in a package now and it will compile and run.

However, the application crashes during runtime with this new layout. When I click the Geometry tab, for example, it dies because it can't find the Native library:

init:
deps-jar:
compile:
run:
Info: Create Viewer
Info: Done creation of Viewer2d
Info: Load NativePaint lib...
Info: Loading NativePaint lib done
Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: paint
at opencascade.CASCADEView3d.paint(Native Method)
at sun.awt.RepaintArea.paintComponent(RepaintArea.java:248)
at sun.awt.RepaintArea.paint(RepaintArea.java:224)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:254)
at java.awt.Component.dispatchEventImpl(Component.java:4031)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
#
# An unexpected error has been detected by HotSpot Virtual Machine:
#
# EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x0a24039a, pid=1168, tid=1560
#
# Java VM: Java HotSpot(TM) Client VM (1.5.0_06-b05 mixed mode, sharing)
# Problematic frame:
# C [TKV3d.dll+0x6039a]
#
# An error report file with more information is saved as hs_err_pid1168.log
#
# If you would like to submit a bug report, please visit:
# http://java.sun.com/webapps/bugreport/crash.jsp
#
Java Result: 1
BUILD SUCCESSFUL (total time: 36 seconds)

Again ... it can't find the DLL.

Davis

Jan Brüninghaus's picture

The problem is within the JNI-stuff.

You generate the header-files for the C-functions with javah. If you take a look on the JNI-specifications[1], you will notice, that the package names are part of the C-function names. So, if you move the java-files to an other package, you _must_ newly generate the headers and change the functions names in the c-source-files, so that they match the names in the headers. And of course your have to rebuild the dlls, too. Since you missed that, you get a linking error, because the names java looks for have simply changed. So it is not a problem of finding the library.

But that's not the only problem. Some of the native functions create new instances of java-classes. The package names are necessary for this. Since there a no variables or makros used for this, you have to change every single occurance by hand (or with a skript).

So moving the files in other packages is a lot of work. :-/

[1] http://java.sun.com/j2se/1.4.2/docs/guide/jni/spec/jniTOC.html

Davis's picture

Jan, thank you for your reply.

How do other people typically start using OCC with Java then? The samples are in an unusable package structure.

Unfortunately, I know very little about OCC at this point to determine whether it would be feasible for me to attempt a renaming effort. My problem right now seems to be just with TKV3d.dll so I will poke around the code and try to see if I can get some help to rebuild that.

Jan Brüninghaus's picture

I have post some things that i know about the java samples:
http://www.opencascade.org/org/forum/thread_10022/

Since i was also unhappy with the package structure I have solved this problem in the last few days. Unfortunatly you have to change nearly or even all jni-files, because there a everywhere hardcoded references to CASCADESamplesJni. But the most things have to be done for all the classes in CASCADESamplesJni. I have used a little bash-skript and sed to perform the necessary changes to this package, so i think, you will need cygwin [1] for it.

Let's say, the package CASCADESamplesJni should be changed to org.opencascade.

The bash-skript file-rename.sh:
for I in *cxx
do
sed -i -f package-rename.sed $I
mv $I `echo $I | sed 's/CASCADESamplesJni_//' | sed 's/_java.cxx/.cxx/'`
done

The sed-skript package-rename.sed:
s/"CASCADESamplesJni/"org\/opencascade/g
s/_CASCADESamplesJni/_org_opencascade/g
s/

Run the bash-skript in an copy of OCC/samples/standard/java/drv/CASCADESamplesJni

I change the names of files too, since this is easier to use with the makefile i use to create the libraries. If you are interested in the makefile, i can upload it.

For the same reason i changed the name of the header-files.

You will have to create the header-files with javah new for the new package-structure. There will be several compilation errors, since in the headers a short in java results in jshort, but the cxx-files have a jint. I have changed the cxx-files to work by hand. I can upload an diff of it.

The changes you will have to make in the other jni-files are rather small, since that are only a few functions with very few hardcoded references to CASCADESamplesJni.

[1] http://www.cygwin.com/

Jan Brüninghaus's picture

Well, at least firefox snips parts of the posting, since there is a < in the text. If you click on reply they are correctly masked. Strange thing.

So here again all from the beginning of the sed-skript. I hope it works, if i mask the < by myself...

The sed-skript package-rename.sed:
s/"CASCADESamplesJni/"org\/opencascade/g
s/_CASCADESamplesJni/_org_opencascade/g
s/<CASCADESamplesJni_/</

Run the bash-skript in an copy of OCC/samples/standard/java/drv/CASCADESamplesJni

I change the names of files too, since this is easier to use with the makefile i use to create the libraries. If you are interested in the makefile, i can upload it.

For the same reason i changed the name of the header-files.

You will have to create the header-files with javah new for the new package-structure. There will be several compilation errors, since in the headers a short in java results in jshort, but the cxx-files have a jint. I have changed the cxx-files to work by hand. I can upload an diff of it.

The changes you will have to make in the other jni-files are rather small, since that are only a few functions with very few hardcoded references to CASCADESamplesJni.

[1] http://www.cygwin.com/

Davis's picture

Jan;

Thank you so much! That's fantastic. I will try it out right away.

Davis

Davis's picture

hi Jan;

I have been at this for a number of days now but am stuck at compilation. I am using Visual Studio 2003 for this process.

I ran your script on the contents of the ..standard/java/drv/CASCADESamplesJni folder, then created new header files for the corresponding Java classes as you had instructed. I placed the new headers into the ../ros/inc folder (that's the only way Visual Studio could find the header files for some reason) then recompiled the SAMPLE solution and got the compilation errors as you had explained, in addition to a number of other errors which may or may not be related. Here is a sample of the errors I am getting:

Compiling...
V3d_Viewer.cxx
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(53) : error C2733: second C linkage of overloaded function 'Java_org_opencascade_V3d_1Viewer_V3d_1Viewer_1Create_10' not allowed
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(52) : see declaration of 'Java_org_opencascade_V3d_1Viewer_V3d_1Viewer_1Create_10'
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(402) : error C2733: second C linkage of overloaded function 'Java_org_opencascade_V3d_1Viewer_V3d_1Viewer_1SetDefaultBackgroundColor_11' not allowed
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(401) : see declaration of 'Java_org_opencascade_V3d_1Viewer_V3d_1Viewer_1SetDefaultBackgroundColor_11'
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(425) : error C2733: second C linkage of overloaded function 'Java_org_opencascade_V3d_1Viewer_V3d_1Viewer_1SetDefaultBackgroundColor_12' not allowed
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(424) : see declaration of 'Java_org_opencascade_V3d_1Viewer_V3d_1Viewer_1SetDefaultBackgroundColor_12'
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(495) : error C2733: second C linkage of overloaded function 'Java_org_opencascade_V3d_1Viewer_SetDefaultViewProj' not allowed
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(494) : see declaration of 'Java_org_opencascade_V3d_1Viewer_SetDefaultViewProj'
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(518) : error C2733: second C linkage of overloaded function 'Java_org_opencascade_V3d_1Viewer_SetDefaultVisualization' not allowed
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(517) : see declaration of 'Java_org_opencascade_V3d_1Viewer_SetDefaultVisualization'
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(588) : error C2733: second C linkage of overloaded function 'Java_org_opencascade_V3d_1Viewer_SetDefaultShadingModel' not allowed
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(587) : see declaration of 'Java_org_opencascade_V3d_1Viewer_SetDefaultShadingModel'
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(611) : error C2733: second C linkage of overloaded function 'Java_org_opencascade_V3d_1Viewer_SetDefaultSurfaceDetail' not allowed
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(610) : see declaration of 'Java_org_opencascade_V3d_1Viewer_SetDefaultSurfaceDetail'
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(657) : error C2733: second C linkage of overloaded function 'Java_org_opencascade_V3d_1Viewer_SetUpdateMode' not allowed
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(656) : see declaration of 'Java_org_opencascade_V3d_1Viewer_SetUpdateMode'
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(680) : error C2733: second C linkage of overloaded function 'Java_org_opencascade_V3d_1Viewer_SetDefaultTypeOfView' not allowed
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(679) : see declaration of 'Java_org_opencascade_V3d_1Viewer_SetDefaultTypeOfView'
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(956) : error C2733: second C linkage of overloaded function 'Java_org_opencascade_V3d_1Viewer_V3d_1Viewer_1DefaultBackgroundColor_11' not allowed
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(955) : see declaration of 'Java_org_opencascade_V3d_1Viewer_V3d_1Viewer_1DefaultBackgroundColor_11'
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(1034) : error C2556: 'jint Java_org_opencascade_V3d_1Viewer_DefaultViewProj(JNIEnv *,jobject)' : overloaded function differs only by return type from 'jshort Java_org_opencascade_V3d_1Viewer_DefaultViewProj(JNIEnv *,jobject)'
C:\OpenCascade\ros\inc\org_opencascade_V3d_Viewer.h(336) : see declaration of 'Java_org_opencascade_V3d_1Viewer_DefaultViewProj'
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(1034) : error C2371: 'Java_org_opencascade_V3d_1Viewer_DefaultViewProj' : redefinition; different basic types
C:\OpenCascade\ros\inc\org_opencascade_V3d_Viewer.h(336) : see declaration of 'Java_org_opencascade_V3d_1Viewer_DefaultViewProj'
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(1058) : error C2556: 'jint Java_org_opencascade_V3d_1Viewer_DefaultVisualization(JNIEnv *,jobject)' : overloaded function differs only by return type from 'jshort Java_org_opencascade_V3d_1Viewer_DefaultVisualization(JNIEnv *,jobject)'
C:\OpenCascade\ros\inc\org_opencascade_V3d_Viewer.h(344) : see declaration of 'Java_org_opencascade_V3d_1Viewer_DefaultVisualization'

This is getting quite frustrating and I'm a month behind now on my thesis work. Any suggestion you can provide as how to continue would be appreciated. Unfortunately, I am an amateur programmer -- my background is in architecture, not computer science.

Davis

Jan Brüninghaus's picture

V3d_Viewer.cxx
\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(53) : error C2733: second C linkage of overloaded function 'Java_org_opencascade_V3d_1Viewer_V3d_1Viewer_1Create_10' not allowed \OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(52) : see declaration of 'Java_org_opencascade_V3d_1Viewer_V3d_1Viewer_1Create_10'

Well, I think you try to link libraries twice. I found the following link, explaining this error: http://msdn2.microsoft.com/en-us/library/5z9es6ec.aspx

\OpenCascade\samples\standard\java\drv\org\opencascade\V3d_Viewer.cxx(1058) : error C2556: 'jint Java_org_opencascade_V3d_1Viewer_DefaultVisualization(JNIEnv *,jobject)' : overloaded function differs only by return type from 'jshort Java_org_opencascade_V3d_1Viewer_DefaultVisualization(JNIEnv *,jobject)'

Look through your source, you have it definitly twice. ;)

Peronally I use only the compiler and linker of VS (i think it is 2005) in my project. The hole building process is managed with a self-written makefile. Since the only things you do in C++ is that jni-stuff, i see no need for an IDE. Well, i confess that don't like VS at all, too. I uploaded a snapshot of my own work (which is at now only cutting down the samples to my needs and moving the packages a bit around). The makefile should work on windows, but i tested it so far only on linux.
http://www.lawevapo.de/opencascade/opencascade-test.tgz

If you have question on using make, take look at the manual:
http://www.gnu.org/software/make/manual/make.html

Davis's picture

hi Jan;

Thank you for posting your source and makefile. I'm getting closer but not quite there yet.

I installed Cygwin with make on my machine and compiled your modified sources. It seems that everything goes along smoothly until it gets to AIS_Drawer.cxx and then halts the following errors:

/usr/bin/g++ -c -O2 -DHAVE_IOSTREAM -DHAVE_LIMITS -I/opt/OpenCASCADE-6.1/ros/inc -I/usr/lib/jvm/java-1.5.0-sun/include -
I/usr/lib/jvm/java-1.5.0-sun/include/linux -IJni/include/org/opencascade/jcas -IJni/include/org/opencascade/Jni -IJni/in
clude/SampleImportExportJni -IJni/include -o Jni/obj/org/opencascade/Jni/AIS_Drawer.o Jni/src/org/opencascade/Jni/AIS_Dr
awer.cxx
Jni/src/org/opencascade/Jni/AIS_Drawer.cxx:15:26: AIS_Drawer.hxx: No such file or directory
In file included from Jni/src/org/opencascade/Jni/AIS_Drawer.cxx:16:
Jni/include/jcas.hxx:2:34: Standard_ExtString.hxx: No such file or directory
In file included from Jni/src/org/opencascade/Jni/AIS_Drawer.cxx:16:
Jni/include/jcas.hxx:8: error: expected constructor, destructor, or type conversion before "int"
Jni/include/jcas.hxx:8: error: expected `,' or `;' before "int"
Jni/include/jcas.hxx:9: error: expected constructor, destructor, or type conversion before "void"
Jni/include/jcas.hxx:9: error: expected `,' or `;' before "void"
Jni/include/jcas.hxx:10: error: expected constructor, destructor, or type conversion before "void"
Jni/include/jcas.hxx:10: error: expected `,' or `;' before "void"
Jni/include/jcas.hxx:11: error: expected constructor, destructor, or type conversion before "void"
Jni/include/jcas.hxx:11: error: expected `,' or `;' before "void"
Jni/include/jcas.hxx:12: error: `Standard_EXPORT' does not name a type
Jni/include/jcas.hxx:14: error: expected constructor, destructor, or type conversion before "void"
Jni/include/jcas.hxx:14: error: expected `,' or `;' before "void"
Jni/include/jcas.hxx:15: error: expected constructor, destructor, or type conversion before "void"
Jni/include/jcas.hxx:15: error: expected `,' or `;' before "void"
Jni/include/jcas.hxx:16: error: expected constructor, destructor, or type conversion before "void"
Jni/include/jcas.hxx:16: error: expected `,' or `;' before "void"
Jni/include/jcas.hxx:18: error: `Standard_EXPORT' does not name a type
Jni/include/jcas.hxx:19: error: expected constructor, destructor, or type conversion before "const"
Jni/include/jcas.hxx:19: error: expected `,' or `;' before "const"
Jni/include/jcas.hxx:20: error: expected constructor, destructor, or type conversion before "const"
Jni/include/jcas.hxx:20: error: expected `,' or `;' before "const"
Jni/include/jcas.hxx:21: error: expected constructor, destructor, or type conversion before "void"
Jni/include/jcas.hxx:21: error: expected `,' or `;' before "void"
Jni/include/jcas.hxx:22: error: expected constructor, destructor, or type conversion before "const"
Jni/include/jcas.hxx:22: error: expected `,' or `;' before "const"
Jni/include/jcas.hxx:23: error: expected constructor, destructor, or type conversion before "void"
Jni/include/jcas.hxx:23: error: expected `,' or `;' before "void"
Jni/include/jcas.hxx:25: error: `Standard_EXPORT' does not name a type
Jni/include/jcas.hxx:26: error: `Standard_EXPORT' does not name a type
Jni/include/jcas.hxx:27: error: `Standard_EXPORT' does not name a type
Jni/include/jcas.hxx:28: error: `Standard_EXPORT' does not name a type
Jni/include/jcas.hxx:29: error: `Standard_EXPORT' does not name a type
Jni/include/jcas.hxx:30: error: `Standard_EXPORT' does not name a type
Jni/include/jcas.hxx:31: error: `Standard_EXPORT' does not name a type
Jni/include/jcas.hxx:32: error: expected constructor, destructor, or type conversion before "short"
Jni/include/jcas.hxx:32: error: expected `,' or `;' before "short"
Jni/include/jcas.hxx:34: error: expected constructor, destructor, or type conversion before "void"
Jni/include/jcas.hxx:34: error: expected `,' or `;' before "void"
Jni/include/jcas.hxx:35: error: expected constructor, destructor, or type conversion before "void"
Jni/include/jcas.hxx:35: error: expected `,' or `;' before "void"
Jni/include/jcas.hxx:36: error: expected constructor, destructor, or type conversion before "void"
Jni/include/jcas.hxx:36: error: expected `,' or `;' before "void"
Jni/include/jcas.hxx:37: error: expected constructor, destructor, or type conversion before "void"
Jni/include/jcas.hxx:37: error: expected `,' or `;' before "void"
Jni/include/jcas.hxx:38: error: expected constructor, destructor, or type conversion before "void"
Jni/include/jcas.hxx:38: error: expected `,' or `;' before "void"
Jni/include/jcas.hxx:39: error: expected constructor, destructor, or type conversion before "void"
Jni/include/jcas.hxx:39: error: expected `,' or `;' before "void"
Jni/include/jcas.hxx:40: error: expected constructor, destructor, or type conversion before "void"
Jni/include/jcas.hxx:40: error: expected `,' or `;' before "void"
Jni/include/jcas.hxx:41: error: expected constructor, destructor, or type conversion before "void"
Jni/include/jcas.hxx:41: error: expected `,' or `;' before "void"
Jni/include/jcas.hxx:47: error: `Standard_EXPORT' does not name a type
Jni/include/jcas.hxx:49: error: ISO C++ forbids declaration of `Standard_EXPORT' with no type
Jni/include/jcas.hxx:49: error: expected `;' before "void"
Jni/include/jcas.hxx:51: error: ISO C++ forbids declaration of `Standard_EXPORT' with no type
Jni/include/jcas.hxx:51: error: expected `;' before '~' token
Jni/src/org/opencascade/Jni/AIS_Drawer.cxx:18:37: Standard_ErrorHandler.hxx: No such file or directory
Jni/src/org/opencascade/Jni/AIS_Drawer.cxx:19:32: Standard_SStream.hxx: No such file or directory
make: *** [Jni/obj/org/opencascade/Jni/AIS_Drawer.o] Error 1

Davis

Jan Brüninghaus's picture

You must adjust the makefile for your directories, since they surely will differ from mine. Look into it, i have put comments there.

Use the compiler of VS, since OpenCASCADE is build with it too. It is called "cl.exe" and you will find it somewhere in the VS directory (i think it was VC/bin). There you will also find "link.exe" you will need for linking. In Windows you must link against the user32.lib or resizing of the 3D-window won't work. This lib is inside the VS directory, too. Add it to "LIBSEARCHPATH" and user32 to "LINKLIBRARY" in the makefile.

Davis's picture

hi Jan;

After much wrangling with various problems, I was finally able to get it to compile this morning.

You definately can't have any spaces in the path names when compiling on Windows. I ended up replacing all the normal path names with the Windows 8+3 character "short name" (given by doing a dir /x at the command prompt for everyone else's reference). This assured that the path names contained no spaces.

Also, I had two problems during linking. First, I needed to adjust the LINKLIBRARIES section by adding $(OCASLIBDIR)/ before most of the library names, since those files were located in OCC/ros/win32/lib on my machine. Second, for some reason I was unable to get it to link the VS libs (user32, etc.) when I pointed to them in the Visual Studio folders where they were located. Consequently, I copied them into OCC/ros/win32/lib and then everything was fine. On that note, I should also mention that there were additional VS libraries that needed to be copied in, aside from user32 that you had mentioned. These libraries were all part of VS, and in the same folder as user32, so no problems there.

Finally, I did not end up using Cygwin at all. Everything that is required comes with Visual Studio already, and should work without much hassle. Cygwin was unfortunately not so friendly to use and presented many compilation problems.

My modified make file is here:

http://www.sfu.ca/~dmarques/Makefile.win

I noted that 'make clean' doesn't completely work on my machine, and gives some errors. I presume the problem is that it should be calling 'del' rather than 'rm'.

rm -rf Jni/include/org/opencascade/jcas/*
rm -rf Jni/include/org/opencascade/Jni/*
rm -rf Jni/include/SampleImportExportJni/*
rm -rf Jni/obj/org/opencascade/jcas/*
rm -rf Jni/obj/org/opencascade/Jni/*
rm -rf Jni/obj/SampleImportExportJni/*
rm -rf Jni/win32/Jni/win32/jcas.dll
make: rm: Command not found
make: *** [clean-lib] Error 127

Thank you again for having put that together, it was the difference between not being able to use OCC and being able to use it for me.

I'm now going to try this out and confirming that everything works ok for me. If that is the case then perhaps I can append to your package a ready made Netbeans project, with all the required Windows libs and some installation instructions, so that people can have a clean starting point for development.

Best,

Davis

Davis's picture

Jan;

I was able to build and run your modified samples package. The window has the appearance of an old Motif application. I expect that this means I have somehow linked in the wrong library. Is that right? Seems odd.

Also, you had mentioned previously, and I just realized, that you hadn't included all the sample applications in your package. Consequently, I went about trying to put them back in. When I build it now, there are a number of conflicts, most notably that certain objects are already defined in other locations. How should I go about resolving this? Does this require manual editing of the C++ headers, source files?

SampleViewer3DPackage.obj : error LNK2005: "class gp_Pnt __cdecl ConvertClickToPoint(double,double,class Handle_V3d_View)" (?ConvertClickToPoint@@YA?AVgp_Pnt@@NNVHan
dle_V3d_View@@@Z) already defined in SampleAISDisplayModePackage.obj
SampleViewer3DPackage.obj : error LNK2005: "class gp_Pnt p2" (?p2@@3Vgp_Pnt@@A) already defined in SampleAISDisplayModePackage.obj
SampleViewer3DPackage.obj : error LNK2005: "class gp_Pnt p1" (?p1@@3Vgp_Pnt@@A) already defined in SampleAISDisplayModePackage.obj
SampleViewer3DPackage.obj : warning LNK4006: "class gp_Pnt __cdecl ConvertClickToPoint(double,double,class Handle_V3d_View)" (?ConvertClickToPoint@@YA?AVgp_Pnt@@NNVH
andle_V3d_View@@@Z) already defined in SampleAISDisplayModePackage.obj; second definition ignored
SampleViewer3DPackage.obj : warning LNK4006: "class gp_Pnt p2" (?p2@@3Vgp_Pnt@@A) already defined in SampleAISDisplayModePackage.obj; second definition ignored
SampleViewer3DPackage.obj : warning LNK4006: "class gp_Pnt p1" (?p1@@3Vgp_Pnt@@A) already defined in SampleAISDisplayModePackage.obj; second definition ignored
Creating library Jni/win32/OpenCASCADEJni.lib and object Jni/win32/OpenCASCADEJni.exp
ISession2D_InteractiveContext.obj : error LNK2019: unresolved external symbol "public: __thiscall ISession2D_ObjectOwner::ISession2D_ObjectOwner(int)" (??0ISession2D
_ObjectOwner@@QAE@H@Z) referenced in function "public: void __thiscall ISession2D_ObjectOwner::`default constructor closure'(void)" (??_FISession2D_ObjectOwner@@QAEX
XZ)
ISession2D_InteractiveContext.obj : error LNK2019: unresolved external symbol "public: __thiscall Handle_ISession2D_ObjectOwner::~Handle_ISession2D_ObjectOwner(void)
" (??1Handle_ISession2D_ObjectOwner@@QAE@XZ) referenced in function "public: virtual void __thiscall ISession2D_InteractiveContext::Pick(unsigned int)" (?Pick@ISessi
on2D_InteractiveContext@@UAEXI@Z)
ISession2D_InteractiveContext.obj : error LNK2019: unresolved external symbol "public: static class Handle_ISession2D_ObjectOwner const __cdecl Handle_ISession2D_Obj
ectOwner::DownCast(class Handle_Standard_Transient const &)" (?DownCast@Handle_ISession2D_ObjectOwner@@SA?BV1@ABVHandle_Standard_Transient@@@Z) referenced in functio
n "public: virtual void __thiscall ISession2D_InteractiveContext::Pick(unsigned int)" (?Pick@ISession2D_InteractiveContext@@UAEXI@Z)

Davis

Jan Brüninghaus's picture

In Java you can choose the look & feel. It's done in the beginning of the main-function. Simply put you preferred type there.

UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");

That would give you the look & feel of windows.

What is the linking command, that causes the errors?

Also be aware of the references to CASCADESamplesJni in the sample packages. They will not cause compilation errors, but will throw exceptions when running.

Btw., i throw out everything in SampleImportExportJni except the iges import and CreateViewer3d, since i don't need it. I have also put the needed functions of SampleImportExportPacke directly into SampleImportExportJni.

Davis's picture

Jan;

This is the output from the make process:

http://www.sfu.ca/~dmarques/occlinkerror-20060811.txt

I ran grep on my sources to locate any references to CASCADESamplesJni and there are none.

Davis

Jan Brüninghaus's picture

link.exe /DLL /OUT:"Jni/win32/jcas.dll" ....

You have multiple jcas.lib there, but it should be only one. Also note, that you don't need TKjcas, if you compile jcas on your own.

----

link.exe /DLL /OUT:"Jni/win32/OpenCASCADEJni.dll" ...

SampleViewer3DPackage.obj : error LNK2005: "class gp_Pnt __cdecl ConvertClickToPoint(double,double,class Handle_V3d_View)" (?ConvertClickToPoint@@YA?AVgp_Pnt@@NNVHan
dle_V3d_View@@@Z) already defined in SampleAISDisplayModePackage.obj
SampleViewer3DPackage.obj : error LNK2005: "class gp_Pnt p2" (?p2@@3Vgp_Pnt@@A) already defined in SampleAISDisplayModePackage.obj
SampleViewer3DPackage.obj : error LNK2005: "class gp_Pnt p1" (?p1@@3Vgp_Pnt@@A) already defined in SampleAISDisplayModePackage.obj
SampleViewer3DPackage.obj : warning LNK4006: "class gp_Pnt __cdecl ConvertClickToPoint(double,double,class Handle_V3d_View)" (?ConvertClickToPoint@@YA?AVgp_Pnt@@NNVH
andle_V3d_View@@@Z) already defined in SampleAISDisplayModePackage.obj; second definition ignored
SampleViewer3DPackage.obj : warning LNK4006: "class gp_Pnt p2" (?p2@@3Vgp_Pnt@@A) already defined in SampleAISDisplayModePackage.obj; second definition ignored
SampleViewer3DPackage.obj : warning LNK4006: "class gp_Pnt p1" (?p1@@3Vgp_Pnt@@A) already defined in SampleAISDisplayModePackage.obj; second definition ignored

In both source files you will find global variables "gp_Pnt p1, p2".

----

"unresolved external symbol"

I think, there are libraries missing. You must link against the libraries, where the functions are defined. It seems, that you miss the ISession and User_Cylinder stuff. You will find it in /samples/standard/java/src/User, samples/standard/java/src/ISession and samples/standard/java/src/ISession2D. These things are part of TKSamples. The Sample*Package stuff is also part of TKSamples.

Davis's picture

Also, this is my modified package: www.sfu.ca/~dmarques/org.opencascade.zip

Contact us

Attention: DO NOT use this form for all kind of request for the removal of your personal data. Please follow this link for such cases.