I'd like to know if moving an executable to a directory different from where it is installed will make it not be able to work? I remembered it is the case under Windows XP when running the executable by clicking its icon. Under Linux terminal, it seems that with its path specified correctly, the executable can still work? Thanks for clarification! Regards!
feedback
|
migrated from stackoverflow.com Aug 31 '09 at 18:40
This question came from our site for professional and enthusiast programmers.
|
As long as the executable can find it's dependencies (other dlls on Windows for example) then it will work. If it can't for any reason (i.e. it assumes that they are in the same directory) then it won't. Unfortunately the error messages you get out of Windows aren't always the most helpful so you might have problems locating all the required files. | |||||
feedback
|
|
This depends 100% on the application. An application by itself just needs to find it's dependencies, or the list of DLLs it requires to run. It'll look in the current directory for these most of the time, so this usually isn't an issue. The largest issue is in the registry. If the application has written where it was installed to the registry, it may look for certain files in the old directory at runtime. If you installed the application, this is also stored in the registry, and uninstalling from Add/Remove programs will no longer work. If the application does not use the registry though, it can be moved without consequence. Many portable apps which run off flash drives take this approach, and as a result can be moved or deleted as needed. | |||
|
feedback
|
|
usually. If there are shared libraries they may need to be moved too, or a path set so it can find them, depending on your operating system. | |||||
feedback
|
|
Theres no technical reason that you can't move an executable to any directory you want to and run it. The executable itself shouldn't know or care what its filename is or what directory its in. However, the executable must be able to find any other files it wants to to open, such as configuration files, data files, shared libraries, etc. Often times the executable will be written such that it expects to find these things in the same directory it is run from or in a sub directory, for example, the exeuctable might expect that if it is run in: /foo/baz/bin/executable That its config files are in /foo/baz/etc/configfile As long as you make sure the executable can find any other files it needs to open, you should be able to move it around as needed. Under Linux, the 'strace' command can be useful for this, you can run the exe under strace and see what files its trying to open and them grab them and move them. Also, for shared libraries 'ldd' is useful as it tells you what shared libraries the executable will try to open and which ones it isn't finding. | |||||
feedback
|
|
Under Linux (and UNIX in general) most executables can be moved around freely. They usually find their dependencies automatically ... sometimes using ~/.* ("dot files") ... conventionally named things like ~/.rc (where 'rc' originally stood for "run command" but can be thought of as "resource/configuration" settings). Sometimes (increasingly) UNIX/Linux packages will create a ~/. directory (such as ~/.gnome/, ~/.firefox/ and so on). Commonly an application will check for a ~/.* file, then look for an /etc/ configuration file. It may search in other places (such as /opt/etc/ or /usr/local/etc). It's also fairly common for such programs to honor an environment setting ... so you Generally it's best to refer to a program's documentation to find out about the files and environment settings. Usually a program will allow a command line switch to over-ride any environment setting, over-riding any ~/.* setting, which over-rides any /etc/* setting which might over-ride any compiled in setting. However, that's merely a loosely followed convention. Check the docs! In general UNIX/Linux programs are far less fragile than MS Windows or older MacOS programs in managing their resource locations. There's usually no opaque "registry" or "resource forks" to hide these things from you. | |||
|
feedback
|