[GH-ISSUE #339] Static build of libxlsxwriter with openssl #276

Closed
opened 2026-05-05 12:04:49 -06:00 by gitea-mirror · 20 comments
Owner

Originally created by @squinky86 on GitHub (Jun 24, 2021).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/339

Originally assigned to: @jmcnamara on GitHub.

I have a project where I'm building libxlsxwriter and openssl statically into it. Unfortunately, both define the MD5 function identically and cause a conflict.

When -DBUILD_SHARED_LIBS=off and -DUSE_OPENSSL_MD5=on, libxlsxwriter's build process should specify that the MD5 function is external.

Originally created by @squinky86 on GitHub (Jun 24, 2021). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/339 Originally assigned to: @jmcnamara on GitHub. I have a project where I'm building libxlsxwriter and openssl statically into it. Unfortunately, both define the MD5 function identically and cause a conflict. When -DBUILD_SHARED_LIBS=off and -DUSE_OPENSSL_MD5=on, libxlsxwriter's build process should specify that the MD5 function is external.
gitea-mirror 2026-05-05 12:04:49 -06:00
Author
Owner

@jmcnamara commented on GitHub (Jun 24, 2021):

Could you give some example of how to reproduce this?

<!-- gh-comment-id:867997895 --> @jmcnamara commented on GitHub (Jun 24, 2021): Could you give some example of how to reproduce this?
Author
Owner

@squinky86 commented on GitHub (Jun 25, 2021):

Absolutely:

  1. Static build openssl
  2. Static build libxlsxwriter with -DBUILD_SHARED_LIBS=off and -DUSE_OPENSSL_MD5=on
  3. create a project that attempts to then statically link both libxlsxwriter and openssl
  4. Watch what happens when you try to statically link everything in:
/usr/bin/x86_64-w64-mingw32-ld: /tmp/openssl-1.1.1k/libcrypto.a(md5_dgst.o):md5_dgst.c:(.text+0x0): multiple definition of `MD5_Init'; /tmp/libxlsxwriter-RELEASE_1.0.6/libxlsxwriter.a(md5.c.obj):md5.c:(.text+0x835): first defined here
/usr/bin/x86_64-w64-mingw32-ld: /tmp/openssl-1.1.1k/libcrypto.a(md5_dgst.o):md5_dgst.c:(.text+0x8bc): multiple definition of `MD5_Update'; /tmp/libxlsxwriter-RELEASE_1.0.6/libxlsxwriter.a(md5.c.obj):md5.c:(.text+0x859): first defined here
/usr/bin/x86_64-w64-mingw32-ld: /tmp/openssl-1.1.1k/libcrypto.a(md5_dgst.o):md5_dgst.c:(.text+0x9bb): multiple definition of `MD5_Final'; /tmp/libxlsxwriter-RELEASE_1.0.6/libxlsxwriter.a(md5.c.obj):md5.c:(.text+0x8f1): first defined here

In this example, I built openssl-1.1.1k by cross-compiling into /tmp/openssl-1.1.1k.
pushd /tmp/openssl-1.1.1k && ./Configure mingw64 no-shared no-asm no-err no-tests CROSS_COMPILE=x86_64-w64-mingw32- && make -j3 && popd

libxlsxwriter-1.0.6 was built in /tmp/libxlsxwriter-1.0.6.

Since both libxlsxwriter and openssl now both define the MD5_* functions, I can't link anymore. This is resolved for now by building libxlsxwriter without MD5 support; however, I lose some functionality with this fix.

My suggested fix: if -DBUILD_SHARED_LIBS=off and USE_OPENSSL_MD5 is on, declare the MD5_* functions as "externs" so that they can be linked in. Alternatively, the static build for libxlsxwriter should build in the static openssl library (please don't do this). Another alternative is to use different function names for the internal MD5 routines like they were before.

<!-- gh-comment-id:868812713 --> @squinky86 commented on GitHub (Jun 25, 2021): Absolutely: 1) Static build openssl 2) Static build libxlsxwriter with -DBUILD_SHARED_LIBS=off and -DUSE_OPENSSL_MD5=on 3) create a project that attempts to then statically link both libxlsxwriter and openssl 4) Watch what happens when you try to statically link everything in: ``` /usr/bin/x86_64-w64-mingw32-ld: /tmp/openssl-1.1.1k/libcrypto.a(md5_dgst.o):md5_dgst.c:(.text+0x0): multiple definition of `MD5_Init'; /tmp/libxlsxwriter-RELEASE_1.0.6/libxlsxwriter.a(md5.c.obj):md5.c:(.text+0x835): first defined here /usr/bin/x86_64-w64-mingw32-ld: /tmp/openssl-1.1.1k/libcrypto.a(md5_dgst.o):md5_dgst.c:(.text+0x8bc): multiple definition of `MD5_Update'; /tmp/libxlsxwriter-RELEASE_1.0.6/libxlsxwriter.a(md5.c.obj):md5.c:(.text+0x859): first defined here /usr/bin/x86_64-w64-mingw32-ld: /tmp/openssl-1.1.1k/libcrypto.a(md5_dgst.o):md5_dgst.c:(.text+0x9bb): multiple definition of `MD5_Final'; /tmp/libxlsxwriter-RELEASE_1.0.6/libxlsxwriter.a(md5.c.obj):md5.c:(.text+0x8f1): first defined here ``` In this example, I built openssl-1.1.1k by cross-compiling into /tmp/openssl-1.1.1k. `pushd /tmp/openssl-1.1.1k && ./Configure mingw64 no-shared no-asm no-err no-tests CROSS_COMPILE=x86_64-w64-mingw32- && make -j3 && popd` libxlsxwriter-1.0.6 was built in /tmp/libxlsxwriter-1.0.6. Since both libxlsxwriter and openssl now both define the MD5_* functions, I can't link anymore. This is resolved for now by building libxlsxwriter without MD5 support; however, I lose some functionality with this fix. My suggested fix: if -DBUILD_SHARED_LIBS=off and USE_OPENSSL_MD5 is on, declare the MD5_* functions as "externs" so that they can be linked in. Alternatively, the static build for libxlsxwriter should build in the static openssl library (please don't do this). Another alternative is to use different function names for the internal MD5 routines like they were before.
Author
Owner

@jmcnamara commented on GitHub (Jun 25, 2021):

This part of the error message is odd since md5.c shouldn't be compiled into the libxlsxwriter.a with USE_OPENSSL_MD5=on:

/tmp/libxlsxwriter-RELEASE_1.0.6/libxlsxwriter.a(md5.c.obj):md5.c:(.text+0x835): first defined here

When I do the following with the option off I get:

$ cd libxlsxwriter
$ cd cmake
$ cmake .. -DUSE_OPENSSL_MD5=off
...
$ make clean
...
$ make
...
[ 92%] Building C object CMakeFiles/xlsxwriter.dir/third_party/tmpfileplus/tmpfileplus.c.o
[ 96%] Building C object CMakeFiles/xlsxwriter.dir/third_party/md5/md5.c.o
[100%] Linking C static library libxlsxwriter.a
[100%] Built target xlsxwriter

$ nm libxlsxwriter.a | grep MD5
                 U _MD5_Final
                 U _MD5_Init
                 U _MD5_Update
0000000000001140 T _MD5_Final
0000000000000000 T _MD5_Init
0000000000000050 T _MD5_Update

As you can see md5.c.o in included and the symbols are in the Text section. Which all looks okay.

And when I compile with it on:

$ cmake .. -DUSE_OPENSSL_MD5=on
...
$ make clean
...
$ make
...
[ 92%] Building C object CMakeFiles/xlsxwriter.dir/third_party/minizip/zip.c.o
[ 96%] Building C object CMakeFiles/xlsxwriter.dir/third_party/tmpfileplus/tmpfileplus.c.o
[100%] Linking C static library libxlsxwriter.a
[100%] Built target xlsxwriter

$ nm libxlsxwriter.a | grep MD5
                 U _MD5_Final
                 U _MD5_Init
                 U _MD5_Update

This time there is no mention of md5.c.o and the symbols are only in the Undefined section. Which again looks okay.

Can you do something similar and check if md5.c is compiled and if the symbols are defined. BUILD_SHARED_LIBS=off isn't required since that is the default.

<!-- gh-comment-id:868879795 --> @jmcnamara commented on GitHub (Jun 25, 2021): This part of the error message is odd since md5.c shouldn't be compiled into the libxlsxwriter.a with `USE_OPENSSL_MD5=on`: ``` /tmp/libxlsxwriter-RELEASE_1.0.6/libxlsxwriter.a(md5.c.obj):md5.c:(.text+0x835): first defined here ``` When I do the following with the option off I get: ``` $ cd libxlsxwriter $ cd cmake $ cmake .. -DUSE_OPENSSL_MD5=off ... $ make clean ... $ make ... [ 92%] Building C object CMakeFiles/xlsxwriter.dir/third_party/tmpfileplus/tmpfileplus.c.o [ 96%] Building C object CMakeFiles/xlsxwriter.dir/third_party/md5/md5.c.o [100%] Linking C static library libxlsxwriter.a [100%] Built target xlsxwriter $ nm libxlsxwriter.a | grep MD5 U _MD5_Final U _MD5_Init U _MD5_Update 0000000000001140 T _MD5_Final 0000000000000000 T _MD5_Init 0000000000000050 T _MD5_Update ``` As you can see md5.c.o in included and the symbols are in the Text section. Which all looks okay. And when I compile with it on: ``` $ cmake .. -DUSE_OPENSSL_MD5=on ... $ make clean ... $ make ... [ 92%] Building C object CMakeFiles/xlsxwriter.dir/third_party/minizip/zip.c.o [ 96%] Building C object CMakeFiles/xlsxwriter.dir/third_party/tmpfileplus/tmpfileplus.c.o [100%] Linking C static library libxlsxwriter.a [100%] Built target xlsxwriter $ nm libxlsxwriter.a | grep MD5 U _MD5_Final U _MD5_Init U _MD5_Update ``` This time there is no mention of md5.c.o and the symbols are only in the Undefined section. Which again looks okay. Can you do something similar and check if md5.c is compiled and if the symbols are defined. `BUILD_SHARED_LIBS=off ` isn't required since that is the default.
Author
Owner

@jmcnamara commented on GitHub (Jul 1, 2021):

@squinky86 Any update on this?

<!-- gh-comment-id:872590619 --> @jmcnamara commented on GitHub (Jul 1, 2021): @squinky86 Any update on this?
Author
Owner

@squinky86 commented on GitHub (Jul 1, 2021):

Thanks for the reminder! I have the test running at https://ci.appveyor.com/project/squinky86/stigqter/builds/39837129 to see if I can reproduce it. It'll be a couple of hours, and I won't be able to check it until tomorrow.

<!-- gh-comment-id:872592973 --> @squinky86 commented on GitHub (Jul 1, 2021): Thanks for the reminder! I have the test running at https://ci.appveyor.com/project/squinky86/stigqter/builds/39837129 to see if I can reproduce it. It'll be a couple of hours, and I won't be able to check it until tomorrow.
Author
Owner

@jmcnamara commented on GitHub (Jul 1, 2021):

Cool. I'll keep an eye on that.

<!-- gh-comment-id:872593589 --> @jmcnamara commented on GitHub (Jul 1, 2021): Cool. I'll keep an eye on that.
Author
Owner

@squinky86 commented on GitHub (Jul 2, 2021):

Well, I botched that one. Perhaps an OPENSSL_INCLUDE_DIR option could be included as well? Trying again (https://ci.appveyor.com/project/squinky86/stigqter/builds/39847906)...

<!-- gh-comment-id:873058434 --> @squinky86 commented on GitHub (Jul 2, 2021): Well, I botched that one. Perhaps an OPENSSL_INCLUDE_DIR option could be included as well? Trying again (https://ci.appveyor.com/project/squinky86/stigqter/builds/39847906)...
Author
Owner

@jmcnamara commented on GitHub (Jul 2, 2021):

Trying again

That looks like it passed. Right?

Perhaps an OPENSSL_INCLUDE_DIR option could be included as well?

I added find_package(OpenSSL REQUIRED) to the CMakeLists.txt file on HEAD.

On Linux it finds the correct include dir and link files. On macOS I had to prompt it a bit like this:

cmake .. -DUSE_OPENSSL_MD5=ON -DBUILD_EXAMPLES=ON -DOPENSSL_ROOT_DIR="/usr/local/Cellar/openssl@1.1/1.1.1k"

Could you try that out and see if it works and/or improves things for you. I want to respin a release later today so if you get a chance to test it that would be great.

<!-- gh-comment-id:873124746 --> @jmcnamara commented on GitHub (Jul 2, 2021): > Trying again That looks like it passed. Right? > Perhaps an OPENSSL_INCLUDE_DIR option could be included as well? I added `find_package(OpenSSL REQUIRED)` to the CMakeLists.txt file on HEAD. On Linux it finds the correct include dir and link files. On macOS I had to prompt it a bit like this: ```` cmake .. -DUSE_OPENSSL_MD5=ON -DBUILD_EXAMPLES=ON -DOPENSSL_ROOT_DIR="/usr/local/Cellar/openssl@1.1/1.1.1k" ```` Could you try that out and see if it works and/or improves things for you. I want to respin a release later today so if you get a chance to test it that would be great.
Author
Owner

@squinky86 commented on GitHub (Jul 2, 2021):

That does look like it's working. I'm good closing this issue (and sincerely thank you for your time for helping me debug).

I'll try the OPENSSL_ROOT_DIR on the next build. Thanks!

<!-- gh-comment-id:873184412 --> @squinky86 commented on GitHub (Jul 2, 2021): That does look like it's working. I'm good closing this issue (and sincerely thank you for your time for helping me debug). I'll try the OPENSSL_ROOT_DIR on the next build. Thanks!
Author
Owner

@jmcnamara commented on GitHub (Jul 3, 2021):

Thanks to you too for the debugging. Closing.

<!-- gh-comment-id:873378494 --> @jmcnamara commented on GitHub (Jul 3, 2021): Thanks to you too for the debugging. Closing.
Author
Owner

@squinky86 commented on GitHub (Jul 13, 2021):

Hey @jmcnamara - I'm having trouble with 1.0.8+. After cross-compiling openssl in /tmp/openssl-1.1.1k and zlib into /tmp/zlib-1.2.11, I try to build libxlsxwriter with:
cmake -DUSE_STANDARD_TMPFILE=OFF -DCMAKE_TOOLCHAIN_FILE=/tmp/profile.cmake -DBUILD_SHARED_LIBS=OFF -DZLIB_INCLUDE_DIR=/tmp/zlib-1.2.11 -DZLIB_LIBRARY=/tmp/zlib-1.2.11/libzlibstatic.a -DUSE_OPENSSL_MD5=ON -DCMAKE_C_FLAGS=-I/tmp/openssl-1.1.1k/include -DOPENSSL_ROOT_DIR=/tmp/openssl-1.1.1k
but get the following error:

-- Found ZLIB: /tmp/zlib-1.2.11/libzlibstatic.a (found version "1.2.11") 
zlib version: 
CMake Error at /usr/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
  system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY) (found
  version "1.1.1f")
Call Stack (most recent call first):
  /usr/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.20/Modules/FindOpenSSL.cmake:570 (find_package_handle_standard_args)
  CMakeLists.txt:256 (find_package)
<!-- gh-comment-id:879398084 --> @squinky86 commented on GitHub (Jul 13, 2021): Hey @jmcnamara - I'm having trouble with 1.0.8+. After cross-compiling openssl in /tmp/openssl-1.1.1k and zlib into /tmp/zlib-1.2.11, I try to build libxlsxwriter with: `cmake -DUSE_STANDARD_TMPFILE=OFF -DCMAKE_TOOLCHAIN_FILE=/tmp/profile.cmake -DBUILD_SHARED_LIBS=OFF -DZLIB_INCLUDE_DIR=/tmp/zlib-1.2.11 -DZLIB_LIBRARY=/tmp/zlib-1.2.11/libzlibstatic.a -DUSE_OPENSSL_MD5=ON -DCMAKE_C_FLAGS=-I/tmp/openssl-1.1.1k/include -DOPENSSL_ROOT_DIR=/tmp/openssl-1.1.1k` but get the following error: ``` -- Found ZLIB: /tmp/zlib-1.2.11/libzlibstatic.a (found version "1.2.11") zlib version: CMake Error at /usr/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:230 (message): Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY) (found version "1.1.1f") Call Stack (most recent call first): /usr/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE) /usr/share/cmake-3.20/Modules/FindOpenSSL.cmake:570 (find_package_handle_standard_args) CMakeLists.txt:256 (find_package) ```
Author
Owner

@jmcnamara commented on GitHub (Jul 13, 2021):

@squinky86 what OS are you using? I can't reproduce this on macOS 10.14.6:

cd /tmp

# Fetch and build zlib
curl -L -O http://www.zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
cd ..

# Fetch and build openssl
curl -L -O https://www.openssl.org/source/openssl-1.1.1k.tar.gz
tar -zxvf openssl-1.1.1k.tar.gz
cd openssl-1.1.1k
./config
make -j 3
cd ..

# Get
git clone https://github.com/jmcnamara/libxlsxwriter.git
cd libxlsxwriter/cmake/
cmake -DUSE_STANDARD_TMPFILE=OFF -DBUILD_SHARED_LIBS=OFF -DZLIB_ROOT=/tmp/zlib-1.2.11/ -DUSE_OPENSSL_MD5=ON -DOPENSSL_ROOT_DIR=/tmp/openssl-1.1.1k ..
make

# This builds cleanly as shown below.

$ cmake -DUSE_STANDARD_TMPFILE=OFF -DBUILD_SHARED_LIBS=OFF -DZLIB_ROOT=/tmp/zlib-1.2.11/ -DUSE_OPENSSL_MD5=ON -DOPENSSL_ROOT_DIR=/tmp/openssl-1.1.1k ..
-- The C compiler identification is AppleClang 11.0.0.11000033
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- The CXX compiler identification is AppleClang 11.0.0.11000033
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ZLIB: /tmp/zlib-1.2.11/libz.dylib (found version "1.2.11")
zlib version:
-- Found OpenSSL: /tmp/openssl-1.1.1k/libcrypto.dylib (found version "1.1.1k")
-- OpenSSL version: 1.1.1k
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/libxlsxwriter/cmake

$ make
Scanning dependencies of target xlsxwriter
[  4%] Building C object CMakeFiles/xlsxwriter.dir/src/app.c.o
[  8%] Building C object CMakeFiles/xlsxwriter.dir/src/chart.c.o
[ 12%] Building C object CMakeFiles/xlsxwriter.dir/src/chartsheet.c.o
[ 16%] Building C object CMakeFiles/xlsxwriter.dir/src/comment.c.o
[ 20%] Building C object CMakeFiles/xlsxwriter.dir/src/content_types.c.o
[ 24%] Building C object CMakeFiles/xlsxwriter.dir/src/core.c.o
[ 28%] Building C object CMakeFiles/xlsxwriter.dir/src/custom.c.o
[ 32%] Building C object CMakeFiles/xlsxwriter.dir/src/drawing.c.o
[ 36%] Building C object CMakeFiles/xlsxwriter.dir/src/format.c.o
[ 40%] Building C object CMakeFiles/xlsxwriter.dir/src/hash_table.c.o
[ 44%] Building C object CMakeFiles/xlsxwriter.dir/src/metadata.c.o
[ 48%] Building C object CMakeFiles/xlsxwriter.dir/src/packager.c.o
[ 52%] Building C object CMakeFiles/xlsxwriter.dir/src/relationships.c.o
[ 56%] Building C object CMakeFiles/xlsxwriter.dir/src/shared_strings.c.o
[ 60%] Building C object CMakeFiles/xlsxwriter.dir/src/styles.c.o
[ 64%] Building C object CMakeFiles/xlsxwriter.dir/src/theme.c.o
[ 68%] Building C object CMakeFiles/xlsxwriter.dir/src/utility.c.o
[ 72%] Building C object CMakeFiles/xlsxwriter.dir/src/vml.c.o
[ 76%] Building C object CMakeFiles/xlsxwriter.dir/src/workbook.c.o
[ 80%] Building C object CMakeFiles/xlsxwriter.dir/src/worksheet.c.o
[ 84%] Building C object CMakeFiles/xlsxwriter.dir/src/xmlwriter.c.o
[ 88%] Building C object CMakeFiles/xlsxwriter.dir/third_party/minizip/ioapi.c.o
[ 92%] Building C object CMakeFiles/xlsxwriter.dir/third_party/minizip/zip.c.o
[ 96%] Building C object CMakeFiles/xlsxwriter.dir/third_party/tmpfileplus/tmpfileplus.c.o
[100%] Linking C static library libxlsxwriter.a
[100%] Built target xlsxwriter
<!-- gh-comment-id:879457900 --> @jmcnamara commented on GitHub (Jul 13, 2021): @squinky86 what OS are you using? I can't reproduce this on macOS 10.14.6: ```bash cd /tmp # Fetch and build zlib curl -L -O http://www.zlib.net/zlib-1.2.11.tar.gz tar -zxvf zlib-1.2.11.tar.gz cd zlib-1.2.11 ./configure make cd .. # Fetch and build openssl curl -L -O https://www.openssl.org/source/openssl-1.1.1k.tar.gz tar -zxvf openssl-1.1.1k.tar.gz cd openssl-1.1.1k ./config make -j 3 cd .. # Get git clone https://github.com/jmcnamara/libxlsxwriter.git cd libxlsxwriter/cmake/ cmake -DUSE_STANDARD_TMPFILE=OFF -DBUILD_SHARED_LIBS=OFF -DZLIB_ROOT=/tmp/zlib-1.2.11/ -DUSE_OPENSSL_MD5=ON -DOPENSSL_ROOT_DIR=/tmp/openssl-1.1.1k .. make # This builds cleanly as shown below. $ cmake -DUSE_STANDARD_TMPFILE=OFF -DBUILD_SHARED_LIBS=OFF -DZLIB_ROOT=/tmp/zlib-1.2.11/ -DUSE_OPENSSL_MD5=ON -DOPENSSL_ROOT_DIR=/tmp/openssl-1.1.1k .. -- The C compiler identification is AppleClang 11.0.0.11000033 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped -- Detecting C compile features -- Detecting C compile features - done -- The CXX compiler identification is AppleClang 11.0.0.11000033 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found ZLIB: /tmp/zlib-1.2.11/libz.dylib (found version "1.2.11") zlib version: -- Found OpenSSL: /tmp/openssl-1.1.1k/libcrypto.dylib (found version "1.1.1k") -- OpenSSL version: 1.1.1k -- Configuring done -- Generating done -- Build files have been written to: /tmp/libxlsxwriter/cmake $ make Scanning dependencies of target xlsxwriter [ 4%] Building C object CMakeFiles/xlsxwriter.dir/src/app.c.o [ 8%] Building C object CMakeFiles/xlsxwriter.dir/src/chart.c.o [ 12%] Building C object CMakeFiles/xlsxwriter.dir/src/chartsheet.c.o [ 16%] Building C object CMakeFiles/xlsxwriter.dir/src/comment.c.o [ 20%] Building C object CMakeFiles/xlsxwriter.dir/src/content_types.c.o [ 24%] Building C object CMakeFiles/xlsxwriter.dir/src/core.c.o [ 28%] Building C object CMakeFiles/xlsxwriter.dir/src/custom.c.o [ 32%] Building C object CMakeFiles/xlsxwriter.dir/src/drawing.c.o [ 36%] Building C object CMakeFiles/xlsxwriter.dir/src/format.c.o [ 40%] Building C object CMakeFiles/xlsxwriter.dir/src/hash_table.c.o [ 44%] Building C object CMakeFiles/xlsxwriter.dir/src/metadata.c.o [ 48%] Building C object CMakeFiles/xlsxwriter.dir/src/packager.c.o [ 52%] Building C object CMakeFiles/xlsxwriter.dir/src/relationships.c.o [ 56%] Building C object CMakeFiles/xlsxwriter.dir/src/shared_strings.c.o [ 60%] Building C object CMakeFiles/xlsxwriter.dir/src/styles.c.o [ 64%] Building C object CMakeFiles/xlsxwriter.dir/src/theme.c.o [ 68%] Building C object CMakeFiles/xlsxwriter.dir/src/utility.c.o [ 72%] Building C object CMakeFiles/xlsxwriter.dir/src/vml.c.o [ 76%] Building C object CMakeFiles/xlsxwriter.dir/src/workbook.c.o [ 80%] Building C object CMakeFiles/xlsxwriter.dir/src/worksheet.c.o [ 84%] Building C object CMakeFiles/xlsxwriter.dir/src/xmlwriter.c.o [ 88%] Building C object CMakeFiles/xlsxwriter.dir/third_party/minizip/ioapi.c.o [ 92%] Building C object CMakeFiles/xlsxwriter.dir/third_party/minizip/zip.c.o [ 96%] Building C object CMakeFiles/xlsxwriter.dir/third_party/tmpfileplus/tmpfileplus.c.o [100%] Linking C static library libxlsxwriter.a [100%] Built target xlsxwriter ```
Author
Owner

