-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
Question: copy bundled libvips to another directory #20
Comments
Hi there, See here for a detailed instruction to set the libvips binary directory at runtime. The bundled libvips that NetVips uses are taken from this repo. I could add another property (for e.g. Also, copying libvips and their dependencies to a subdirectory by default would break globally installed libvips versions, so I don't intend to do that. |
Thanks, that workaround really helped me. The only question I have now is why don't use main libvips repo? Bindings won't work correctly if I'll reference this version? |
The binaries from the main libvips repo also work. The advantage of the Hopefully this distribution will be incorporated in the official libvips binaries (see libvips/build-win64#22). |
Understood, thank you! |
@kleisauke How about copying libvips in directory and set path variables like gdal.net does (it creates GdalConfigure class with ConfigureGdal() method which sets path variables for copied binaries, but I suppose netvips calls initializer automatically)? This won’t create global path variables (these exist only for current process and I’m pretty sure that you won’t use installed vips from the code if you’re using bindings, here’s docs on this method from msdn) so it won’t be problem for already installed on pc vips. |
Modifying the DLL search path within a library feels clunky to me. In order to not bloat the project's output directory, I thought about an alternative:
When setting the if (!ModuleInitializer.VipsInitialized)
{
// Get the directory for the executing assembly in which the current code resides.
var currentDirectory =
Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
// <LibvipsOutputBase>vips</LibvipsOutputBase>
var vipsPath = Path.Combine(currentDirectory, "vips");
// Prepend the vips path to PATH environment variable, to ensure the right libs are being used.
var path = Environment.GetEnvironmentVariable("PATH");
path = vipsPath + ";" + path;
Environment.SetEnvironmentVariable("PATH", path);
// Try to reinitialize libvips
Base.VipsInit();
} If you want to test this, you can use the nightly version of NetVips. Add the
And update NetVips to 1.0.6.102. |
@kleisauke I've run some tests with both nighty version of package and rebuilt 1.0.6 branch. Everything seems to work correctly. I've also noticed, that setting // Try to reinitialize libvips
try
{
Base.VipsInit();
}
catch (Exception exception)
{
switch (exception)
{
case DllNotFoundException _:
Console.WriteLine("libvips dlls not found. Please, specify correct path.");
break;
case BadImageFormatException _:
Console.WriteLine("libvips is unable to load. Try target x64.");
break;
}
} BTW, how about automatically adding the |
`LinkBase` property is only for .NET Core >= 2.0. See #20.
I've fixed the The only configuration that is needed is to call |
Weird, but
And of course, if I change |
@Gigas002 My apologies for the slow reply; I've been busy with my internship.
Also, NetVips tries to guess the target platform from the Otherwise, I'm not sure why it doesn't work for you. I've successfully tested this on .NET Core 2.1 and .NET Framework 4.5. |
@kleisauke Ah, my fault, I overlooked that |
Thanks for testing! I'll publish a new version (1.0.6) on NuGet with this improvement in the course of next week. |
The new version is delayed due to a packaging bug on Windows x86. I'll try to publish a new version on NuGet after this has been fixed (and libvips 8.7.3 is released). Sorry for the delay. |
Sure, no problem! |
NetVips 1.0.6 is now available on NuGet. |
@kleisauke Noticed something weird when referencing the project with NetVips from another project. If I try to use If I remove NetVips dependency in project2 and try to initialize it in project1, the exception is still thrown. Am I doing something wrong? That also gave me a thought (Inspired by GDAL once again. Sorry, if it's a bad idea since 1.0.6 is already released) - probably it'll be better to create two separate Nuget packages: NetVips (which contains only NetVips.dll) and something like NetVips.Native (which contains original libvips bindings)? |
I agree, the pre-compiled libvips binaries should be in a seperate package (for e.g. I'll try to address this issue (along with #21) next month. |
See: #21 (comment). |
Is there possibility to set the directory for bundled libvips before runtime? I don't want to have all the dll's in my working directory, I'd prefer something like "Release/vips/".
This just copies the vips in selected directory to the output directory. I can't set EnvironmentVariable this way:
either, because libvips's Initializer is called before runtime and throws exception because can't find libvips in my output directory.
Thanks in advance for your reply!
The text was updated successfully, but these errors were encountered: