Recent

Author Topic: Portable apps on Unix/Linux  (Read 8954 times)

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Portable apps on Unix/Linux
« on: October 20, 2011, 11:47:05 am »
Hi all,

It's fairly easy to write a portable application for Windows, e.g.:
  • avoid the registry
  • read config files from the current/application directory
  • put all required dlls in the application directory

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?
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

fabienwang

  • Sr. Member
  • ****
  • Posts: 449
  • Lazarus is the best
    • My blog
Re: Portable apps on Unix/Linux
« Reply #1 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).
I'm using Arch Linux.
Known for: CPickSniff, OpenGrabby
Contributed to: LazPaint

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Portable apps on Unix/Linux
« Reply #2 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  :)
« Last Edit: October 20, 2011, 01:33:10 pm by BigChimp »
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

sfeinst

  • Full Member
  • ***
  • Posts: 186
Re: Portable apps on Unix/Linux
« Reply #3 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.

BigChimp

  • Hero Member
  • *****
  • Posts: 5740
  • Add to the wiki - it's free ;)
    • FPCUp, PaperTiger scanning and other open source projects
Re: Portable apps on Unix/Linux
« Reply #4 on: October 20, 2011, 03:36:45 pm »
Good one. I'll keep that in mind.
Want quicker answers to your questions? Read http://wiki.lazarus.freepascal.org/Lazarus_Faq#What_is_the_correct_way_to_ask_questions_in_the_forum.3F

Open source including papertiger OCR/PDF scanning:
https://bitbucket.org/reiniero

Lazarus trunk+FPC trunk x86, Windows x64 unless otherwise specified

TurboRascal

  • Hero Member
  • *****
  • Posts: 672
  • "Good sysadmin. Bad programmer."™
Re: Portable apps on Unix/Linux
« Reply #5 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...
Regards, ArNy the Turbo Rascal
-
"The secret is to give them what they need, not what they want." - Scotty, STTNG:Relics

 

TinyPortal © 2005-2018