@jmcnamara commented on GitHub (Jul 13, 2021):

I also tried the same commands on Fedora 32 and they worked fine as well.

Note that my cmake args are slightly paired down from yours. The -DZLIB_INCLUDE_DIR and -DZLIB_LIBRARY are result variables rather than input variables and aren't needed (see https://cmake.org/cmake/help/latest/module/FindZLIB.html). I used -DZLIB_ROOT instead but that isn't relevant to your issue since cmake finds a zlib version. I also left out -DCMAKE_C_FLAGS which shouldn't be required.

<!-- gh-comment-id:879462680 --> @jmcnamara commented on GitHub (Jul 13, 2021): I also tried the same commands on Fedora 32 and they worked fine as well. Note that my cmake args are slightly paired down from yours. The `-DZLIB_INCLUDE_DIR` and `-DZLIB_LIBRARY` are result variables rather than input variables and aren't needed (see https://cmake.org/cmake/help/latest/module/FindZLIB.html). I used `-DZLIB_ROOT` instead but that isn't relevant to your issue since cmake finds a zlib version. I also left out `-DCMAKE_C_FLAGS` which shouldn't be required.
Author
Owner

@jmcnamara commented on GitHub (Jul 13, 2021):

Also make sure that libcrypto compiled correctly in your openssl directory. You should have something like:

