-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
- Expose and implement append_decorations method to build the library… #23
Conversation
… path without loading the library. It allows to get the concrete path that will be loaded and allows the user to use the concrete path prior to effectively load the library. - Add error handling for posix platforms (gnu compiler compilation) when a library with missing symbols is asked for loading : check the library path exists and we do not try to load the current executable. In this case : return the current dlerror (useless to try the exactly specified path as the decorated path points to a valid shared library file).
|
||
if (handle_) { | ||
return; | ||
} | ||
if (boost::filesystem::exists(load_path)) { | ||
// decorated path exists : current error is not a bad file descriptor | ||
ec = boost::dll::detail::last_error_code(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the wrong way to use last_error_code. The last_error_code function must be called immediately after the system function in wich error code we are interested in. Putting filesystem::exists between the LoadLibrary and last_error_code breaks the error reporting.
So just move the ec = boost::dll::detail::last_error_code();
line before the if
statement. That will do the job.
@@ -511,6 +511,26 @@ class shared_library | |||
return base_t::suffix(); | |||
} | |||
|
|||
/*! | |||
* Returns the decorated path to a shared module name, i.e. with needed prefix/suffix added. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need more scary notes:
Returns the decorated path to a shared module name for the current runtime environment, i.e. ...
Calling this function with different current directories may produce different results.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain what you mean with "different current directories" ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ther result of shared_library::decorate("foo")
may not be the same, if user changes the current directory via https://en.cppreference.com/w/cpp/filesystem/current_path
For example it may return libfoo.so and foo.so, depending on the working directory.
Oh, one more thing: please add a test, that if we create an empty file with name test_broken.so
and try to load it, then the the loading fails. You may also write some other tests.
Almost ready for merge :) |
Many thanks for the PR! I've changed a few things in 7981565 We need a better name for the |
Thanks Antony, feel sorry that I didn't have time to finalize the PR with your comments. |
Thanks to you! You made the most part of the job. Happy new Year :) |
… path without loading the library.
It allows to get the concrete path that will be loaded and allows the user to use the concrete path prior to effectively load the library.
In this case : return the current dlerror (useless to try the exactly specified path as the decorated path points to a valid shared library file).