diff --git a/include/wx/msw/stdpaths.h b/include/wx/msw/stdpaths.h index e36a2a9c5b..89d9c5ffd5 100644 --- a/include/wx/msw/stdpaths.h +++ b/include/wx/msw/stdpaths.h @@ -27,6 +27,7 @@ public: virtual wxString GetUserDataDir() const override; virtual wxString GetUserLocalDataDir() const override; virtual wxString GetPluginsDir() const override; + virtual wxString GetSharedLibrariesDir() const override; virtual wxString GetUserDir(Dir userDir) const override; virtual wxString MakeConfigFileName(const wxString& basename, ConfigFileConv conv = ConfigFileConv_Ext diff --git a/include/wx/osx/cocoa/stdpaths.h b/include/wx/osx/cocoa/stdpaths.h index 623277bbcf..e9b1af716d 100644 --- a/include/wx/osx/cocoa/stdpaths.h +++ b/include/wx/osx/cocoa/stdpaths.h @@ -27,6 +27,7 @@ public: virtual wxString GetLocalDataDir() const override; virtual wxString GetUserDataDir() const override; virtual wxString GetPluginsDir() const override; + virtual wxString GetSharedLibrariesDir() const override; virtual wxString GetResourcesDir() const override; virtual wxString GetLocalizedResourcesDir(const wxString& lang, diff --git a/include/wx/stdpaths.h b/include/wx/stdpaths.h index 49b0333153..934752cfbf 100644 --- a/include/wx/stdpaths.h +++ b/include/wx/stdpaths.h @@ -129,6 +129,9 @@ public: // Contents/Plugins app bundle subdirectory under Mac virtual wxString GetPluginsDir() const = 0; + // return the directory where the shared libraries live + virtual wxString GetSharedLibrariesDir() const; + // get resources directory: resources are auxiliary files used by the // application and include things like image and sound files // @@ -252,6 +255,7 @@ public: virtual wxString GetLocalDataDir() const { return m_prefix; } virtual wxString GetUserDataDir() const { return m_prefix; } virtual wxString GetPluginsDir() const { return m_prefix; } + virtual wxString GetSharedLibrariesDir() const override { return m_prefix; } virtual wxString GetUserDir(Dir WXUNUSED(userDir)) const { return m_prefix; } virtual wxString MakeConfigFileName(const wxString& basename, diff --git a/include/wx/unix/stdpaths.h b/include/wx/unix/stdpaths.h index 018ed602e9..4cd4173e3a 100644 --- a/include/wx/unix/stdpaths.h +++ b/include/wx/unix/stdpaths.h @@ -45,6 +45,7 @@ public: virtual wxString GetPluginsDir() const override; virtual wxString GetLocalizedResourcesDir(const wxString& lang, ResourceCat category) const override; + virtual wxString GetSharedLibrariesDir() const override; #ifndef __VMS virtual wxString GetUserDir(Dir userDir) const override; #endif diff --git a/interface/wx/stdpaths.h b/interface/wx/stdpaths.h index 46e55a61d7..aaae7994b7 100644 --- a/interface/wx/stdpaths.h +++ b/interface/wx/stdpaths.h @@ -312,7 +312,7 @@ public: /** Return the program installation prefix, e.g.\ @c /usr, @c /opt or @c /home/zeitlin. - If the prefix had been previously by SetInstallPrefix(), returns that + If the prefix had been previously set by SetInstallPrefix(), returns that value, otherwise tries to determine it automatically (Linux only right now) and finally returns the default @c /usr/local value if it failed. @@ -441,6 +441,22 @@ public: */ virtual wxString GetUserLocalDataDir() const; + /** + Return OS specific directory where project shared liraries are. + + The function does the same thing as GetPluginsDir() under non-Mac platforms + but differs from it under Mac, where plugins (shared libraries loaded by the + application dynamically while it's running) and shared libraries (that the + application is statically linked with) are stored in different directories. + + - Windows: returns the folder where the application binary is located + - Unix: returns the libraries installation path, i.e. /usr/lib + - Mac: returns `Contents/Frameworks` bundle subdirectory + + @since 3.3.0 + */ + virtual wxString GetSharedLibrariesDir() const; + /** MSW-specific function to customize application directory detection. diff --git a/src/common/stdpbase.cpp b/src/common/stdpbase.cpp index 88ea17f709..81ca39ebcb 100644 --- a/src/common/stdpbase.cpp +++ b/src/common/stdpbase.cpp @@ -171,3 +171,7 @@ wxString wxStandardPathsBase::AppendAppInfo(const wxString& dir) const return subdir; } +wxString wxStandardPathsBase::GetSharedLibrariesDir() const +{ + return {}; +} diff --git a/src/msw/stdpaths.cpp b/src/msw/stdpaths.cpp index 49f37a3bf3..076789e36e 100644 --- a/src/msw/stdpaths.cpp +++ b/src/msw/stdpaths.cpp @@ -348,6 +348,12 @@ wxStandardPaths::MakeConfigFileName(const wxString& basename, return fn.GetFullName(); } +wxString wxStandardPaths::GetSharedLibrariesDir() const +{ + wxFileName fn( GetExecutablePath() ); + return fn.GetPath(); +} + // ============================================================================ // wxStandardPathsWin16 implementation // ============================================================================ diff --git a/src/osx/cocoa/stdpaths.mm b/src/osx/cocoa/stdpaths.mm index 584362c4bd..e9bb0e37c3 100644 --- a/src/osx/cocoa/stdpaths.mm +++ b/src/osx/cocoa/stdpaths.mm @@ -145,4 +145,11 @@ wxStandardPaths::MakeConfigFileName(const wxString& basename, return fn.GetFullName(); } +wxString wxStandardPaths::GetSharedLibrariesDir() const +{ + // Shared libraries on OSX should be stored inside the + // /Contents/Frameworks + return wxCFStringRef::AsString([NSBundle mainBundle].privateFrameworksPath); +} + #endif // wxUSE_STDPATHS diff --git a/src/unix/stdpaths.cpp b/src/unix/stdpaths.cpp index 8d49f4b11b..f752842b2b 100644 --- a/src/unix/stdpaths.cpp +++ b/src/unix/stdpaths.cpp @@ -369,4 +369,9 @@ wxStandardPaths::MakeConfigFileName(const wxString& basename, return fn.GetFullName(); } +wxString wxStandardPaths::GetSharedLibrariesDir() const +{ + return GetInstallPrefix() + "/lib"; +} + #endif // wxUSE_STDPATHS diff --git a/tests/interactive/output.cpp b/tests/interactive/output.cpp index 4fcbf7ea54..a0b8895817 100644 --- a/tests/interactive/output.cpp +++ b/tests/interactive/output.cpp @@ -403,6 +403,7 @@ void InteractiveOutputTestCase::TestStandardPaths() wxPrintf(wxT("Executable path:\t%s\n"), stdp.GetExecutablePath()); wxPrintf(wxT("Plugins dir:\t\t%s\n"), stdp.GetPluginsDir()); wxPrintf(wxT("Resources dir:\t\t%s\n"), stdp.GetResourcesDir()); + wxPrintf( "Shared Libraries dir:\t\t%s\n", stdp.GetSharedLibrariesDir() ); wxPrintf(wxT("Localized res. dir:\t%s\n"), stdp.GetLocalizedResourcesDir(wxT("fr"))); wxPrintf(wxT("Message catalogs dir:\t%s\n"),