/tmp/openssl-1.1.1k/libcrypto.a
<!-- gh-comment-id:879463927 --> @jmcnamara commented on GitHub (Jul 13, 2021): Also make sure that libcrypto compiled correctly in your openssl directory. You should have something like: /tmp/openssl-1.1.1k/libcrypto.a
Author
Owner

@squinky86 commented on GitHub (Jul 14, 2021):

Cross-compiling on linux on Ubuntu 20.04 using the g++-mingw-w64-x86-64 package:

/tmp/profile.cmake:

set(CMAKE_SYSTEM_NAME Windows)
set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++)
set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran)
set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres)
set(CMAKE_FIND_ROOT_PATH /usr/)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_C_FLAGS_RELEASE "-m64 -Os")
set(CMAKE_CXX_FLAGS_RELEASE "-m64 -Os")

zlib compile:
pushd /tmp/zlib-1.2.11 && cmake ./ -DCMAKE_TOOLCHAIN_FILE=/tmp/profile.cmake -DBUILD_SHARED_LIBS=OFF && make -j3 && popd

openssl compile:
pushd /tmp/openssl-1.1.1k && ./Configure mingw64 no-shared no-asm no-err no-tests CROSS_COMPILE=x86_64-w64-mingw32- && make -j3 && popd

libxlsxwrwiter compile:
pushd /tmp/libxlsxwriter-RELEASE_1.1.0 && cmake -DUSE_STANDARD_TMPFILE=OFF -DCMAKE_TOOLCHAIN_FILE=/tmp/profile.cmake -DBUILD_SHARED_LIBS=OFF -DZLIB_INCLUDE_DIR=/tmp/zlib-1.2.11 -DZLIB_LIBRARY=/tmp/zlib-1.2.11/libzlibstatic.a -DUSE_OPENSSL_MD5=ON -DCMAKE_C_FLAGS=-I/tmp/openssl-1.1.1k/include -DOPENSSL_ROOT_DIR=/tmp/openssl-1.1.1k && make -j3 && popd

