Closed hahntech closed 8 years ago
These instructions should fix at least the package problem: http://www.coolprop.org/dev/coolprop/wrappers/Java/index.html#windows-32-bit-and-64-bit
I will fix the name of the folder we generate.
Thanks for the report
What version of cmake do you use?
Thanks for the assistance! I will check out those instructions and let you know if this resolves the issue. The version of cmake I have is 3.6.1.
Sorry to say the newer instructions produced the exact same result. And by the way the instructions for Windows is identical from the one I used and linked in the opening post. This time I had the presence of mind to attach the cmake error log. The error states that a file could not be found "CompilerIdC.vcxproj", and yet when I check the directory listed in the error log that file is definitely present. CMakeError.txt
Until we get this resolved I'm going to experiment with the JavaScript wrapper and see if I can get that working in my Java SE project.
Sounds like your Visual Studio install is messed up. It is unable to file CL.exe (the compiler). Perhaps try reinstalling Visual Studio? Make sure you pass the generator for Visual Studio 15, with something like:
cmake ../.. -G "Visual Studio 14 2015 Win64" -DCOOLPROP_JAVA_MODULE=ON (and so on)
for instance
This has been a journey of a thousand nightmares. There are numerous prerequisite programs that need to be installed. I'm sure you've listed them somewhere but I must have missed it. Visual Studio C++ compiler if you happen to install Visual Studio 2015 (it does not include the C++ compiler) Cmake Python Swig Each of these has it's own horror stories, how to add them to the path so Cmake can find them. And after all these were installed I finally got what appeared to be a completed project. Even still, there was an error about "Could Not Find JNI (missing JAVA_JVM_LIBRARY)". Probably have to figure out how to add that to the path too.... Yes, I have long ago installed JDK 1.8.0_91. So the next step in the instructions is to type this into the command prompt: "make install". To which it responds "make is not a recognized program". Yet another dependency and I lack the strength to go and chase that down and install it.
So I find a file in the build folder called INSTALL, and I right-click the file and select open with Visual Studio. I managed to get the java files written into the build folder. So here we have a chance, after 12+ hours of nightmares to finally put this thing to the test.
Result: "UnsatisfiedLinkError: build.CoolPropJNI.PropsSI". Same exact message you get when trying to use the precompiled Java wrapper in the folder named "platform-independent". Ok, I hope you are still with me here because I said all of that to tell you this.
The java files produced through this process lack a package name. It is impossible to add an import statement without a package name. And when you try to manually add a package name to each of the java files you end up with the same error "UnsatisfiedLinkError". Even when the java files are added to the same package as the main class. So there is something fundamentally wrong with the format of these java files. Sure, it works with the example.java you provide. But it is completely ineffective when trying to add it to an existing Java application.
To make this truly usable for Java applications you probably need to covert these to .class files and compile them into a .jar file that can be included as a library instead of as a package. But how to do all that is well above my knowledge.
Some comments:
a) Here are the common requirements get everything working: http://www.coolprop.org/dev/coolprop/wrappers/Java/index.html#common-requirements
b) make install
should be replaced with cmake --build . --config Release
in the windows instructions. I will fix that.
c) Make sure you follow the instructions about setting the -package flag: -DCOOLPROP_SWIG_OPTIONS="-package package.name"
. Information is here: http://www.coolprop.org/dev/coolprop/wrappers/Java/index.html#common-requirements in the development documentation. That should fix your package issue.
In general, better to post your problems here then to spend 12 hours fighting with compilation :)
Thanks a bunch for the suggestions and updated instructions. I really appreciate this tool. Great stuff. If I can get it working in my Java app I'll post a version of it to github to hopefully shorten the learning curve for others. I'll let you know how it goes.
Well I've run through this a few times. Had to install the 32 bit version of JDK in order to avoid cmake error in finding Java_JNI. After running the build I always end up with the same result. 11 warnings and 1 error. The .java files are being generated and they do have a package name included. So how serious are these warnings and errors? Should I attached a copy of the build output for someone to review?
Error is probably serious, warnings probably not serious. Can you please provide the full clean build log? Thanks.
On Tue, Aug 2, 2016 at 4:20 PM, Pete Hahn notifications@github.com wrote:
Well I've run through this a few times. Had to install the 32 bit version of JDK in order to avoid cmake error in finding Java_JNI. After running the build I always end up with the same result. 11 warnings and 1 error. The .java files are being generated and they do have a package name included. So how serious are these warnings and errors? Should I attached a copy of the build output for someone to review?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/CoolProp/CoolProp/issues/1172#issuecomment-237064328, or mute the thread https://github.com/notifications/unsubscribe-auth/ABxha2hcVM4MGtTP9kRRQRayCFJoTGWSks5qb8KigaJpZM4JYgg9 .
Ok, thanks for taking a look at this. Not sure this is exactly what you requested. I didn't find a "build log" per se. But the text in the attached file is the contents from the command prompt window, which seems to me to be the build log. I removed some of the file path for privacy but did so in a consistent manner so as not to disrupt the structure. CoolPropBuildLog.txt
Are you doing this in Netbeans? You should probably do all the build from the command prompt. Then copy-paste the entire build procedure from the console into a text file. If you don't want to post it here, you can mail me: ian.h.bell@gmail.com
I am not doing any of this from Netbeans. It's just that I placed the build files in my Netbeans folder on my Windows computer. I am using a command prompt. In fact I am using the "VS2015 x86 Native Tools Command Prompt". Just to make sure the C compilers are accessible to cmake. The file I attached is directly copy and pasted from that command prompt window (console). I just did Ctrl+ A and Ctrl +C, and pasted it into a text editor where I stripped out the user folder from the path to the directory. Then saved it as a txt file.
I would like to see the commands, all the way from the first cmake call. I can't see them in the file you attached.
On Tue, Aug 2, 2016 at 9:23 PM, Pete Hahn notifications@github.com wrote:
I am not doing any of this from Netbeans. It's just that I placed the build files in my Netbeans folder on my Windows computer. I am using a command prompt. In fact I am using the "VS2015 x86 Native Tools Command Prompt". Just to make sure the C compilers are accessible to cmake. The file I attached is directly copy and pasted from that command prompt window (console). I just did Ctrl+ A and Ctrl +C, and pasted it into a text editor where I stripped out the user folder from the path to the directory. Then saved it as a txt file.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/CoolProp/CoolProp/issues/1172#issuecomment-237124731, or mute the thread https://github.com/notifications/unsubscribe-auth/ABxha13B8EY4KP2yVGpE9jXbW1GA9uduks5qcAnLgaJpZM4JYgg9 .
yeah, I noticed the console does not contain all the commands from the first stage. So I'll send you one file from the first stage, then another file from the build stage. That should contain everything. I'll send them to the email you provided.
Thanks for reviewing the build log and spotting the lack of Python six. I installed that as per your suggestion using pip install six
and I just completed the build with no errors. Still had the 11 warnings but you mentioned those shouldn't cause issues. No I'll run ctest --extra-verbose
as the final step and see what I get.
I have a questions about the CoolProp.DLL file. Is this generated during the build process? If so where is it located? Is it 32 bit or 64 bit? And is that DLL file matched to this specific build (i.e., does package name get factored into the DLL) Or can I use the DLL file that is supplied with your platform-independent java example?
Thanks again for your assistance!
Ok, good to hear you got it building.
The Java DLL is NOT a normal DLL. From the beginning we should have called it something different to make it clear that it is not a standard DLL for CoolProp. But too late now... Perhaps at some point we will change it to make it more clear.
On windows, your DLL is probably in the Release directory, or depending on how you built CoolProp, perhaps in the install directory. A full build log should make that clear. The DLL will be 32-bit if you use "Visual Studio 14 2015" generator, or 64-bit if you use "Visual Studio 14 2015 Win64" generator.
Ok, finally got around to testing out the fresh build in a Java application. Couple issues. First is the CoolProp.dll file generated using the "Visual Studio 14 2015 Win64" generator ended up being a 32 bit DLL. So that fails to load on startup. Then I tried using the 64 bit CoolProp.dll available in your repo and it did successfully load that DLL. However I still the get very same "UnsatisfiedLinkError" when the example.java class tries to call CoolProp. Here is the exact output of running example.java:
**** INFORMATION *** This example was auto-generated by the language-agnostic dev/scripts/example_generator.py script written by Ian Bell Exception in thread "main" java.lang.UnsatisfiedLinkError: org.coolprop.CoolPropJNI.get_global_param_string(Ljava/lang/String;)Ljava/lang/String; at org.coolprop.CoolPropJNI.get_global_param_string(Native Method) at org.coolprop.CoolProp.get_global_param_string(CoolProp.java:121) at coolpropperf.Example.main(Example.java:13) C:\Users\petehahn\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
Can you please provide a full build log? Should allow us to debug what has gone wrong. I'm surprised it doesn't work for you out of the box. You do realize that you should start from an empty build folder, right?
On Sun, Aug 7, 2016 at 7:25 PM, Pete Hahn notifications@github.com wrote:
Ok, finally got around to testing out the fresh build in a Java application. Couple issues. First is the CoolProp.dll file generated using the "Visual Studio 14 2015 Win64" generator ended up being a 32 bit DLL. So that fails to load on startup. Then I tried using the 64 bit CoolProp.dll available in your repo and it did successfully load that DLL. However I still the get very same "UnsatisfiedLinkError" when the example.java class tries to call CoolProp. Here is the exact output of running example.java:
**** INFORMATION *** This example was auto-generated by the language-agnostic dev/scripts/example_generator.py script written by Ian Bell Exception in thread "main" java.lang.UnsatisfiedLinkError: org.coolprop.CoolPropJNI.get_global_param_string(Ljava/ lang/String;)Ljava/lang/String; at org.coolprop.CoolPropJNI.get_global_param_string(Native Method) at org.coolprop.CoolProp.get_global_param_string(CoolProp.java:121) at coolpropperf.Example.main(Example.java:13) C:\Users\petehahn\AppData\Local\NetBeans\Cache\8.1\executor-snippets\run.xml:53: Java returned: 1
— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/CoolProp/CoolProp/issues/1172#issuecomment-238122881, or mute the thread https://github.com/notifications/unsubscribe-auth/ABxha7P4zFWPIy9asEN3uf4elJz1yXczks5qdoWngaJpZM4JYgg9 .
CoolProp x64 build.txt Attached build log as you requested. I only gave you the first stage because I noticed right away there is an issue with the selection of the compilers.
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/cl.exe -- works
I see it is going to the 32 program folders for each of the C compilers. So I am guessing the most likely cause is my Viz Studio install lacks the 64 bit compliers?
Update: 8/7/2016 @ 9:42 pm PT I followed the instructions given here that is supposed to set the command prompt to compile in x64 bit: https://msdn.microsoft.com/en-us/library/x4d2c09s.aspx And the DLL that results is still recognized by Windows a 32 bit. Yes, I start with a completely empty build file for each run. Attached are the two stages of the build log. CoolProp vcvarsall amd64.txt CoolProp x64 build Stage 2.txt
SUCCESS!!! I finally have a working 64 bit Java application with proper package assignments. (previously, this only worked if you placed the Example.java main class in the "default" package, which is a big no-no in Java dev). It seems the CoolProp.DLL that is created in the final build is specific to the package name used in the first stage of the build. I could not substitute another 64 bit DLL.
So here is what I did to get it working:
For the cmake part:
cmake ../. -G "Visual Studio 14 2015 Win64" -DCOOLPROP_JAVA_MODULE=ON -DBUILD_TESTING=ON -DCOOLPROP_SWIG_OPTIONS="-package org.coolprop"
I then opened Visual Studio 2015 (community edition for those interested). From inside VS I opened the project file named ALL_BUILD that was created by cmake. In the project explorer, I then right-clicked on ALL_BUILD and selected properties. Just to confirm the build was set to x64, which it was. I then right-clicked on ALL_BUILD and selected 'Build' from the pop-up menu.
After the build completed in VS I then checked my build directory and found the 64 bit CoolProp.DLL was placed in a folder named Debug. (/build/Debug) I copied that dll file into the main path of my Java project. Then added Example.java to a new package called coolpropperf
and then added the remaining .java files to a package named org.coolprop
. Then added an import statement to Example.java import org.coolprop.*;
. Works perfect!
So when I get time, I do plan on building a basic Java app and posting it to a repo of my own. I'll drop a link to that repo here so anyone else looking for this solution will have a functional copy.
Thanks again Ian for all your assistance (and patience)!
Couple of notes: You should be able to build your DLL at the command line with
cmake --build . --config Release --target install
This will put the DLL and all .java files in one directory. You can then chuck that all into your project.
If you could please update the docs (https://github.com/CoolProp/CoolProp/blob/master/Web/coolprop/wrappers/Java/index.rst) with your experience, that would be great!
I followed the instructions here I tried using: "cmake .. -DCOOLPROP_JAVA_MODULE=ON -DBUILD_TESTING=ON" To build a Java wrapper for CoolProp but it always fails with an error. I've read the error logs and taken corrective actions. So far I've installed Visual Basic Studio 2015, then SDK 8.1 and each time I get a new set of errors. Now it's reporting the C and CXX compiler cannot be found. When I check the log it says it could not locate a file named "CompilerIdCXX.vcxproj" and yet I checked the directory it listed and the file is absolutely in there.
I sure hope someone can point me in the right direction. As an additional FYI, the precompiled wrapper includes a folder named "platform-independent". While the example.java works you cannot add this folder to any Java project as a package. Because package names cannot contain "-". You could sure avoid a ton of headaches by simply compiling a new Java wrapper using the folder name "platform_independent".
It has already been posted that it's not possible to simply change the folder name. It has to be compiled with the correct folder name. Sorry for the long post, I wanted to make sure to cover all the nooks and crannies here. Thanks for you assistance.