GNOME Bugzilla – Bug 618646
Should be able to run gnucash-bin.exe directly, rather than gnucash.cmd
Last modified: 2018-06-29 22:39:20 UTC
There is no conditional logic in gnucash.cmd. The file is only for setting environment variables. We can set those environment variables to system or user during the installation. Then it's not necessary to use 'gnucash.cmd' as a wrapper.
Yes, this was one of my goals when I created the environment config file. But I haven't found the time to complete this part (that and my slow Windows VM which makes the tests much slower than should be). There are a few things that have to be sorted out before this can be completed. * gnucash.com is different when install.sh has run from the gnucash.cmd that gets installed by the ISS installer. * Most of the environment for GnuCash can be configured in etc/gnucash/environment, that is all but the path(s) to the gnucash binaries. The point is that this config file has to be found by the gnucash binary. On linux this is a no-brainer, on Windows I will have to investigate this a bit more. This environment config file will need to have slightly different content depending on how gnucash was installed, similar to the gnucash.com file it's trying to replace. * Simply putting all this information directly in the environment at install time is not a good idea for several reasons. I think for example about installing several independent instances of GnuCash (for testing or other purposes). Setting this in the global environment makes that these settings are shared between gnucash instances. * ...
(In reply to comment #1) > * Most of the environment for GnuCash can be configured in > etc/gnucash/environment, that is all but the path(s) to the gnucash binaries. > The point is that this config file has to be found by the gnucash binary. On > linux this is a no-brainer, on Windows I will have to investigate this a bit > more. Isn't this a problem that can be solved using g_win32_get_package_installation_directory_of_module () ?
http://library.gnome.org/devel/glib/2.22/glib-Windows-Compatibility-Functions.html#g-win32-get-package-installation-directory-of-module
Created attachment 161579 [details] [review] Patch will make it's possible to run gnucash-bin.exe directly I made a patch to this problem. I build it against r19185, and it can run gnucash-bin.exe directly. The patch contains following modifications: 1) Change desktop icon, start menu links to gnucash-bin.exe instead of gnucash.cmd 2) Modify packaging/win32/gnucash.iss.in to create etc\gnucash\environment file during the installation. 3) Move all lib/gnucash/lib*.dll files to bin/ on Windows only. So, gnucash-bin.exe will find all linked .dll files. 4) Change gnc_path_get_pkglibdir(), if current system is WIN32, return bin/. This is the workaround for the functions need to load .dll files in 'pkglibdir' which are already moved to bin/ 5) When loading gnc module, adding a filename prefix filter to check whether the filename is begin with "libgncmod". The reason is after moving lib/gnucash/lib*.dll to bin/, those files will mixed with other libraries on Windows, which are definitly not gnc module, such as gtk+, cairo .dll files. In most case they are easily ignored. However, for some libraries, there will be an error warning prompt on Windows. To avoid load unnecessary files, the prefix "libgncmod" is checked when loading the file. If it is begin with 'libgncmod', that means it's more likely a gnc module. Since, the prefix is kept for all platform, I didn't add #ifdef G_OS_WIN32 around that filter. 6) If GNC_CONFIG_PATH, GNC_SHARE_PATH is not set before running gnucash-bin.exe, the main() will use the compiled path instead. And environment_override() will find the 'etc/gnucash/environment' against that path. The default path should not be the linked one, they should be based on the current executable file location. So, change the default config_path, share_path and help_path to the result of 'gnc_path_get_*dir()', which is based on the current executable location. It is still easily override by the environment variables. I'm not sure whether all platform should be the same way, so I made this behavior WIN32 only.
Comment on attachment 161579 [details] [review] Patch will make it's possible to run gnucash-bin.exe directly Looks good to me. All functional changes are limited to G_OS_WIN32 which IMHO means they are just fine.
Created attachment 161923 [details] [review] Fixed a bug in previous patch Found a bug in previous patch, fixed it, and recreate the patch. Change: - mv bin/*.dll gnucash 2>/dev/null || true + mv bin/*.dll $_INSTALL_UDIR/bin 2>/dev/null || true To - mv bin/*.dll gnucash 2>/dev/null || true + mv bin/*.dll gnucash/*.dll $_INSTALL_UDIR/bin 2>/dev/null || true Not only lib/bin/*.dll should be copied to bin/, but also lib/gnucash/*.dll.
Comment on attachment 161923 [details] [review] Fixed a bug in previous patch ok
Comment on attachment 161923 [details] [review] Fixed a bug in previous patch In r19204. Thank you very much.
*** Bug 605825 has been marked as a duplicate of this bug. ***
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=618646. Please update any external references or bookmarks.