...
-- Found ZLIB: /tmp/zlib-1.2.11/libzlibstatic.a (found version "1.2.11") 
zlib version: 
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
  system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY
  OPENSSL_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.16/Modules/FindOpenSSL.cmake:447 (find_package_handle_standard_args)
  CMakeLists.txt:256 (find_package)

Attempt 2:
cmake -DUSE_STANDARD_TMPFILE=OFF -DCMAKE_TOOLCHAIN_FILE=/tmp/profile.cmake -DBUILD_SHARED_LIBS=OFF -DZLIB_INCLUDE_DIR=/tmp/zlib-1.2.11 -DZLIB_LIBRARY=/tmp/zlib-1.2.11/libzlibstatic.a -DUSE_OPENSSL_MD5=ON -DCMAKE_C_FLAGS=-I/tmp/openssl-1.1.1k/include -DOPENSSL_CRYPTO_LIBRARY=/tmp/openssl-1.1.1k/libcrypto.a -DOPENSSL_ROOT_DIR=/tmp/openssl-1.1.1k

zlib version: 
CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
  system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY) (found
  version "1.1.1k")
Call Stack (most recent call first):
  /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.16/Modules/FindOpenSSL.cmake:447 (find_package_handle_standard_args)
  CMakeLists.txt:256 (find_package)

