mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 14:15:54 -06:00
[GH-ISSUE #115] Link zlib when building shared library with MinGW-w64 #95
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/libxlsxwriter#95
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ohmyarch on GitHub (Jul 28, 2017).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/115
Originally assigned to: @jmcnamara on GitHub.
CMakeFiles/xlsxwriter.dir/objects.a(zip.c.obj): In function 'zipWriteInFileInZip':
libxlsxwriter/third_party/minizip/zip.c:1414: undefined reference to 'crc32'
...
@jmcnamara commented on GitHub (Jul 29, 2017):
@Alexhuszagh could you take a look at this.
@ohmyarch could you add the command line you used and the build environment.
@ohmyarch commented on GitHub (Jul 29, 2017):
@jmcnamara https://tea-ci.org/ohmyarch/libxlsxwriter/1
@jmcnamara commented on GitHub (Jul 29, 2017):
@ohmyarch
Are you compiling this in MSYS? (Update: since the log is tea-ci I guess you are. Using the .drone.yml.)
Does it work with a 64bit target?
For a 32bit build do you have to install 32bit versions of the zlib-devel libraries?
@jmcnamara commented on GitHub (Jul 29, 2017):
Also can you try the standard make system for libxlsxwriter: http://libxlsxwriter.github.io/getting_started.html
@ohmyarch commented on GitHub (Jul 29, 2017):
I have tried both 32bit and 64bit build, the same error. All 32bit/64bit static/shared zlib libraries was installed. CMakeLists.txt need some correction to link zlib library when building shared libxlsxwriter library with MinGW-w64.
In addition, standard linux build(static/shared) and mingw static library build works fine.
@Alexhuszagh commented on GitHub (Jul 31, 2017):
Hi @jmcnamara, sorry for the late response, I've tried to stop doing work on weekends and am writing my thesis. I'll look into this later today.
@ohmyarch, let me check the configuration. Nothing in the CMakeLists should be dependent on a shared library, since it finds the system's installation.
@jmcnamara commented on GitHub (Jul 31, 2017):
@Alexhuszagh Don't worry about it. Stick with your thesis.
@jmcnamara commented on GitHub (Aug 1, 2017):
@ohmyarch Correction I do see the issue now.
@jmcnamara commented on GitHub (Aug 1, 2017):
@ohmyarch and @Alexhuszagh It looks like the shared lib isn't linked with
-lz. Adding that to the link command inCMakeFiles/xlsxwriter.dir/link.txtfixes the issue. We just need to figure out how to add that to the Cmake script.@jmcnamara commented on GitHub (Aug 1, 2017):
I tried different variations of the following in CMakeLists.txt but it didn't work because they add the flag to the start of the compile list instead of the end.
The same effect occurs with:
@Alexhuszagh commented on GitHub (Aug 1, 2017):
@jmcnamara The
target_link_librariesandfind_package(ZLIB, ...)should automatically add those in. If-lzis not getting added in, there's a bug in the logic with those steps somewhere.There's no reason to manually add
-lz, since that won't work with custom zlib install directories (users can provideZLIB_INSTALL_DIRandZLIB_LIBRARYon the command line to override the system install locations), nor will it work with MSVC. Let me take a look at my logic.@Alexhuszagh commented on GitHub (Sep 8, 2017):
Hi @jmcnamara, sorry for the long delay but I was unable to find time until now. I just defended my thesis earlier this week, so I will be able to look over this tonight.
@jmcnamara commented on GitHub (Sep 11, 2017):
@Alexhuszagh There is no rush.
@Alexhuszagh commented on GitHub (Oct 18, 2017):
Hi @jmcnamara, I should have the patch for this. Between life events and my Windows dev computer crashing, I really haven't had time for this. I'm testing it on a naive virtual machine and then publishing it.
@jmcnamara commented on GitHub (Oct 18, 2017):
@Alexhuszagh no worries. I'm not sure that this is actually an issue.
I was able to reproduce it in MSYS2 32 and 64 bit a few months ago but not in Linux so my feeling was that it was probably a cmake or other issue.
Anyway I tried to reproduce it today with the latest MSYS2 (20161025 builds) and I can't:
Output:
So everything looks okay.
@ohmyarch can you confirm? And then rerun your tea-ci job.
@Alexhuszagh commented on GitHub (Oct 18, 2017):
@jmcnamara I cannot reproduce the above issue if the runtime flags or library architecture is correct. However, if I link to an incorrect ZLIB library, I get the exact compiler warnings @ohmyarch was warning about. Be very careful about the linked ZLIB variant, if you are worried about potential linker issues, you may always build a static version with the same runtime flags (on MSVC) and architecture, and pass the
ZLIB_INCLUDE_DIRandZLIB_LIBRARYto CMake during configuration.I did require a few minor patches to fix a few minor issues (and suppress the MSVC security warnings, since they promote a non-standard API), so I will be committing those. One of the patches involved ZLIB linking to the library, so it's very likely the cause of @ohmyarch's issues, even if I couldn't reproduce his errors on my machine.
For the following tests, I used the system ZLIB for MSYS2 (installed for the appropriate architecture via Pacman).
Tested Configurations
BUILD_STATIC=OFFBUILD_STATIC=OFFBUILD_STATIC=ONBUILD_STATIC=ONBUILD_STATIC=OFFBUILD_STATIC=ONGenerators
Build Command
Download
Build ZLIB
MSVC
Build Library
MSVC
MSYS2
@ohmyarch commented on GitHub (Oct 19, 2017):
@Alexhuszagh Now the shared library can be built , but libxlsxwriter.dll will not be installed after executing
make install.@Alexhuszagh commented on GitHub (Oct 19, 2017):
@ohmyarch Can you please post the output of
make VERBOSE=1 install? I'll be debugging this today.@Alexhuszagh commented on GitHub (Oct 19, 2017):
At the very least, I will be submitting a PR today to test the MSVC and MinGW target installs using AppVeyor and Tea-CI, so this issue does not occur again.
@ohmyarch commented on GitHub (Oct 20, 2017):
@Alexhuszagh https://paste.kde.org/pcpx9ekat/j8swm1/raw
@Alexhuszagh commented on GitHub (Oct 22, 2017):
@ohmyarch Is everything working like expected now?
@ohmyarch commented on GitHub (Oct 23, 2017):
@Alexhuszagh For MinGW-w64, *.dll should be installed to ${CMAKE_INSTALL_PREFIX}/bin.
@jmcnamara commented on GitHub (Oct 23, 2017):
@ohmyarch why in
bin? Shouldn't it go intolib?@Alexhuszagh commented on GitHub (Oct 23, 2017):
@jmcnamara He, @ohmyarch, is actually right here. I never get this right, because "DLL" is supposed to go in the bin folder, has a "DllMain" function and has the same file format, despite it being a dynamically linked library and being identified as a library in the header. It's a counter-intuitive reality of Windows, and it's how most libraries do things (including ZLIB, our dependency). It's a 3 character patch.
@jmcnamara commented on GitHub (Oct 24, 2017):
@ohmyarch This fix is merged upstream into master. Can you test it.
@ohmyarch commented on GitHub (Oct 24, 2017):
@jmcnamara @Alexhuszagh Everything is now working as expected, thanks. 🎉👍
@jmcnamara commented on GitHub (Oct 24, 2017):
Great. Thanks @ohmyarch and @Alexhuszagh.
@lattice0 commented on GitHub (Mar 2, 2020):
thanks, I was getting this while compiling with qt5 static in MSYS2/MinGW and didn't know I had to instal the devel version of zlib, I was installing the release one