Qt in Cygwin

Feb 19, 2009 at 7:12am
Has anyone installed and made a hello world program with Qt in Cygwin? I'm getting it to compile but no window is showing up when I run the program.

Could you list the steps that I need to follow (or links if possible) to get this to work?


Here's what I've done:

1. I installed "KDE on Cygwin" by extracting the tar file in the root directory (creating /usr/lib/qt3/*). Maybe I should just try a regular Linux/X11 Qt build?

2. Created a ~/.profile file containing:

QTDIR=/usr/lib/qt3
PATH=$QTDIR/bin:$PATH
MANPATH=$TQDIR/man:$MANPATH
LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH
export QTDIR PATH MANPATH LD_LIBRARY_PATH


3. Created a main.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <qapplication.h>
#include <qpushbutton.h>

using namespace std;

int main( int argc, char * args[] )
{
    // some extra code left out (making a Mandelbrot fractal)
    cout << "Here goes!" << endl;

    QApplication app( argc, args );
    QPushButton hello( "Hello World!", 0 );
    hello.resize( 100, 50 );
    app.setMainWidget( &hello );
    hello.show();
    return app.exec();
}


4. Compiled and ran it, as follows:

> qmake -project
> qmake
> make
g++ -c -pipe -Wall -W -O2 -DQT_NO_DEBUG -I/usr/lib/qt3/mkspecs/cygwin-g++ -I. -I. -I/usr/include/qt3 -o main.o main.cpp
g++ -Wl,--enable-runtime-pseudo-reloc -o fractal main.o -L/usr/lib/qt3/lib -L/usr/X11R6/lib -lqt -lXext -lX11
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: warning: auto-importing has been activated without --enable-auto-import specified on the command line.
This should work unless it involves constant data structures referencing symbols from auto-imported DLLs.Info: resolving QString::shared_null by linking to __imp___ZN7QString11shared_nullE (auto-import)
> ./main.exe
Here goes!
>
Last edited on Feb 20, 2009 at 5:34am
Feb 20, 2009 at 5:33am
It works; exactly as described above. I was running the wrong executable. If you notice in the make above, the output file was fractal.exe, not main.exe like it was before I added the Qt part and used qmake.

Here's an ASCII Mandelbrot, just for kicks:

KKKKKKKKKK$$8888888888888$.OOOO%HHHHHHH$%OOO.$888888888888$$$KKKKKKKKKKKKKKKKKKK
KKKKKKKKKKK%:$$88888888888$:OOOO%$$888.$OOO$$888888888$$$.%OKKKKKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKOO%:$888888888$$%OOOO:$$%: $$.888888$$:%OOOOKKKKKKKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKOOOO%:$8888888$$ %O$ .: .$.:$$.OOOOOOOHKKKKKKKKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKHHOOOOO%$$:%O$%$$:% $OOOOOOHHHHHKKKKKKKKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKHHH$:OOO%$$: $$$$8HHHHHHKKKKKKKKKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKHHHH8 %$O888HHHHHHKKKKKKKKKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKKHHH$:OOO%$$: $$$$8HHHHHHKKKKKKKKKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKHHOOOOO%$$:%O$%$$:% $OOOOOOHHHHHKKKKKKKKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKKOOOO%:$8888888$$ %O$ .: .$.:$$.OOOOOOOHKKKKKKKKKKKKKKKKKKKKKKK
KKKKKKKKKKKKKOO%:$888888888$$%OOOO:$$%: $$.888888$$:%OOOOKKKKKKKKKKKKKKKKKKKKKK
KKKKKKKKKKK%:$$88888888888$:OOOO%$$888.$OOO$$888888888$$$.%OKKKKKKKKKKKKKKKKKKKK
Last edited on Feb 20, 2009 at 5:35am
Feb 20, 2009 at 5:37am
Woot for the mandelbrot!
Feb 23, 2009 at 8:10pm
Bug fix! ;)


###########################$$$$$$$$$$$$$$$$$$$$$$$$$$$##########################
#########################$$$$$$%%%%%%%%%$$$$$$$$$$$$$$$$########################
#######################$$$%%%%%%%%:::+-. ::%%$$$$$$$$$$$$$######################
######################$%%%%%%%%:::+=-. -=+:%%%$$$$$$$$$$$#####################
#####################$%%%%%:++++=, -+%%%$$$$$$$$$$$####################
#####################%:::++- +:%%%$$$$$$$$$$####################
#################### -+:%%%$$$$$$$$$$####################
#####################%:::++- +:%%%$$$$$$$$$$####################
#####################$%%%%%:++++=, -+%%%$$$$$$$$$$$####################
######################$%%%%%%%%:::+=-. -=+:%%%$$$$$$$$$$$#####################
#######################$$$%%%%%%%%:::+-. ::%%$$$$$$$$$$$$$######################
#########################$$$$$$%%%%%%%%%$$$$$$$$$$$$$$$$########################
Topic archived. No new replies allowed.