And I acknowledge some of the flags are probably redundant at this point. You can probably tell I tried a lot of different things to get this working ;)

<!-- gh-comment-id:879900734 --> @squinky86 commented on GitHub (Jul 14, 2021): Cross-compiling on linux on Ubuntu 20.04 using the g++-mingw-w64-x86-64 package: /tmp/profile.cmake: ``` set(CMAKE_SYSTEM_NAME Windows) set(TOOLCHAIN_PREFIX x86_64-w64-mingw32) set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) set(CMAKE_Fortran_COMPILER ${TOOLCHAIN_PREFIX}-gfortran) set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres) set(CMAKE_FIND_ROOT_PATH /usr/) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) set(CMAKE_C_FLAGS_RELEASE "-m64 -Os") set(CMAKE_CXX_FLAGS_RELEASE "-m64 -Os") ``` zlib compile: `pushd /tmp/zlib-1.2.11 && cmake ./ -DCMAKE_TOOLCHAIN_FILE=/tmp/profile.cmake -DBUILD_SHARED_LIBS=OFF && make -j3 && popd` openssl compile: `pushd /tmp/openssl-1.1.1k && ./Configure mingw64 no-shared no-asm no-err no-tests CROSS_COMPILE=x86_64-w64-mingw32- && make -j3 && popd` libxlsxwrwiter compile: `pushd /tmp/libxlsxwriter-RELEASE_1.1.0 && cmake -DUSE_STANDARD_TMPFILE=OFF -DCMAKE_TOOLCHAIN_FILE=/tmp/profile.cmake -DBUILD_SHARED_LIBS=OFF -DZLIB_INCLUDE_DIR=/tmp/zlib-1.2.11 -DZLIB_LIBRARY=/tmp/zlib-1.2.11/libzlibstatic.a -DUSE_OPENSSL_MD5=ON -DCMAKE_C_FLAGS=-I/tmp/openssl-1.1.1k/include -DOPENSSL_ROOT_DIR=/tmp/openssl-1.1.1k && make -j3 && popd` ``` ... -- Found ZLIB: /tmp/zlib-1.2.11/libzlibstatic.a (found version "1.2.11") zlib version: CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message): Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR) Call Stack (most recent call first): /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE) /usr/share/cmake-3.16/Modules/FindOpenSSL.cmake:447 (find_package_handle_standard_args) CMakeLists.txt:256 (find_package) ``` Attempt 2: `cmake -DUSE_STANDARD_TMPFILE=OFF -DCMAKE_TOOLCHAIN_FILE=/tmp/profile.cmake -DBUILD_SHARED_LIBS=OFF -DZLIB_INCLUDE_DIR=/tmp/zlib-1.2.11 -DZLIB_LIBRARY=/tmp/zlib-1.2.11/libzlibstatic.a -DUSE_OPENSSL_MD5=ON -DCMAKE_C_FLAGS=-I/tmp/openssl-1.1.1k/include -DOPENSSL_CRYPTO_LIBRARY=/tmp/openssl-1.1.1k/libcrypto.a -DOPENSSL_ROOT_DIR=/tmp/openssl-1.1.1k` ``` zlib version: CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message): Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY) (found version "1.1.1k") Call Stack (most recent call first): /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE) /usr/share/cmake-3.16/Modules/FindOpenSSL.cmake:447 (find_package_handle_standard_args) CMakeLists.txt:256 (find_package) ``` And I acknowledge some of the flags are probably redundant at this point. You can probably tell I tried a lot of different things to get this working ;)
Author
Owner

