Lazarus

Programming => Operating Systems => Topic started by: BigChimp on October 20, 2011, 11:47:05 am

Title: Portable apps on Unix/Linux
Post by: BigChimp on October 20, 2011, 11:47:05 am
Hi all,

It's fairly easy to write a portable application for Windows, e.g.:

On Linux/OSX/FreeBSD, things are different. Suppose I'd want to write a portable password vault with an SQLite database that you can use on a USB stick.

Libraries/.so/.dynlib
I suspect I'd have to statically link my libraries or use FPC's LoadLibrary to load in the .so's - but where do I store them, which brings me to my next question:

File locations
Determining the directory an application is in is not completely reliable (see other messages/cross-platform wiki), so reading config files from the app directory wouldn't really work.
As far as I understand, using resources is a Windows thing.
For config files etc, I could just write out a config file into the user's directory, but I'd prefer if I could keep it on the USB key  :D

What solutions or thoughts do you have?
Title: Re: Portable apps on Unix/Linux
Post by: fabienwang on October 20, 2011, 11:48:56 am
Hey,

if you have few settings to save, why not use an encryption on a plain text file. (.ini ? lol)
or a XMLPropStorage (i use that a lot).
Title: Re: Portable apps on Unix/Linux
Post by: BigChimp on October 20, 2011, 12:01:34 pm
Hi FabienWang,

Yeah, but where to put them? Ideally I'd put them in the directory where the application is running but that apparently isn't reliable.
I could of course just ignore that and use Application.Exename/Paramstr[0]/whatever it's called, like everybody else...

Modified: RTFM (at least partly): FreePascal Programmer's Guide chapter 13, resources: "all FPC supported platforms now have resources available". So that's one question solved  :)
Title: Re: Portable apps on Unix/Linux
Post by: sfeinst on October 20, 2011, 03:21:45 pm
What I do with configs is accept a command line param with the location the user wants to use for the config.  If param is not passed, the user's home directory is used.  In this way I do not need to worry about mount points and if the user wants it portable, the user can decide where to store the config.  It also allows multiple configs for multiple users even using the same USB stick.
Title: Re: Portable apps on Unix/Linux
Post by: BigChimp on October 20, 2011, 03:36:45 pm
Good one. I'll keep that in mind.
Title: Re: Portable apps on Unix/Linux
Post by: TurboRascal on October 20, 2011, 06:06:06 pm
Libraries/.so/.dynlib
I suspect I'd have to statically link my libraries or use FPC's LoadLibrary to load in the .so's - but where do I store them, which brings me to my next question:
...
As far as I understand, using resources is a Windows thing.

This brings an interesting (at least to me) question -  how does one link something statically with FPC/Lazarus? And especially, is there a way to link statically something that is already wrapped in LCL controls and which uses dynamic linking itself?

Concerning resources, AFAIK Lazarus has its own OS-independent resources system...
TinyPortal © 2005-2018