[GH-ISSUE #124] Guide: How to build under Qt-Creator / Windows (MinGW) #104

Closed
opened 2026-05-05 11:41:03 -06:00 by gitea-mirror · 5 comments
Owner

Originally created by @petricf on GitHub (Sep 4, 2017).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/124

Originally assigned to: @jmcnamara on GitHub.

Qt-Creator (http://qt.io) is a multi-platform/-compiler IDE. Platform here: Windows 7
Under Windows (if you want to avoid MS VisualStudio) you can use the MingGW compiler bundled with it. mingw32_make.exe is also included.
This guide is to build libxlsxwriter w/o installing MSYS (how i did it). Reason: Minimize packages to be installed and use the MinGW-compiler bundled with Qt-Creator.

  1. Get CMake (https://cmake.org/download/) - 64 or 32Bit should be irrelevant - and install it
  2. Get Zlib (http://gnuwin32.sourceforge.net/packages/zlib.htm) - both binaries and developer files *.zip
  3. Unpack developer files to (in my case) C:/Qt/Tools/zlib/*
    3.a. Unpack contents bin directory from binary files to C:/Qt/Tools/zlib/lib/*
  4. Clone or unpack release to a project dir
  5. Start Qt-Creator
    5.a. Menu "Extras" -> Settings
    5.b. Select "Build and Execution"
    5.c. Select Tab "CMake" and define the Location of cmake.exe (from Step 1)
    5.d. Select Tab "Kits" and choose the Kit (here: Desktop Qt 5.9.0 MinGW 5.3.0)
    5.e. In the lines appearing below labeled "CMake-Tool" select the CMake defined in 5.c.
    5.e. At the last line labeled "CMake-Configuration" push the button "Change"
    5.f. In the dialog box appearing then add the lines (path value given at Step 3):

ZLIB_INCLUDE_DIR:FILEPATH=C:/Qt/Tools/zlib/include
ZLIB_LIBRARY:FILEPATH=C:/Qt/Tools/zlib/lib/zlib.lib

Remark: ZLIB_ROOT setting does not work (at least not here)
  1. Create a new session/project and open CMakeLists.txt (CMake analysis step starts immediately)
  2. Press the compile button (or menu item).
  3. Option: Copy the resulting libxlslibwriter.a and the includes to C:/Qt/Tools/xlsxlib/[include|lib]

One problem i have currently is that it only creates a static library but no shared library (aka *.dll).

In a project using libxlsxwriter the qmake *.pro file requires two lines:

INLCLUDEPATH += [directory of libxlsxwriter includes]
LIBS += -L[directory of libxlsxwriter.a] -lxlsxwriter.a -lz

The zlib used to build xlsxwriter above is no more required - Qt comes with a own version but misses zlib.lib required for linking libxlsxwriter.

Hope that helps.

Originally created by @petricf on GitHub (Sep 4, 2017). Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/124 Originally assigned to: @jmcnamara on GitHub. Qt-Creator (http://qt.io) is a multi-platform/-compiler IDE. Platform here: Windows 7 Under Windows (if you want to avoid MS VisualStudio) you can use the MingGW compiler bundled with it. mingw32_make.exe is also included. This guide is to build libxlsxwriter w/o installing MSYS (how i did it). Reason: Minimize packages to be installed and use the MinGW-compiler bundled with Qt-Creator. 1. Get CMake (https://cmake.org/download/) - 64 or 32Bit should be irrelevant - and install it 2. Get Zlib (http://gnuwin32.sourceforge.net/packages/zlib.htm) - both binaries and developer files *.zip 3. Unpack developer files to (in my case) C:/Qt/Tools/zlib/* 3.a. Unpack contents bin directory from binary files to C:/Qt/Tools/zlib/lib/* 4. Clone or unpack release to a project dir 5. Start Qt-Creator 5.a. Menu "Extras" -> Settings 5.b. Select "Build and Execution" 5.c. Select Tab "CMake" and define the Location of cmake.exe (from Step 1) 5.d. Select Tab "Kits" and choose the Kit (here: Desktop Qt 5.9.0 MinGW 5.3.0) 5.e. In the lines appearing below labeled "CMake-Tool" select the CMake defined in 5.c. 5.e. At the last line labeled "CMake-Configuration" push the button "Change" 5.f. In the dialog box appearing then add the lines (path value given at Step 3): > ZLIB_INCLUDE_DIR:FILEPATH=C:/Qt/Tools/zlib/include > ZLIB_LIBRARY:FILEPATH=C:/Qt/Tools/zlib/lib/zlib.lib Remark: ZLIB_ROOT setting does not work (at least not here) 6. Create a new session/project and open CMakeLists.txt (CMake analysis step starts immediately) 7. Press the compile button (or menu item). 8. Option: Copy the resulting libxlslibwriter.a and the includes to C:/Qt/Tools/xlsxlib/[include|lib] One problem i have currently is that it only creates a static library but no shared library (aka *.dll). In a project using libxlsxwriter the qmake *.pro file requires two lines: > INLCLUDEPATH += [directory of libxlsxwriter includes] > LIBS += -L[directory of libxlsxwriter.a] -lxlsxwriter.a -lz The zlib used to build xlsxwriter above is no more required - Qt comes with a own version but misses zlib.lib required for linking libxlsxwriter. Hope that helps.
gitea-mirror 2026-05-05 11:41:04 -06:00
Author
Owner

@jmcnamara commented on GitHub (Sep 5, 2017):

Thanks. Those are useful instructions. When I get a chance I'll try it out and maybe add it to the docs.

It would probably be useful would be if you uploaded a sample QT project to Github.

<!-- gh-comment-id:327108205 --> @jmcnamara commented on GitHub (Sep 5, 2017): Thanks. Those are useful instructions. When I get a chance I'll try it out and maybe add it to the docs. It would probably be useful would be if you uploaded a sample QT project to Github.
Author
Owner

@petricf commented on GitHub (Sep 22, 2017):

Attached a sample Qt GUI application designed like the minimal test in your package.

Simply open the *.pro file inside the Qt-Creator IDE (downloaded/installed from http://qt.io).

The *.pro file contains the reference to the includes and libs created in the steps above. I copied them to C:\Qt\Tools\xlsxwriter\include and C:\Qt\Tools\xlsxwriter\libs.

Hope it helps. Sorry i am currently not good in using git.

xlsxwriter-test.zip

<!-- gh-comment-id:331556198 --> @petricf commented on GitHub (Sep 22, 2017): Attached a sample Qt GUI application designed like the minimal test in your package. Simply open the *.pro file inside the Qt-Creator IDE (downloaded/installed from http://qt.io). The *.pro file contains the reference to the includes and libs created in the steps above. I copied them to C:\Qt\Tools\xlsxwriter\include and C:\Qt\Tools\xlsxwriter\libs. Hope it helps. Sorry i am currently not good in using git. [xlsxwriter-test.zip](https://github.com/jmcnamara/libxlsxwriter/files/1325769/xlsxwriter-test.zip)
Author
Owner

@petricf commented on GitHub (Sep 22, 2017):

Oh, i forgot - sure this is an application simply using the C-interface of libxlsxwriter directly.

Currently i am designing Qt classes inspired by https://github.com/Alexhuszagh/libxlsxwriterpp.

<!-- gh-comment-id:331557209 --> @petricf commented on GitHub (Sep 22, 2017): Oh, i forgot - sure this is an application simply using the C-interface of libxlsxwriter directly. Currently i am designing Qt classes inspired by https://github.com/Alexhuszagh/libxlsxwriterpp.
Author
Owner

@jmcnamara commented on GitHub (Sep 23, 2017):

Thanks for the contribution. I'm sure someone will find it useful.

<!-- gh-comment-id:331595394 --> @jmcnamara commented on GitHub (Sep 23, 2017): Thanks for the contribution. I'm sure someone will find it useful.
Author
Owner

@petricf commented on GitHub (Jan 21, 2020):

Released a new guide at Issue #270

<!-- gh-comment-id:576612905 --> @petricf commented on GitHub (Jan 21, 2020): Released a new guide at Issue #270
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#104
No description provided.