You are not logged in.

#1 2013-09-25 14:05:28

keineeile
Member
Registered: 2012-03-03
Posts: 41

[SOLVED] Mingw32 cross compiler -> QCA

Hi guys,

On my system (Arch 64 Bit) I installed the mingw32 compiler (from AUR). With some tweaks I also managed to get a (static) qt4 installation. Compiling qt4 apps for Windows on my Linux system works perfectly.
However, for a new project, I now need to add QCA to it. It isn't in the AUR, so I downloaded the code from its website.
That'w what I undertake to compile it, followed by the error(s) I get:

First, I apply this patch (otherwise g++ throws an error).

Since the configure script for some reason always falls back to the system g++ instead of the i486-mingw32-g++ (even though I specify all the --*dir that are possible) I chose to try to compile it using i486-mingw32-qmake-qt4 and make.

That seems to work quite well at first. But then the first error:

../../../tools/mozcerts/main.cpp:22:29: fatal error: QtCrypto: No such file or directory

Since the include headers are shipped with the packaged file, I change the include line to:

#include "../../include/QtCrypto/QtCrypto"

However, that leads to the next errors, and that's where I'm stuck:

i486-mingw32-g++ -c -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 --param=ssp-buffer-size=4 -mms-bitfields -O2 -frtti -fexceptions -mthreads -Wall -DUNICODE -DQT_LARGEFILE_SUPPORT -DQT_NO_DEBUG -DQT_CORE_LIB -DQT_THREAD_SUPPORT -I'/usr/i486-mingw32/include/qt4/QtCore' -I'/usr/i486-mingw32/include' -I'/usr/i486-mingw32/include/qt4/ActiveQt' -I'release' -I'../../../tools/mozcerts' -I'.' -I'/usr/i486-mingw32/share/qt4/mkspecs/win32-g++-cross' -o release/main.o ../../../tools/mozcerts/main.cpp
i486-mingw32-g++ -Wl,-s -Wl,-subsystem,console -mthreads -o release/mozcerts.exe release/main.o  -L'/usr/i486-mingw32/lib' -lQtCore -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32 
release/main.o: In function `ZN3QCA10TextFilterD1Ev':
/home/***/qca-2.0.3/build/tools/mozcerts/../../../tools/mozcerts/../../include/QtCrypto/qca_textfilter.h:51: undefined reference to `_imp___ZTVN3QCA10TextFilterE'
/home/***/qca-2.0.3/build/tools/mozcerts/../../../tools/mozcerts/../../include/QtCrypto/qca_textfilter.h:51: undefined reference to `_imp___ZN3QCA6FilterD2Ev'
release/main.o: In function `~TextFilter':
/home/***/qca-2.0.3/build/tools/mozcerts/../../../tools/mozcerts/../../include/QtCrypto/qca_textfilter.h:51: undefined reference to `_imp___ZTVN3QCA10TextFilterE'
/home/***/qca-2.0.3/build/tools/mozcerts/../../../tools/mozcerts/../../include/QtCrypto/qca_textfilter.h:51: undefined reference to `_imp___ZN3QCA6FilterD2Ev'
release/main.o: In function `ZN3QCA6Base64D1Ev':
/home/***/qca-2.0.3/build/tools/mozcerts/../../../tools/mozcerts/../../include/QtCrypto/qca_textfilter.h:232: undefined reference to `_imp___ZTVN3QCA6Base64E'
release/main.o: In function `~TextFilter':
/home/***/qca-2.0.3/build/tools/mozcerts/../../../tools/mozcerts/../../include/QtCrypto/qca_textfilter.h:51: undefined reference to `_imp___ZTVN3QCA10TextFilterE'
/home/***/qca-2.0.3/build/tools/mozcerts/../../../tools/mozcerts/../../include/QtCrypto/qca_textfilter.h:51: undefined reference to `_imp___ZN3QCA6FilterD2Ev'
/home/***/qca-2.0.3/build/tools/mozcerts/../../../tools/mozcerts/../../include/QtCrypto/qca_textfilter.h:51: undefined reference to `_imp___ZTVN3QCA10TextFilterE'
/home/***/qca-2.0.3/build/tools/mozcerts/../../../tools/mozcerts/../../include/QtCrypto/qca_textfilter.h:51: undefined reference to `_imp___ZN3QCA6FilterD2Ev'
release/main.o: In function `main':
/home/***/qca-2.0.3/build/tools/mozcerts/../../../tools/mozcerts/main.cpp:32: undefined reference to `_imp___ZN3QCA11InitializerC1ENS_10MemoryModeEi'
/home/***/qca-2.0.3/build/tools/mozcerts/../../../tools/mozcerts/main.cpp:116: undefined reference to `_imp___ZN3QCA11InitializerD1Ev'
/home/***/qca-2.0.3/build/tools/mozcerts/../../../tools/mozcerts/main.cpp:105: undefined reference to `_imp___ZN3QCA6Base64C1ENS_9DirectionE'
/home/***/qca-2.0.3/build/tools/mozcerts/../../../tools/mozcerts/main.cpp:106: undefined reference to `_imp___ZN3QCA6Base6420setLineBreaksEnabledEb'
/home/***/qca-2.0.3/build/tools/mozcerts/../../../tools/mozcerts/main.cpp:107: undefined reference to `_imp___ZN3QCA6Base6419setLineBreaksColumnEi'
/home/***/qca-2.0.3/build/tools/mozcerts/../../../tools/mozcerts/main.cpp:108: undefined reference to `_imp___ZN3QCA12MemoryRegionC1ERK10QByteArray'
/home/***/qca-2.0.3/build/tools/mozcerts/../../../tools/mozcerts/main.cpp:108: undefined reference to `_imp___ZN3QCA10TextFilter13arrayToStringERKNS_12MemoryRegionE'
/home/***/qca-2.0.3/build/tools/mozcerts/../../../tools/mozcerts/main.cpp:108: undefined reference to `_imp___ZN3QCA12MemoryRegionD1Ev'
/home/***/qca-2.0.3/build/tools/mozcerts/../../../tools/mozcerts/main.cpp:116: undefined reference to `_imp___ZN3QCA11InitializerD1Ev'
/home/***/qca-2.0.3/build/tools/mozcerts/../../../tools/mozcerts/main.cpp:108: undefined reference to `_imp___ZN3QCA12MemoryRegionD1Ev'
collect2: error: ld returned 1 exit status
make[3]: *** [release/mozcerts.exe] Error 1
make[3]: Leaving directory `/home/***/qca-2.0.3/build/tools/mozcerts'
make[2]: *** [release] Error 2
make[2]: Leaving directory `/home/***/qca-2.0.3/build/tools/mozcerts'
make[1]: *** [sub-mozcerts-make_default] Error 2
make[1]: Leaving directory `/home/***/qca-2.0.3/build/tools'
make: *** [sub-tools-make_default] Error 2


It seems obvious to me, that the problem lies within the mozcerts/main.cpp file. I guess, that my adjustment to the include wasn't right? Or what else could be the problem? I tried adding all different kind of stuff to the mozcerts.pro file, "CONFIG += crypto", "LIBS += {-lqca, -lqca2, -lcrypt32, [anything I could think of]}, but nothing solved it. I don't know what else to try...

I'd really appreciate any hint/comment!!

Regards
keineeile


Edit
Just found that somebody else has the exact same problem (lol!): http://www.qtcentre.org/threads/56322-I … ompiler%29
However, there's no solution in that forum either...

Last edited by keineeile (2013-09-28 14:07:48)

Offline

#2 2013-09-27 11:15:09

keineeile
Member
Registered: 2012-03-03
Posts: 41

Re: [SOLVED] Mingw32 cross compiler -> QCA

Nobody any idea?

Compilation does finish if I exclude mozcerts and qcatools from being build. I'm not sure though how important they are for using qca as part of a C++/Qt4 app (the only encryption I need is AES)??

Lets assume for now it is not that important in this case. After it is compiled I need to install it manually, since qca does that with a .bat file on windows:

So I move the ./include/QtCrypto/ directory to /usr/i486-mingw32/include/ and the files in ./build/lib/ to /usr/i486-mingw32/lib

Then I create a file called crypto.prf with the following two lines:

QCA_INCDIR = "/usr/i486-mingw32/include/QCrypto/"
QCA_LIBDIR = "/usr/i486-mingw32/lib"

and move the file to /usr/i486-mingw32/share/qt4/mkspecs/features/

Is there anything else I need to do? Because when I try then to install qca-ossl it fails with error message:

qca-ossl.cpp:6944: Error: Undefined interface

The responsible code for this error is is the following:

class opensslPlugin : public QObject, public QCAPlugin
{
	Q_OBJECT
	Q_INTERFACES(QCAPlugin)
public:
	virtual Provider *createProvider() { return new opensslProvider; }
};

If I go even a step further and remove the Q_INTERFACES(QCAPlugin) line (I'm more than certain that this is not a good idea, but I don't know what else to try), compilation soon after fails because "'EVP_md2' was not declared in this scope".
Searching the web I read something about md2 not being supported anymore in openssl? Anyway, since I wont need this type of encryption, I simply removed the few lines where this function is called and compilation finishes without errors.
To install it, all I need to do (according to the README) is copying the files in ./lib/ to /usr/i486-mingw32/lib/qt4/plugins/crypto/


Now, when I try to compile my application that uses QtCrypto for encryption, it at first compiles fine - until the linking part. Here's the start of the error message compiling my actualy app:

i486-mingw32-g++ -Wl,-s -mthreads -Wl,-subsystem,windows -o release/aes.exe release/main.o release/mainwindow.o release/moc_mainwindow.o  -L'/usr/i486-mingw32/lib/' -L'/usr/i486-mingw32/lib/qt4/' -lmingw32 -lqtmain -L/usr/i486-mingw32/lib -lcrypto -lwsock32 -lQtGui -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lmsimg32 -lQtCore -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32 
release/main.o: In function `main':
/home/***/main.cpp:7: undefined reference to `_imp___ZN3QCA11InitializerC1ENS_10MemoryModeEi'
/home/***/main.cpp:12: undefined reference to `_imp___ZN3QCA11InitializerD1Ev'
[... and many more like the two above ...]