@jmcnamara commented on GitHub (Jul 14, 2021):

I was able to reproduce the build issue using your instructions on Fedora 32.

I don't know what the issue is. I suspect that the error message is a bit of a red herring and Cmake can't find libcrypto.a rather than OpenSSL. It may expect a different extension or prefix. I tried a variety of fixes with OPENSSL_USE_STATIC_LIBS and other workarounds but without success.

If I get a chance I'll compile it in a real mingw environment on Windows and see if it gives any clues.

<!-- gh-comment-id:880192978 --> @jmcnamara commented on GitHub (Jul 14, 2021): I was able to reproduce the build issue using your instructions on Fedora 32. I don't know what the issue is. I suspect that the error message is a bit of a red herring and Cmake can't find libcrypto.a rather than OpenSSL. It may expect a different extension or prefix. I tried a variety of fixes with `OPENSSL_USE_STATIC_LIBS` and other workarounds but without success. If I get a chance I'll compile it in a real mingw environment on Windows and see if it gives any clues.
Author
Owner

@squinky86 commented on GitHub (Jul 15, 2021):

FYI, I am able to duplicate it in cygwin as well using the mingw64-x86_64-gcc 10.2.0 (stable) and 11.1.0 (testing) packages. This does appear to be more of a weird cmake issue than a libxlsxwriter issue, but I have no idea what needs to be documented to write this up as a cmake bug at this point.

<!-- gh-comment-id:880869860 --> @squinky86 commented on GitHub (Jul 15, 2021): FYI, I am able to duplicate it in cygwin as well using the mingw64-x86_64-gcc 10.2.0 (stable) and 11.1.0 (testing) packages. This does appear to be more of a weird cmake issue than a libxlsxwriter issue, but I have no idea what needs to be documented to write this up as a cmake bug at this point.
Author
Owner

@jmcnamara commented on GitHub (Jul 15, 2021):

I think I found the issue.

This line in profile.cmake file puts /usr/ before the search paths so that Cmake is looking in /usr/tmp instead of /tmp:

set(CMAKE_FIND_ROOT_PATH /usr/)

Just comment that out or remove it, unless you have some very specific reason for using it.

I also had to change this line in the Libxlsxwriter CMakeList.txt:

enable_language(CXX)

To this:

enable_language(C)

To avoid an error about a missing CMAKE_CXX_COMPILER but you may have g++ installed. I think I only installed gcc.

Anyway, after those fixes everything compiled for me on Fedora.

<!-- gh-comment-id:881064527 --> @jmcnamara commented on GitHub (Jul 15, 2021): I think I found the issue. This line in `profile.cmake` file puts `/usr/` before the search paths so that Cmake is looking in `/usr/tmp` instead of `/tmp`: set(CMAKE_FIND_ROOT_PATH /usr/) Just comment that out or remove it, unless you have some very specific reason for using it. I also had to change this line in the Libxlsxwriter CMakeList.txt: enable_language(CXX) To this: enable_language(C) To avoid an error about a missing CMAKE_CXX_COMPILER but you may have g++ installed. I think I only installed gcc. Anyway, after those fixes everything compiled for me on Fedora.
Author
Owner

@jmcnamara commented on GitHub (Jul 20, 2021):

@squinky86 Any update on this?

<!-- gh-comment-id:883665675 --> @jmcnamara commented on GitHub (Jul 20, 2021): @squinky86 Any update on this?
Author
Owner

@squinky86 commented on GitHub (Apr 6, 2022):

For anyone coming from google: adding "/" to the CMAKE_FIND_ROOT_PATH also resolved this. It's all working now - thanks!

<!-- gh-comment-id:1090426191 --> @squinky86 commented on GitHub (Apr 6, 2022): For anyone coming from google: adding "/" to the CMAKE_FIND_ROOT_PATH also resolved this. It's all working now - thanks!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/libxlsxwriter#276
No description provided.