-
Notifications
You must be signed in to change notification settings - Fork 281
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
Linking with static expat #11
Comments
I believe it's possible. Are you building with the msvc/exiv2.sln file, or using CMake? Which Edition of Visual Studio 2015 are you using? Community, Express, or a Retail Edition? The policy is "all static" or "all dynamic". I have successfully built x64/Debug (which is static) and x64/DebugDLL a few minutes ago:
However, I'm currently working on a build error for Visual Studio 2015 Community Edition x64 bit builds. I will submit the fix in the next couple of hours. |
… 2015 Community Edition. Issue 11 and Raphael's issues should now be resolved.
CMake, with VS2015 Community |
The CMake/Visual Studio build does not support static external libraries. The reason is historical. I found it almost impossible to get CMake to build anything with Visual Studio when I first worked with it around 2012. To simplify things, I could only get CMake to build and link DLLs. Since then I've made progress and you will find scripts in contrib/cmake/msvc which "tame the beast". However the historical restriction of linking zlib and expat dynamically remains (although you may build a static exiv2.exe). You can build it with:
I'm willing to listen to any good argument for supporting static builds of the external libraries. However, as the pain and effort to achieve the current capability was huge, I'm unlikely to accept the challenge to support static builds of the external libraries. You may think that this is an easy change, however the testing effort is considerable to support: |
Hi all, I just want to comment that it is possible to link exiv2 with the static versions of zlib and expat. In my organisation we have spent some time creating conan recipes for all our dependencies, and we are supporting this case. The relevant python lines of the conan recipe looks like this:
Where Is not fully working yet but you can find the conan recipe here: https://github.com/piponazo/conan-exiv2 (The support for zlib and expat has not been added here yet) |
I don't know what conan is. Is this something that will benefit the Exiv2 project? There is no question that it's possible to link the static versions of expat and libz because the msvc/exiv2.sln file does it. However, it will require changes to CMake_msvc.txt and contrib/cmake/msvc/cmakeBuild.cmd, and probably changes to contrib/buildserver (which builds and tests the bundles using CMake). A simpler solution is for you to execute devenv.exe commands to use msvc/exiv2.sln to build the libraries. |
[offtopic] Conan is a package manager that is becoming in the standard package manager for C++ :). You can find more information in its page: https://www.conan.io/ The recipe is pointing now to this github repository, and it will make extremely easy to get a working package for someone interested in the usage of exiv2 (for linux, mac or windows). |
Conan sounds very useful and I'd like to work with you to ensure Exiv2 is published. I'll look at the effort to get our CMake static build to work with static external libraries. |
Sure. I am now working now in this recipe for Exiv2 and I will need to also contribute with some of the other dependencies that it has (expat). Other dependencies like zlib are already in the main conan-center repository. If it is fine for you I will continue working on the conan-exiv2 recipe. Feel free to comment there and we can discuss more via email about the possible collaboration :) |
I'd expect zlib and expat to be "kind of core". They are so common. (And is it called libz or zlib? On the command-line, you use -lz to link libz.a. However it's everyday name is zlib. Groan ....... software). I'm happy to work with you. All the different package systems: apt, brew, port (and probably others) intend to help on a single platform. I believe Microsoft are entering the packaging arena and will integrate theirs with Visual Studio. A cross-platform packaging systems helps everybody. Good Luck to you. Please keep working on the recipe and I'm happy to help you. I'm going to leave this issue open to remind me to work on the original request to link static external libraries. |
Not to get too far off topic but I'd like to second what piponazo mentioned. ,If exiv2 was on Conan, my life would be so much easier. |
@henryborchers You are not off topic. That's also what I'd like to achieve. I'm working with @piponazo to achieve that goal. I believe @piponazo owns the conan task and I'll make any changes required on Exiv2 to reach that objective. |
Progress update: I've done more (unsuccessful) work on this. My team-mate Ben has observed that expat is only used by xmpsdk (and samples/geotag.exe). I could always build the static version of expat and never build the DLLs. However, the architecture I would like is the behaviour of the msvc/exiv2.sln. Everything is static, or everything is a DLL. It can be done. msvc/exiv2.sln does it! |
Progress update: I've put another session into this without a successful result. @piponazo is giving the CMake support a makeover. Perhaps he'll even solve this as part of the makeover. If he doesn't, I take up this challenge after the makeover is complete. I'm going to stop working on this for now to focus on others matters. In particular, I've discussed with @piponazo having a "dot" release of the code late August/early September. Ben and I have other work to undertake for that dot release and I'd like to complete that before going on vacation on July 21. When I return in early August, we'll decide what's going into the 'dot' release and I will focus on testing and releasing v0.26.1. |
Good to know. I will keep this issue in my list of priorities during the CMake makeover ;) |
@piponazo I own the task to statically link Expat/Exiv2/CMake. To avoid "stepping on each others toes", I'm going to put it to the side for now and revisit it when you're done with your work. @draekko has a working solution in his branch cpp11-xmpsdk-split which always links statically with Expat (and never dynamically). We want to pull that into Exiv2 v0.26.1, so it's possible that this issue will disappear with no effort required by you at all! I will have to update xmpsdk/exiv2.sln to adopt the same approach. sample/geotag also requires Expat and I can either remove the sample or link statically. @data-man Thank you for your suggestions. Our code builds and links a static version of Adobe's XMPsdk which uses Expat. I don't want to change anything in Adobe's code. Even if one of the suggested libraries interfaces using the Expat API, I still want to ship Exiv2 with libxmpsdk.a linked to Expat. I believe the fix for this will be easy. I've had 3 sessions (of about 4 hours each) without resolving this. A break from the puzzle is probably the correct medicine. When I look at this in August, it's probable that the fix will be obvious in minutes. The difficulty is being caused by "Russian Dolls". CMake is a language for generating build environments and can generate Visual Studio Solution/Project Files which are an XML wrappers for running the Microsoft compiler and linker CL and LINK. CMake and Visual Studio are not happy partners and I know Thomas B (another Exiv2 Team Member) agrees. |
Delighted to report that I have a fix which I will submit this evening. The essential ingredient is to get Expat to link the static runtime library. So the following CMake options are required when building Expat:
There are other "gotchas" concerning CMake/zlib which builds the static library as zlibstatic.lib I'm still considering alternative ways to deal with this. Success is certain after 4 sessions of 4 hours. Session 5 will fix this. |
I've submitted a fix to master. Please be aware that @draekko and I are merging a major change to master this week and the build is currently broken. However, you should be able to use the change above on the "old" master. In addition to the discovery above concerning Expat, you should link zlibstatic into exiv2. The appropriate change is around line 260 in src/CMakeLists.txt
Although it is (just) possible to use CMake from the command-line, I recommend that you build using the script in contrib/cmake/msvc as follows:
Usage: |
I don't know if this the place to ask this or not. I've been trying to build Exiv2 with static zlib and static expat in MSVC 2015 Win64.
I was able to build it with static zlib but if I tried to link it with static Expat, I'd get linker errors. exiv2 with static zlib and expat even possible?
The text was updated successfully, but these errors were encountered: