# How to run an application without installing



## balanga (Aug 19, 2018)

I want to be able to run an application without installing it and can't figure out how to do it.  Basically I want to find all the dependencies of a particular program and then copy them along with the progam to a USB stick so that I can insert the USB stick, mount it and run 'myprog.sh' which would be a stub for setting the correct paths and any other required environment variables and then launching 'myprog'. 

Is this doable?


----------



## Phishfry (Aug 19, 2018)

To build a freestanding app you can compile a port with MAKE_ARGS+=STATIC=1 in the makefile.
You must also add the argument to every leaf port (And every leaf port of the leaf).

So you better off splitting the ports branch off to a private build for static builds. That way you don't contaminate your entire ports tree. You could also just copy the ports needed to a private tree instead of the whole tree.

I have sysutils/flashrom on USB stick. I made a seperate ports tree and compiled the port with STATIC.
After chasing the dependencies it worked.. Copied it from build machine to USB stick.
I can copy it to any FreeBSD 9,10,11,12 install and run it. Maybe even earlier versions too.
Basically STATIC compile adds all the libraries internally, making a bigger executable.
https://forums.freebsd.org/threads/make-a-stand-alone-application.66341/


----------



## ralphbsz (Aug 19, 2018)

Another XY problem.

Please explain in more detail what you are trying to do.  What do you mean by "application" ???

I have many applications I have written and downloaded.  Typical examples include C++ programs and python scripts.  I don't "install" them, I compile or prepare them, and then run them.  Sometimes they can be run directly, in the directory the executable is stored in. Sometimes I copy the executable to /usr/local/bin/ or ~/bin/ to make it easier to access.  Sometimes I wrap them in shell scripts to streamline them.

Finding and fulfilling dependencies is part of step "compile and prepare".


----------



## balanga (Aug 19, 2018)

ralphbsz said:


> Another XY problem.
> 
> Please explain in more detail what you are trying to do.  What do you mean by "application" ???



I was thinking of something like Midnight Commander which has plenty of dependencies...


----------



## Phishfry (Aug 19, 2018)

ralphbsz said:


> copy the executable to /usr/local/bin/


Yes and when I compile with STATIC=1 it still puts the application in the runtime place /usr/local/bin/flashrom
So I dig it out from there and copy to USB for usage. Flashrom requires no configuration file.
I could see an application that might require a configuration file as well. Like MC
misc/ytree only has 2 leaf ports. print/indexinfo and devel/readline


----------