I'd really appreciate any hint or idea as to what to try!

Offline

#3 2013-09-28 14:07:26

keineeile
Member
Registered: 2012-03-03
Posts: 41

Re: [SOLVED] Mingw32 cross compiler -> QCA

Woohoo, finally got it working!!

Here's what I did:


First I removes my static qt4 installation and replaces it with a shared one (I'm actually not sure if that was even necessary, but doesn't matter now).

Then I adjusted the qca.pro file, removed a few lines and added a few, so that it eventually looks like this:

TEMPLATE = subdirs
SUBDIRS = sub_src sub_tools

sub_src.subdir = src
sub_tools.subdir = tools
sub_tools.depends = sub_src

INCLUDEPATH += /usr/i486-mingw32/include/QtCrypto
INCLUDEPATH += /usr/i486-mingw32/include/openssl
LIBS += -L/usr/i486-mingw32/bin/
LIBS += -L/home/***/qca-2.0.3/lib/
LIBS += -L/usr/i486-mingw32/lib/qt4/plugins/crypto/
LIBS += -lqca2 -llibeay32 -lssleay32 -lgdi32 -lwsock32

The last few lines (the two INCLUDEPATH and four LIBS) I also copied to ./tools/mozcerts/mozcerts.pro and to ./tools/qcatool/qcatool.pro

