<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to use QZXing with cmake Qt 6.4]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">I'm trying to use QZXing's encode and decode functions in my project. How does this work with cmake with Qt 6.4.0?</p>
<p dir="auto">The latest thing I've tried is:</p>
<ul>
<li>
<p dir="auto">Adding the qzxing directory to my project then adding the following to my base project's CMakeLists.txt</p>
<pre><code>SET(QZXING_USE_ENCODER ON)
SET(ENABLE_ENCODER_GENERIC ON)
SET(ENABLE_ENCODER_QR_CODE ON)
add_subdirectory(./qzxing/src)
</code></pre>
<p dir="auto">Then, in one of my project files I <code>#include "./qzxing/src/QZXing.h"</code> and try to use <a href="https://github.com/ftylitak/qzxing#cqt-1" target="_blank" rel="noopener noreferrer nofollow ugc">QZXing's example in their repo</a>:</p>
<pre><code>QString data = "text to be encoded";
QImage barcode = QZXing::encodeData(data, QZXing::EncoderFormat_QR_CODE, QSize(width.toInt(), height.toInt()), 
QZXing::EncodeErrorCorrectionLevel_H);
</code></pre>
<p dir="auto">I don't get any errors after adding the above, but when I try to build, I get the following error:</p>
<pre><code>:-1: error: error: undefined symbol: QZXing::encodeData(QString const&amp;,QZXing::EncoderFormat, QSize,QZXing::EncodeErrorCorrectionLevel, bool, bool)
</code></pre>
<p dir="auto">I'm assuming that the above error is because the <code>.cpp</code> files aren't included with the project, so no function definitions. I haven't been able to find the correct cmake commands to do this, though (if that is the issue here).</p>
</li>
</ul>
]]></description><link>https://forum.qt.io/topic/140471/how-to-use-qzxing-with-cmake-qt-6-4</link><generator>RSS for Node</generator><lastBuildDate>Thu, 05 Nov 2026 03:01:42 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/140471.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 01 Nov 2022 20:19:12 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to use QZXing with cmake Qt 6.4 on Wed, 02 Nov 2022 08:48:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/gween">@<bdi>gween</bdi></a> You could build qzxing as a library and then link this library to your project using target_link_libraries.</p>
]]></description><link>https://forum.qt.io/post/734809</link><guid isPermaLink="true">https://forum.qt.io/post/734809</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Wed, 02 Nov 2022 08:48:28 GMT</pubDate></item><item><title><![CDATA[Reply to How to use QZXing with cmake Qt 6.4 on Sat, 11 Mar 2023 15:37:33 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/gween">@<bdi>gween</bdi></a> How do you use QZing? His CMake use QT5</p>
]]></description><link>https://forum.qt.io/post/750713</link><guid isPermaLink="true">https://forum.qt.io/post/750713</guid><dc:creator><![CDATA[niqt]]></dc:creator><pubDate>Sat, 11 Mar 2023 15:37:33 GMT</pubDate></item><item><title><![CDATA[Reply to How to use QZXing with cmake Qt 6.4 on Tue, 29 Nov 2022 15:01:52 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a>'s answer is correct:</p>
<blockquote>
<p dir="auto">You could build qzxing as a library and then link this library to your project using target_link_libraries.</p>
</blockquote>
<p dir="auto">This was my complete misunderstanding of cmake and how it works.</p>
<pre><code># with qzxing/src copied to my project as QZXing
add_subdirectory(./QZXing/)
target_link_libraries(${PROJECT_NAME} qzxing)
</code></pre>
<p dir="auto">My misunderstanding was from two things:</p>
<ol>
<li>I thought the command <code>add_subdirectory()</code> was the only thing that should have been needed</li>
<li>That I had to use the library name that is specified in the <code>QZXing/CMakeLists.txt</code>, which, from this command <code>add_library(qzxing "" ${SOURCES})</code> is <code>qzxing</code>.</li>
</ol>
]]></description><link>https://forum.qt.io/post/738222</link><guid isPermaLink="true">https://forum.qt.io/post/738222</guid><dc:creator><![CDATA[gween]]></dc:creator><pubDate>Tue, 29 Nov 2022 15:01:52 GMT</pubDate></item><item><title><![CDATA[Reply to How to use QZXing with cmake Qt 6.4 on Fri, 04 Nov 2022 14:04:39 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> the subdirs link you sent makes sense for QMake, but does this work with CMake since I'm using Qt 6.4? My current project doesn't have a <code>.pro</code> file, only a <code>CMakeLists.txt</code> file. Does the <code>subdirs</code> "pattern" apply to projects that only have <code>CMakeLists.txt</code>? I.e. is there a <code>Defining Project Dependencies: .depends attributes</code> type documentation for Qt 6.4 with cmake?</p>
<p dir="auto">The QZXing repo does have a <code>CMakeLists.txt</code> file, <a href="https://github.com/ftylitak/qzxing/blob/master/src/CMakeLists.txt" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/ftylitak/qzxing/blob/master/src/CMakeLists.txt</a>, in its <code>src</code> dir. Which is why I thought I'd just be able to add the repo as a subdirectory to my main project, then use some cmake function, such as <code>add_subdirectory()</code>, to reference the <code>.h</code> and <code>.cpp</code> files.</p>
]]></description><link>https://forum.qt.io/post/735058</link><guid isPermaLink="true">https://forum.qt.io/post/735058</guid><dc:creator><![CDATA[gween]]></dc:creator><pubDate>Fri, 04 Nov 2022 14:04:39 GMT</pubDate></item><item><title><![CDATA[Reply to How to use QZXing with cmake Qt 6.4 on Thu, 03 Nov 2022 06:14:08 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/gween">@<bdi>gween</bdi></a> said in <a href="/post/734887">How to use QZXing with cmake Qt 6.4</a>:</p>
<blockquote>
<p dir="auto">TEMPLATE = lib</p>
</blockquote>
<p dir="auto">It is already built as library.<br />
To make it properly with QMake you should create a <a href="https://wiki.qt.io/SUBDIRS_-_handling_dependencies" target="_blank" rel="noopener noreferrer nofollow ugc">https://wiki.qt.io/SUBDIRS_-_handling_dependencies</a> project. You then add qzxing as one subproject and your actualy project as another one. Then in your project you add qzxing as dependency (see "Defining Project Dependencies: .depends attributes" chapter in the link above).</p>
]]></description><link>https://forum.qt.io/post/734897</link><guid isPermaLink="true">https://forum.qt.io/post/734897</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Thu, 03 Nov 2022 06:14:08 GMT</pubDate></item><item><title><![CDATA[Reply to How to use QZXing with cmake Qt 6.4 on Thu, 03 Nov 2022 01:12:12 GMT]]></title><description><![CDATA[<p dir="auto">I appreciate the response @jsulm.</p>
<p dir="auto">Does building as a library in Qt mean opening the <code>QZXing.pro</code> file in Qt 6.4 and clicking build? When I do so, I get the following error:</p>
<pre><code>:-1: error: No rule to make target 'install'.  Stop.
</code></pre>
<p dir="auto">What file is this install target supposed to be in?<br />
This is the <code>.pro</code> file:</p>
<pre><code>CONFIG += \
          enable_decoder_1d_barcodes \
          enable_decoder_qr_code \
          enable_decoder_data_matrix \
          enable_decoder_aztec \
          enable_decoder_pdf17 \
          enable_encoder_qr_code \
          #staticlib \
          #qzxing_qml \
          #qzxing_multimedia \

VERSION = 3.3

TARGET = QZXing
TEMPLATE = lib

include(QZXing-components.pri)

DEFINES -= DISABLE_LIBRARY_FEATURES
</code></pre>
<p dir="auto">The only thing QZXing mentions about building as a library is <a href="https://github.com/ftylitak/qzxing#compile-the-project-as-an-external-library" target="_blank" rel="noopener noreferrer nofollow ugc">https://github.com/ftylitak/qzxing#compile-the-project-as-an-external-library</a>.</p>
]]></description><link>https://forum.qt.io/post/734887</link><guid isPermaLink="true">https://forum.qt.io/post/734887</guid><dc:creator><![CDATA[gween]]></dc:creator><pubDate>Thu, 03 Nov 2022 01:12:12 GMT</pubDate></item><item><title><![CDATA[Reply to How to use QZXing with cmake Qt 6.4 on Wed, 02 Nov 2022 08:48:28 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/gween">@<bdi>gween</bdi></a> You could build qzxing as a library and then link this library to your project using target_link_libraries.</p>
]]></description><link>https://forum.qt.io/post/734809</link><guid isPermaLink="true">https://forum.qt.io/post/734809</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Wed, 02 Nov 2022 08:48:28 GMT</pubDate></item></channel></rss>