QCA Build on QT5



  • I finally used Cmake and this fixed my issue:

    1. Download Cmake nightly here: http://www.cmake.org/files/dev/?C=M;O=D
    2. Install it
    3. In QT Creator: Tools -> Options -> Build & Run -> Cmake -> Browse... and find you cmake executable (mine is C:\Program Files (x86)\CMake 2.8\bin\cmake.exe)
    4. Download svn://svn.kde.org/trunk/kdesupport/qca/
    5. Download git://anongit.kde.org/extra-cmake-modules
    6. In QT Creator, File -> Open File or project: select the CMakeLists.txt from the extra-cmake-module repository, compile it
    7. In QT Creator, File -> Open File or project: select the CMakeLists.txt from the qca repository, in the arguments, add -DECM_MODULE_PATH C:/extra-cmake-modules-build (replace it with the location of your built extra-cmake-modules)
    8. You have a working QCA, you only need to copy the lib and include folder in your GCC compiler directory (mine is C:\Qt\Qt5.0.1\5.0.1\mingw47_32)
    9. Follow the same steps to compile plugins, QT will tell you that some package can't be found (for example OpenSSL), then define the variable where cmake is supposed to find the package (-DMY_CMAKE_PACKAGE_LOCATION C:/it/is/here)

    Have fun!

    ==================================================================================
    ======> Original message

    Hi,

    I'm trying to compile QCA to use it on QT5.
    That's why I downloaded the sources of QCA using the following link: http://delta.affinix.com/download/qca/2.0/qca-2.0.3.tar.bz2

    I then downloaded the following patch and applied it using git: https://github.com/psi-plus/main/blob/master/patches/dev/qca_qt5.patch

    @C:\qca-2.0.3>patch -p0 < qca_qt5.patch
    patching file examples/cmssigner/certitem.cpp' patching fileexamples/cmssigner/cmssigner.pro'
    patching file examples/cmssigner/keyselectdlg.cpp' patching fileexamples/cmssigner/main.cpp'
    patching file examples/cmssigner/pkcs11configdlg/pkcs11configdlg.cpp' patching fileexamples/cmssigner/prompter.cpp'
    patching file examples/hashtest/hashtest.cpp' patching fileexamples/randomtest/randomtest.cpp'
    can't find file to patch at input line 120
    Perhaps you used the wrong -p or --strip option?
    The text leading up to this was:

    |Index: plugins/qca-wingss/qca-wingss.cpp
    |===================================================================
    |--- plugins/qca-wingss/qca-wingss.cpp (revision 1336453)

    +++ plugins/qca-wingss/qca-wingss.cpp (working copy)

    File to patch:
    Skip this patch? [y]
    Skipping patch.
    8 out of 8 hunks ignored
    patching file src/qca_keystore.cpp' patching filesrc/support/console.cpp'
    patching file src/support/qpipe.cpp' patching filesrc/support/synchronizer.cpp'
    patching file src/support/syncthread.cpp' patching filetools/qcatool/main.cpp'
    patching file unittest/certunittest/certunittest.cpp' Hunk #1 succeeded at 128 (offset -1 lines). Hunk #3 succeeded at 229 (offset -1 lines). Hunk #5 succeeded at 469 (offset -1 lines). Hunk #7 succeeded at 635 (offset -1 lines). Hunk #8 succeeded at 734 (offset -39 lines). Hunk #9 succeeded at 875 (offset -1 lines). patching fileunittest/hashunittest/hashunittest.cpp'
    patching file unittest/keygenunittest/keygenunittest.cpp' patching filesrc/support/syncthread.cpp'
    patching file `unittest/metatype/metatype.cpp'@

    I then downloaded QConf and did a clean and build in QT Creator: https://github.com/psi-plus/qconf/

    I then copied configure.exe and QConf.exe to the QCA sources folder.

    In the QCA folder, I issued the following: qconf qca.qc
    However, I got an error:
    @C:\qca-2.0.3>qconf qca.qc
    qconf: ./conf does not exist.@

    Please help me to compile QCA on QT5.

    Even if I'm using Windows, please give me instructions that are "portable", I mean that I want to use QCA on Windows, Mac and Linux.

    Thank you







  • Use sources from KDE http://websvn.kde.org/trunk/kdesupport/qca/. Soon they will be ported to Qt5.



  • Do you know when it'll be done?



  • I finally used Cmake and this fixed my issue:

    1. Download Cmake nightly here: http://www.cmake.org/files/dev/?C=M;O=D
    2. Install it
    3. In QT Creator: Tools -> Options -> Build & Run -> Cmake -> Browse... and find you cmake executable (mine is C:\Program Files (x86)\CMake 2.8\bin\cmake.exe)
    4. Download svn://svn.kde.org/trunk/kdesupport/qca/
    5. Download git://anongit.kde.org/extra-cmake-modules
    6. In QT Creator, File -> Open File or project: select the CMakeLists.txt from the extra-cmake-module repository, compile it
    7. In QT Creator, File -> Open File or project: select the CMakeLists.txt from the qca repository, in the arguments, add -DECM_MODULE_PATH C:/extra-cmake-modules-build (replace it with the location of your built extra-cmake-modules)
    8. You have a working QCA, you only need to copy the lib and include folder in your GCC compiler directory (mine is C:\Qt\Qt5.0.1\5.0.1\mingw47_32)
    9. Follow the same steps to compile plugins, QT will tell you that some package can't be found (for example OpenSSL), then define the variable where cmake is supposed to find the package (-DMY_CMAKE_PACKAGE_LOCATION C:/it/is/here)

    Have fun!



  • Hey noname120, thanks for the tutorial. Unfortunately, I'm stuck at step 7. I added an argument -DECM_MODULE_PATH=D:/programowanie/_lib/extra-cmake-modules-build/ and I got an error:

    @Building with Qt5 support
    CMake Error at D:/programowanie/_lib/extra-cmake-modules-build/ECMConfig.cmake:42 (include):
    include could not find load file:

    D://share/ECM-0.0.8/modules//ECMUseFindModules.cmake
    

    Call Stack (most recent call first):
    CMakeLists.txt:12 (find_package)

    CMake Error at CMakeLists.txt:14 (find_package):
    By not providing "FindQt5Transitional.cmake" in CMAKE_MODULE_PATH this
    project has asked CMake to find a package configuration file provided by
    "Qt5Transitional", but CMake did not find one.

    Could not find a package configuration file provided by "Qt5Transitional"
    with any of the following names:

    Qt5TransitionalConfig.cmake
    qt5transitional-config.cmake
    

    Add the installation prefix of "Qt5Transitional" to CMAKE_PREFIX_PATH or
    set "Qt5Transitional_DIR" to a directory containing one of the above files.
    If "Qt5Transitional" provides a separate development package or SDK, be
    sure it has been installed.

    Configuring incomplete, errors occurred!@

    I can't see Qt5Transitional* files in extra-cmake-modules directories. Do you have any suggestions?



  • This is inconsistent because it checks in some location for the ECM_MODULE_PATH and in another for the share folder.

    I knew about this issue but one of the maintainers of the repository told me he would quickly fix it so I thought it was done.

    The workaround is to copy the compiled ECM files to the "D:/share/ECM-0.0.8/" directory. (in your case because your OS is installed on D:/, other users should copy it to the "C:/users/share/ECM-0.0.8/" directory)



  • Thanks a lot, it worked! :-)



  • My happiness was premature. Apps can't load QCA plugins, like QCA-OSSL. For instance running examples\rsatest.exe ends with an error "RSA not supported!".

    While compiling QCA, the plugins were built as well, so I didn't do the 9th step. I can see libqca-logger, libqca-ossl and libqca-softstore DLLs in D:\Qt\Qt5.0.2\5.0.2\mingw47_32\plugins\crypto.

    I tested it also on a virtual machine without Qt environment. Have the plugins been compiled incorrectly?



  • The library is a runtime library: it'll check for necessary DLLs and then tell "feature X is supported" and "feature Y is not supported".

    That's why you need to modify your makefile to copy the plugin DLLs in the right directory of the compiled program. (I think it should in your case be something like yourprog/crypto/qca-ossl2.dll)



  • I had myapp/crypto/qca-ossl.dll.

    I recompiled QCA and tested my app in debug build - it works partially. QCA::supporedFeatures displays:

    @random,md5,sha1,keystorelist,log,sha0,ripemd160,md4,sha224,sha256,sha384,sha512,
    hmac(md5),hmac(sha1),hmac(sha224),hmac(sha256),hmac(sha384),hmac(sha512),
    hmac(ripemd160),aes128-ecb,aes128-cfb,aes128-cbc,aes128-cbc-pkcs7,aes128-ofb,
    aes192-ecb,aes192-cfb,aes192-cbc,aes192-cbc-pkcs7,aes192-ofb,aes256-ecb,aes256-cbc,
    aes256-cbc-pkcs7,aes256-cfb,aes256-ofb,blowfish-ecb,blowfish-cbc-pkcs7,blowfish-cbc,
    blowfish-cfb,blowfish-ofb,tripledes-ecb,tripledes-cbc,des-ecb,des-ecb-pkcs7,des-cbc,
    des-cbc-pkcs7,des-cfb,des-ofb,cast5-ecb,cast5-cbc,cast5-cbc-pkcs7,cast5-cfb,cast5-ofb,
    pbkdf1(sha1),pbkdf2(sha1),pkey,dlgroup,rsa,dsa,dh,cert,csr,crl,certcollection,pkcs12,tls,
    cms,ca@

    While release mode displays this:

    @random,md5,sha1,keystorelist@

    Also, the debug build crashes on accessing Random context (for function nextByte()), the context is set to 0xbaadf00d ;-)



  • You should post the code you're using.



  • Update - the debug mode no longer crashes, it works perfectly. However, the release one still doesn't. The simplest code to test it is rsatest example in QCA.

    What I did so far is similar to steps in OP, but I'm using CMake-GUI for makefile generation and console for compiling instead of Qt Creator.

    General steps:
    For extra-cmake-modules:

    • get from svn://anonsvn.kde.org/home/kde/trunk/kdesupport/qca/ (address in OP is incorrect)
    • add Qt 5 bin and OpenSSL bin folders to PATH
    • open CMake-Gui
    • set source and build folders
    • set gcc and g++
    • set make
    • set CMAKE_INSTALL_PREFIX
    • configure and generate
    • open console, go to ECM build folder
    • make and make install

    For QCA:

    • copy ECM-build\share to root (i.e. C:) due to bug
    • set CMAKE_INSTALL_PREFIX
    • set ECM_DIR
    • (optionally) disable BUILD_TESTS
    • set CMAKE_BUILD_TYPE to debug or release
    • set OPENSSL_INCLUDE_DIR (assuming you have OpenSSL installed)
    • configure and generate
    • open console, go to QCA build folder
    • make and make install

    results

    • bin\libqcad.dll.a or bin\libqca.dll.a - wrong name, correct it to libqcad.a or libqca.a
    • plugins are in root\crypto (i.e. C:\crypto) instead of INSTALL_PREFIX\plugins\crypto
    • LIB path in crypto.prf is incorrect, fix it

    finish

    • move crypto.prf and crypto folder to proper Qt folders - mkspecs\features and plugins, respectively
    • add QCA bin to PATH (or move dlls to QCA lib?)

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.