I adjusted the two main.cpp,changing #include <QtCrypto> to #include <QtCrypto/QtCrypto> in both of them - and compilation finished smoothly without problems.

Edit: Forgot to add that also copied the ./include/QtCrypto/ folder to /usr/i486-mingw32/include

After copying ./build/bin/qca2.dll to /usr/i486-mingw32/bin/ and to /usr/i486-mingw32/lib/qt4/plugins/crypto
and after copying the files in ./build/lib/ to /usr/i486-mingw32/lib/  I was ready to tackle the qca-ossl plugin:


I changed the qca-ossl.pro file to the following:

TEMPLATE = lib
CONFIG += plugin
QT -= gui
DESTDIR = lib

VERSION = 2.0.0
CONFIG += crypto
CONFIG += create_prl

SOURCES = qca-ossl.cpp
DEFINES += OSSL_097

INCLUDEPATH += /usr/i486-mingw32/include/QtCrypto
INCLUDEPATH += /usr/i486-mingw32/include/openssl
LIBS += -L/usr/i486-mingw32/bin/
LIBS += -L/usr/i486-mingw32/lib/qt4/plugins/crypto/
LIBS += -lqca2 -llibeay32 -lssleay32 -lgdi32 -lwsock32

After running i486-mingw32-qmake-qt4, the following make finished without errors (Edit: After of course removing the calls of EVP_md2() as mentioned in previous post).
Finally I copied the two files in ./lib/ to /usr/i486-mingw32/lib/ and the ./lib/qca-ossl2.dll also to /usr/i486-mingw32/lib/qt4/plugins/crypto/ everything was ready to roll.

For my program testing the AES encryption I added the following three lines into the win32 {} section of the .pro file:

LIBS += -L/usr/i486-mingw32/bin/
LIBS += -L/usr/i486-mingw32/lib/
LIBS += -lqca2 -llibeay32 -lssleay32 -lgdi32 -lwsock32

and compilation finishes without errors. I had to copy a good few dll-files into the ./release folder where the executeable was sitting (don't forget to copy libeay32.dll and ssleay32.dll, it runs without them, but the encryption fails if they're missing), and then it worked!! It actually worked!! Man, did that feel good smile

Last edited by keineeile (2013-09-28 15:33:53)

Offline

Board footer

Powered by FluxBB