How to include native .so with JAR - java-native-interface

I'm building a JAR file (to run on linux servers) which uses a native libxxxx.so file. I can put the .so file anywhare and pass its locattion using -Djava.library.path option.
Now can I include the .so file with the jar so that I don't have to copy it to a location and include its location when I'll run the jar?

Ultimately you'll have to unpack it from the jar and store it somewhere before the system will be able to use it. Java Web Start has support for delivering native libraries, but even that system requires it to copy the native libraries out of their delivery jar files into a temporary location.
JNA provides support for embedding and unpacking a shared library from anywhere in your resource path (usually a jar file, but anywhere accessible by Class.getResource() will do).

Related

how to make stand-alone setup file of a mfc project including all data files

I have a project in VC++ MFC and works fine with the .mdb files. But just copying the project's .exe file on other system does not let the project work as it searches for the same path as mentioned in the code for the .mdb files and fails to find one. Also, apart from .mdb files, theres a need for certain .ocx files and io library suite to be registered in the system prior to the project's execution. How to overcome this problem?
You need to wrap up all the files into a package also known as installer. One of the most popular (and free) at the moment is Inno Setup. This will produce a single exe file that you will be deploying to users / other machines. You need to make sure that you include all the needed files, libraries etc in your setup.

How do I set a lua.dll so lua.exe won't ask for it in every directory?

Every time I enter lua my_script.lua in command line, it prompts me for lua53.dll on the same folder. How do I set a path so I won't need to have a copy of the lua library in every folder that I want to run a .lua file? I wonder if it is made via parameters or if I should build my own .exe from the .c files using environment variables, but I don't really know.
I've downloaded the binaries from http://luabinaries.sourceforge.net (v5.3.2 - may 19th) and have put lua.exe inside C:/Windows/System32.
According to this MSDN article, the directory from which the application is loaded is the first location being checked for the DLL file. If you put the DLL next to the location of lua.exe it came with, the DLL should be found and loaded by the system.
It may be better to not put application files into your system folders. Just create a separate folder and put your Lua files (.exe and .dll) there. You can then add that folder to PATH environment variable, so that it can be found when you run it as lua.

Embedding LuaJIT - creating include folder

I have no problems with LuaJIT, it great and easy to switch from good old Lua.
But for now i use folder src from LuaJIT distribution as include for lib.
It is kinda messy because there are makefile, batch scripts, c files, dasc files, src/jit folder with scripts which i know used with luajit.exe e.t.c.
I want to create clean include folder with only h files (and other if needed) for using LuaJIT in c++ windows application as shared lib, but quite don't know what to exclude.
My current exclude list
host folder
jit folder
c files
dasc files
c files
luajit.lib - goes to lib folder
luajit.exp
luajit.exe
luajit.dll - goes to bin folder
makefile
makefile.dep
bat files
http://luajit.org/install.html
It's strongly suggested to build LuaJIT separately using the supplied build system. Please do not attempt to integrate the individual source files into your build tree. You'll most likely get the internal build dependencies wrong or mess up the compiler flags. Treat LuaJIT like any other external library and link your application with either the dynamic or static library, depending on your needs.
Build as usual and then copy into your project the files:
lua.h, lauxlib.h, lualib.h, luajit.h, luaconf.h;
libluajit-5.1.a, or luajit-5.1.dll, or libluajit-5.1.x.x.x.dylib or whatever your platform static/shared library file looks like;
#include headers in project sources and link executables to the library file;
LuaJIT is ABI compatible with Lua, so the regular Lua headers will also work with LuaJIT. The only headers you need are lua.h, luaconf.h, lauxlib.h, and lualib.h. LuaJIT also comes with luajit.h, but it's not required, and doesn't contain anything that isn't accessible via the jit library.

Qt specifying a location for certain application data

I am making an application in Qt. I have 2 directories, 1 for configurations, the other for program scripts.
I would like to have it say that when I build the project, it will place those directories in a certain directory.
For instance on linux:
/home/username/.project_name/configurations
/home/username/.project_name/scripts
This should also be cross platform, so on Windows and MacOS these files should be placed in the normal place where application data is stored.
Is there there a way to specify where these directories (and the files in them) should be placed? Is it an option in the project file? And which option ?
The qt resource system is used to store files within your application's executable.
You need to answer two questions:
Where do the files come from? Does your installer or package contain them, or are they in the executable proper and the application extracts them and saves them. Then the qt resource system is useful.
How to get the path you need to create your configuration directory. QDesktopServices::storageLocation(QDesktopServices::DataLocation) returns such a path in a cross-platform manner.

Where do I place the MySQL C++ Connector files on Mac?

I am trying to install the MySQL C++ Connector on my Mac. I downloaded the tar.gz file from mysql.com, and when I unzip it, I have three text files, one of which is a Readme that doesn't provide much help. Then there is the /include folder which has two C++ header files and then a sub-folder called /cppconn that has another 14 C++ header file. Then there is also the other folder call /lib that contains a Dynamic Library file and two symbolic links to that Dynamic Library file, as well a a .a file. I was wondering where I place these files or folders on my Mac so that I can write a C++ application that can connect to a database? Or if there is a way for gcc or g++ to be able see these files in a location I specify when compiling? Any help would be much appreciated.
I don't know mac specifics, but usually (in linux / unix / windows - I dont expect mac to be any different) you either
put the header files into some place that is in your compilers header path(such as /usr/include), library files in your compilers lib path (such as /usr/lib),
or
you put them anywhere you like (perhaps /usr/local/my_cpp_connector) and then add that path to your compilers search path, both for headers and libraries.
You could also do like
/usr/local/my_cpp_connector/include
/usr/local/my_cpp_connector/lib
but I guess you got the idea at this point.