vtk runnable jar file - executable-jar

I have created an application using VTK java wrapper and java swing in Eclipse IDE. Now, I want to make a runnable jar file of the application so that I can run it on the different computer on which VTK is not installed.
I have created a jar file and have included vtk.jar while creating it. Also I have created a folder in which I am placing the jar file and debug folder (from VTK-bin/bin) which includes all the required dlls. When I am trying to run this jar file on the other computer, it gives unsatisfiedlinkerror.
What is the correct procedure to create a runnable jar file for VTK application?

The issue regarding executable jar file of VTK application is resolved. I compiled VTK in release mode instead of debug mode. For distribution purpose, debug is not used because of its additional dependencies. Also, I included jre/bin in path environmetal variable of target machine, which I had forgotten to do earlier.
Now, I am able to run jar file on the machine in which VTK is not installed.

Related

visual studio 2013 deploy a project

I crack my head already, I need to deploy a project. I tried to use InstallShield, it create an msi file, and local installation has no errors, but then when I tried to launch the program it output "debug error". In my settings code generator -> runtime library set for Multi-threaded Debug DLL(/MDd). If I'll set it to Multi-threaded (/MT) it would not compile: "Please use the /MD switch for _AFXDLL builds"
Then I tried to use VS Installer project extension. It creates the msi and setup file, but after I install it, I can't find the .exe file and launch program. What I am doing wrong?
Folder with project files
![enter image description here][3]
Folder with exe file
![enter image description here][4]
At the stage of creating the installer for your program, you have to put all the external files, libraries and resources, that your program needs in order to run correctly, in your program's working directory. When you run the program via Visual Studio, everything works fine since it can find the files, because, as you've mentioned, they are in the project folder, and the project folder is where Visual Studio is looking for them.
When you launch your program outside VS, the program can't find these files since it by default tries to locate them in the folder in which the .exe file being run is located. So, if you wan't to run program outside VS, you need to put all the files needed to your .exe's directory.
For the same reason, while creating your installer, you need to include all the files necessary in the installation target directory together with your .exe. Every installer creator lets you do that.
In general, if you cannot run your program outside any IDE, and you can run it within that IDE, it is a rule of thumb that you should first check if you have included all the necessary files/libraries/dll's/etc. in your program's working directory.
I solved it!!!!!!!!
1)Help to run .exe file, helped updating .uld file in the same directory as a exe file.
2)I used Dependency Walker (http://www.dependencywalker.com/) to find all dll that it's need. And then I create a Setup Project using Wizard at the "Choose file to include" step I add every file and every library that it's depend on! Build->Install-> Then magic, and my application installed and running! Thank you all for your help

Application failed to start because it could not find or load the QT platform plugin "windows"

I have looked through all of the questions that appear to be related on stack overflow, and none of the solutions seem to help me.
I am building a Qt application with this setup:
Windows 7 Professional x64
Visual Studio 2012
Qt 5.2.0 built with configure -developer-build -debug-and-release -opensource -nomake examples -nomake tests -platform win32-msvc2012 -no-opengl
Project uses QtSingleApplication (qt-solutions)
Application is a 32 bit application
qmake run with the following: -makefile -spec win32-msvc2012
.pri uses QMAKE_CXX += /D_USING_V110_SDK71_
I can build and run my program fine on my development machine (noted above); I can also install and run the package from Program Files directory on dev machine.
When I install and run on a Windows Vista machine (multiple machines)
VC++ redist 2012 11.0.61030.0 installed
VC++ redist 2010 10.0.40219 installed
plus 2005, 2008 versions of redist
(also fails on a clean install of Windows 7)
I get:
Application failed to start because it could not find or load the QT platform plugin "windows"
So I followed the instructions and added a .platforms/ directory, and added qwindows.dll (also added qminimal.dll and qoffscreen.dll); I also added libEGL.dll, libGLESv2.dll (even though I shouldn't need them I don't think)
Once I added qoffscreen.dll I now get the additional message: Available platform plugins are: offscreen
If I run through Dependency Walker I get this error listed:
GetProcAddress(0x76CA0000 [KERNEL32.DLL], "GetCurrentPackageId") called from "MSVCR110.DLL" at address 0x6AC6FDFA and returned NULL. Error: The specified procedure could not be found (127).
and then further down get the:
GetProcAddress(0x745A0000 [UXTHEME.DLL], "BufferedPaintUnInit") called from "COMCTL32.DLL" at address 0x745FFBF8 and returned 0x745AE18C.
This application failed to start because it could not find or load the Qt platform plugin "windows".
Available platform plugins are: offscreen.
Reinstalling the application may fix this problem.
Any ideas how to fix this dll issue?
The error is caused because the program can't find qwindows.dll
qwindows.dll has to be in a folder named platforms so that the path from your executable to the dll is platforms/qwindows.dll
Whereas this wasn't enough in my case. I had also to add following line at the beginning of my main()
QCoreApplication::addLibraryPath("./");
Then everything worked.
The application is able to run on the host system, since the Qt bin path is in the system PATH variable.
There is a standard Qt tool for deployment of Qt applications on Windows windeployqt to be able to run the application on target machines that do not have Qt installed.
That tool takes care about Qt DLL dependencies, makes a copy of platforms\qwindows.dll and also it makes a copy of libraries that you cannot detect with the Dependency Walker, since image plugins and some other DLLs are loaded at runtime.
You do not even need to have your Qt bin folder in your environment PATH. The simplest deployment:
copy built exe binary to a new folder
open cmd console in that folder
call windeployqt using the full path (if it is not in the system PATH) and provide your executable, for example:
c:\Qt\Qt5.2.1\5.2.1\msvc2010_opengl\bin\windeployqt.exe application.exe
As a result you have in that folder all needed Qt DLLs to run the application.
The tool windeployqt has various options. It can also take care about deployment of qml related files.
Of course you can have also issues with MSVC redistributables, but those should be deployed separately and installed once per system.
Only some 3rd party libraries should be copied manually if they are used, for example OpenSSL.
I got this issue and how I solved it:
Used dependency walker(http://www.dependencywalker.com/) to see the exact path of the dlls needed. Try it because both QtCreator and QT framework both have the same dlls and you must pinpoint the exact ones used.
I copied all dlls needed in the same folder as the app.
I have copied the folder platforms from QT framework /plugins and copied it in the same folder as the app. Now the app comtained also plugin/platform/ folder with all its dlls
And the most important step in my case is to create a file named qt.conf in the same folder as the app . This file should contain the path to the plugins. My qt.conf file contains:
[Paths]
Libraries=../lib/qtcreator
Plugins=plugins
Imports=imports
Qml2Imports=qml
I had the same issue "Application failed to start because it could not find or load the QT platform plugin "windows"
I fixed this by copying below files to the app.exe (my app executable) folder,
Qt5Core.dll, Qt5Gui.dll, Qt5Widgets.dll and a "platforms" directory with qminimal.dll, qoffscreen.dll, qwindows.dll.
I hope this will help someone
Note this issue can also be caused if the search path for qwindows.dll that is encoded in your app includes the path where you installed Qt. Consider the following scenario:
I install Qt to c:\Qt\...
I develop an app and deploy it correctly somewhere else.
It runs on any computer properly because it includes qwindows.dll in a subdirectory.
I upgrade my local Qt to a new version.
I try to run my app again.
The result is this error, because the qwindows.dll in c:\Qt\... is found before the one in its local directory and it is incompatible with it. Very annoying.
A solution is to place a file qt.conf in the same directory as your exe file. I don't know how to avoid this. If you used the tool windeployqt.exe to deploy your app, so you have a subdirectory called platforms, then this is sufficient:
[Paths]
Plugins=.
For me, I needed to set QT_QPA_PLATFORM_PLUGIN_PATH to the platforms directory and then it worked.
For what it's worth, this solution was also mentioned on GitHub.
For the people who have this problem in the future - I have a dirty little hack, worked for me. Try at your own risk.
Follow all the steps in Initial deployment (Quick and dirty) [http://wiki.qt.io/Deploy_an_Application_on_Windows]
Close Qt Creator.
Copy the following into C:\Deployment\ The release version of MyApp.exe All the .dll files from
C:\Qt\5.2.1\mingw48_32\bin\ All the folders from
C:\Qt\5.2.1\mingw48_32\plugins\
(If you used QML) All the folders from C:\Qt\5.2.1\mingw48_32\qml\ Rename C:\Qt\ to C:\QtHidden\ (This turns your PC into a clean environment, just like one that doesn't have Qt installed).
Launch C:\Deployment\MyApp.exe.
Now for the hack -
Duplicate your folder for safety
If your file was in /cat/Deployment, go to /cat
Now, delete the Deployment folder while the .exe is still running.
It will tell you that it cannot delete certain files, so say Skip(or skip all)
What you're left with is the list of all the .dll files that your .exe was actually using and could not delete: the list of all the files and only the files that you need to keep.
You can close the .exe file now.
To check whether it is deploying okay, go into the folder where you installed it, say C:/Qt and rename it to C:/NotQt (basically make Qt invisible to the system).
If it works now, it will deploy on other systems more often than not.
Well I solved my issue, although I'm not sure what the difference is:
I copied every dll from my qt directory into both ./ and ./platforms of my application directory.
The application got past the error, but then crashed.
VERSION.dll was causing the crash (noted in dependency walker), so I removed it from both places.
The Application started up, so I systematically removed all unneeded dll's.
This got me back to the same state I had originally.
I then uninstalled my application and re-installed (with only the ./platforms/qwindows.dll file remaining), application works correctly.
So all I can assume is that I had an incorrect version of qwindows.dll in the platforms directory.
I got the same issue:
1. it can run in VS2010;
2. it can run in a folder with files as:
app.exe
\platforms\qwindows.dll
...
but it failed to load qwindows on a clean machine with same OS as the developing one.
Solved simply by move the platform folder to plugins:
app.exe
plugins\platforms\qwindows.dll
plus: qwindows.dll can be renamed as any you like as it is queried by an plugin interafce:
qt_plugin_query_metadata()
It's missing qwindows.dll, which normally should be in platforms, unless you add:
QCoreApplication::addLibraryPath("<yourpath>");
If you don't do this btw, and put your qwindows.dll somewhere else, Qt will search your PATH for the DLL, which may take a LOT of time (10s - several minutes)!
I fixed this by placing qt.conf in my application's exe folder:
[Paths]
Prefix=C:/Qt/Qt5.11.2/5.11.2/msvc2017
Where:
I have installed a custom Qt kit in C:\Qt\Qt5.11.2\5.11.2\msvc2017
qt.conf informs the app where the custom kit via the Prefix property. Note use forward slashes not backslashes (!)
And, optionally, the Qt kit's bin folder is included in my PATH environment variable
Defining Prefix in your qt.conf file allows it to find the qwindows.dll platform plugin when your app starts.
Tried all the above - turned out for me it was simply because I didn't have the main Qt dlls in the apps folder
Qt5Core.dll
Qt5Widgets.dll
etc
You need to add environmental variable QT_QPA_PLATFORM_PLUGIN_PATH to the system which points to the platforms directory in QT plugins. In my case, I was using Anaconda and PySide2. Therefore my directory path was C:\ProgramData\Anaconda3\envs\cv\Lib\site-packages\PySide2\plugins. This fixes the issue for every QT project. Otherwise, you have copy platforms directory to every QT project.

Creation of libBox2D.a when Box2D is compiled?

I am trying to get the most recent version of the libBox2D.a file for updating an old project that uses Box2D. I am using Code::Blocks and Windows 7 64-bit.
I have added the Box2D folder into a Code::Blocks project, and got the HelloWorld.cbp applet to build and run. I expected a lib folder to be created and the .a file to be there, but it's not. The question is, How does libBox2D.a get generated, and where does it go?
Assuming your codeblocks project is setup correctly, the libBox2D.a library gets produced as the end result of building the corresponding project file. What you have to figure out is whether the project is setup to build Box2D as a shared dll or as a static library.
You can find the destination of the build output under project options->Build targets->Output filename. That field should tell you where to find the output. If that doesn't help, you can open a cmd.exe shell and go into Box2D's working directory and do a manual search. For example:
cd YOUR_Box2D_DIRECTORY_GOES_HERE
dir/s/a/w lib*.a

Can I point my project to a locally stored glut.dll?

I have a c++ opengl project that uses glut. It runs fine in my computer, but I need to be able to run it on a lab computer. When I try to do this, it tells me the glut.dll is not installed, but I do not have the privileges to put the file in the proper system folder on the computer. Is there anyway I can store the file with my game, and point to it in my project?
Thanks
Add required dlls to your project and set property to copy local.
Executable looks for dlls in folders listed in $PATH and in the folder with exe file.

Qt Oracle plug-in registration

I built the plug-in for oracle database and have been working very happily with my Qt program and Oracle 10g XE.
When the plug-in was built, the files qsqlocid4.dll and qsqlocid4.lib were created; and I simply copied these files to this location:
C:\QtSDK\Desktop\Qt\4.7.4\msvc2008\plugins\sqldrivers; all works perfect.
However I have a Qt and Oracle installation on other computer, and I need to re-compile this same program in this "new" machine. I thought that it was only necessary to copy the *.lib and *.dll files (the already built driver) to the plug-ins folder of the Qt installation in this second machine to make it work (this computer also has VS2008 installed, so the compiler that generated the plug-in is the same for both machines).
Unfortunately when I execute my program, in this second machine, it tells me it can't load the Oracle plugin.
I think it is because I only copied the driver and not created it in this second machine; and because of this, I suppose that in the process of creating the driver, Qt enables or registers it for future use or something.
Is there a way I can register or enable the driver, so I don't have to build it over and over in every machine that needs it?
There is a good chance that when you have compiled your Qt dlls on the first machine and you copied them to the specified directory, the Qt system still used them from the original directory ... somehow I kind of recall that Qt embeds the installation path into the executables... might be I'm wrong. You should put the plugins in the "sqldrivers" directory which is in the directory where your application runs (ie: the "exe" trying to load the plugin and the "sqldrivers" sub directory are in the same directory).
Or yes, you can re-compile them on the new machine.