On Sat, 11 Feb 2006 18:06:15 -0800, Stephen Harris wrote: > Hello Enrico, > > I am interested in your Cygwin Howto. Someone just asked > about this on the User list, and might appreciate a copy. > "Shenghua Fan" [EMAIL PROTECTED]
Hi Stephen, here it is. I also take this opportunity for sending it to the developers list for their scrutiny (sorry for breaking the thread). The file qtfix.diff contains a patch to the Qt sources. It is not mentioned in the howto, because I still have to update it. The file lyxconfig-cygwin is a bourne shell script for configuring LyX. I adapted it from a similar script by Angus. -- Enrico
In this howto all examples are shown for tcsh, but it is trivial to change them for bash. Mainly, it is simply a matter of substituting "export XXX=YYY" in place of "setenv XXX YYY" (or simply use tcsh instead of bash). QT3/Windows Free Edition ------------------------ In the following, it is assumed that the Qt sources are in /usr/local/src/qt3. If you have them in another place, simply replace the above path with what is appropriate. The Qt sources can be obtained though CVS. In /usr/local/src enter $ setenv CVSROOT ":pserver:[EMAIL PROTECTED]:/cvsroot/qtwin" $ cvs login <return> (no password) $ cvs -z9 -r QT_WIN32_3_3_BRANCH qt-3 1) Add the following line export QTDIR=/usr/local/src/qt3 at the very start of the following sh scripts: config.tests/unix/endian.test config.tests/unix/ipv6.test config.tests/unix/largefile.test config.tests/unix/ptrsize.test config.tests/unix/stl.test 2) Add the following line to mkspecs/cygwin-g++-win32/qmake.conf (immediately after the line "CONFIG +=") DEFINES += UNICODE 3) Add the following lines at the very start of mkspecs/cygwin-g++-win32/qplatformdefs.h #ifdef UNICODE #ifndef _UNICODE #define _UNICODE #endif #endif 4) Add the "-f" flag to ln in qmake/Makefile.unix (in the qmake: target) as follows: ln -s -f ../qmake/$@ @BUILD_PATH@/bin/$@ 5) Add the following code to src/tools/qlocale.cpp (after the inclusion of float.h) #ifdef __CYGWIN__ #define _CRTIMP #endif extern "C" { _CRTIMP unsigned int __cdecl _control87 (unsigned int unNew, unsigned int unMask); _CRTIMP unsigned int __cdecl _clearfp (void); #define _clear87 _clearfp } 6) For the CVS version that I checked out, I also had to add some #include's to src/kernel/qapplication_win.cpp and src/kernel/qfont_win.cpp: $ diff qapplication_win.cpp.orig qapplication_win.cpp 47a48,49 > #include <locale.h> > #include <ctype.h> $ diff qfont_win.cpp.orig qfont_win.cpp 64a65 > #include <locale.h> 7) In src/kernel/qapplication_win.cpp substitute _flushall() with the following code: #if defined (Q_OS_CYGWIN) fflush(NULL); #else _flushall(); #endif 8) Protect the inclusion of winsock.h in src/kernel/qeventloop_win.cpp: #if !defined (Q_OS_CYGWIN) #include <winsock.h> #endif 9) Protect the definition of QT_WA in src/network/qdns.cpp: #if !defined (QT_WA) #define QT_WA( uni, ansi ) ansi #endif 10) In tools/designer/app/app.pro change the occurrence of "designercore.lib" into "libdesignercore.a" 11) Configure and compile Qt $ setenv QTDIR /usr/local/src/qt3 $ setenv PATH "$QTDIR/bin:$PATH" $ ./configure -platform cygwin-g++-win32 -v -release -static -qt-imgfmt-png -qt-imgfmt-jpeg -qt-imgfmt-mng -no-exceptions -disable-opengl -disable-sql -disable-network -no-style-compact -no-style-cde -no-style-motif -no-style-motifplus -no-style-platinum -no-style-sgi -no-sm -no-xft -no-xkb -no-xrender --enable-accessibility (Please, note the double '-' in --enable-accessibility above) Now edit Makefile and comment out sub-tutorial and sub-examples (in the all: target) placing '#' in front of sub-tutorial as follows: all: symlinks src-qmake src-moc sub-src sub-tools #sub-tutorial sub-examples $ make 12) Install a minimal Qt (such that the source tree could even be deleted) $ mkdir -p /usr/local/qt-cygwin/bin $ mkdir /usr/local/qt-cygwin/include /usr/local/qt-cygwin/lib $ cp -p /usr/local/src/qt3/bin/{moc.exe,uic.exe} /usr/local/qt-cygwin/bin/ $ strip /usr/local/qt-cygwin/bin/{moc.exe,uic.exe} $ cp -p /usr/local/src/qt3/lib/libqt.{a,la,prl} /usr/local/qt-cygwin/lib/ $ cd /usr/local/src/qt3/include $ tar cf - . | (cd /usr/local/qt-cygwin/include; tar xvBpf -) $ rm -rf /usr/local/qt-cygwin/include/CVS Now edit /usr/local/qt-cygwin/lib/libqt.la and change a) "library_names='libqt.dll.a'" to "library_names='libqt.a'" b) "libdir='/usr/local/qt3/src/lib'" to "libdir='/usr/local/qt-cygwin/lib'" LyX --- 1) Unpack lyx-1.4.0pre4.tar.bz2 in /usr/local/src 2) Apply the following patch: --- src/frontends/qt2/FileDialog.C.orig 2005-01-19 16:03:30.000000000 +0100 +++ src/frontends/qt2/FileDialog.C 2006-02-12 19:50:24.000000000 +0100 @@ -30,7 +30,7 @@ * * Therefore there is a tradeoff in enabling or disabling this (JMarc) */ -#ifdef Q_WS_MACX +#if defined(Q_WS_MACX) || defined(Q_CYGWIN_WIN) #define USE_NATIVE_FILEDIALOG 1 #endif 3) Configure LyX $ cd /usr/local/src $ ./lyxconfig-cygwin lyx-1.4.0pre4 static 4) Add the following lines to src/config.h (at the bottom) #if defined(X_DISPLAY_MISSING) && defined(__CYGWIN__) #define Q_CYGWIN_WIN 1 #endif 5) Compile and install LyX $ cd lyx-1.4.0pre4/build $ make $ make install ***** The End *****
--- src/dialogs/qfiledialog_win.cpp.orig 2006-02-11 21:30:04.000000000 +0100 +++ src/dialogs/qfiledialog_win.cpp 2006-02-12 06:57:04.000000000 +0100 @@ -44,6 +44,10 @@ #include <commdlg.h> #endif +#ifdef Q_OS_CYGWIN +#include <sys/cygwin.h> +#endif + // Don't remove the lines below! // // resolving the W methods manually is needed, because Windows 95 doesn't include @@ -93,6 +97,27 @@ const unsigned int maxNameLen = 1023; const unsigned int maxMultiLen = 65535; +#ifdef Q_OS_CYGWIN +static QString posixPath(const QString &path) +{ + char posix_path[maxNameLen+1]; + posix_path[0] = '\0'; + cygwin_conv_to_posix_path(path.ascii() ? path.ascii() : "", posix_path); + return QString::fromLocal8Bit(posix_path); +} + +static QString winPath(const QString &path) +{ + char win32_path[PATH_MAX]; + win32_path[0] = '\0'; + cygwin_conv_to_win32_path(path.ascii() ? path.ascii() : "", win32_path); + return QString::fromLocal8Bit(win32_path); +} +#else +#define posixPath(a) a +#define winPath(a) a +#endif + // Returns the wildcard part of a filter. static QString extractFilter(const QString& rawFilter) { @@ -333,7 +358,7 @@ QT_WA({ // Use Unicode strings and API OPENFILENAME* ofn = makeOFN(parent, isel, - *initialDirectory, title, + winPath(*initialDirectory), title, winFilter(filter), ExistingFile); if (idx) ofn->nFilterIndex = idx + 1; @@ -345,7 +370,7 @@ } , { // Use ANSI strings and API OPENFILENAMEA* ofn = makeOFNA(parent, isel, - *initialDirectory, title, + winPath(*initialDirectory), title, winFilter(filter), ExistingFile); if (idx) ofn->nFilterIndex = idx + 1; @@ -365,7 +390,7 @@ return result; } else { - QFileInfo fi(result); + QFileInfo fi(posixPath(result)); *initialDirectory = fi.dirPath(); if (selectedFilter) *selectedFilter = selFilter(filter, selFilIdx); @@ -417,7 +442,7 @@ QT_WA({ // Use Unicode strings and API OPENFILENAME* ofn = makeOFN(parent, isel, - *initialDirectory, title, + winPath(*initialDirectory), title, winFilter(filter), AnyFile); if (idx) ofn->nFilterIndex = idx + 1; @@ -429,7 +454,7 @@ } , { // Use ANSI strings and API OPENFILENAMEA* ofn = makeOFNA(parent, isel, - *initialDirectory, title, + winPath(*initialDirectory), title, winFilter(filter), AnyFile); if (idx) ofn->nFilterIndex = idx + 1; @@ -449,7 +474,7 @@ return result; } else { - QFileInfo fi(result); + QFileInfo fi(posixPath(result)); *initialDirectory = fi.dirPath(); if (selectedFilter) *selectedFilter = selFilter(filter, selFilIdx); @@ -502,7 +527,7 @@ } QT_WA({ OPENFILENAME* ofn = makeOFN(parent, isel, - *initialDirectory, title, + winPath(*initialDirectory), title, winFilter(filter), ExistingFiles); if (idx) ofn->nFilterIndex = idx + 1; @@ -512,14 +537,14 @@ int offset = fileOrDir.length() + 1; if (ofn->lpstrFile[offset] == 0) { // Only one file selected; has full path - fi.setFile(fileOrDir); + fi.setFile(posixPath(fileOrDir)); QString res = fi.absFilePath(); if (!res.isEmpty()) result.append(res); } else { // Several files selected; first string is path - dir.setPath(fileOrDir); + dir.setPath(posixPath(fileOrDir)); QString f; while(!(f = QString::fromUcs2((ushort*)ofn->lpstrFile+offset)).isEmpty()) { fi.setFile(dir, f); @@ -533,7 +558,7 @@ cleanUpOFN(&ofn); } , { OPENFILENAMEA* ofn = makeOFNA(parent, isel, - *initialDirectory, title, + winPath(*initialDirectory), title, winFilter(filter), ExistingFiles); if (idx) ofn->nFilterIndex = idx + 1; @@ -543,14 +568,14 @@ int offset = fileOrDir.length() + 1; if (ofn->lpstrFile[offset] == '\0') { // Only one file selected; has full path - fi.setFile(QString::fromLocal8Bit(fileOrDir)); + fi.setFile(posixPath(QString::fromLocal8Bit(fileOrDir))); QString res = fi.absFilePath(); if (!res.isEmpty()) result.append(res); } else { // Several files selected; first string is path - dir.setPath(QString::fromLocal8Bit(fileOrDir)); + dir.setPath(posixPath(QString::fromLocal8Bit(fileOrDir))); QCString f; while(!(f = QCString(ofn->lpstrFile + offset)).isEmpty()) { fi.setFile(dir, QString::fromLocal8Bit(f)); @@ -649,7 +674,7 @@ } QT_WA({ resolveLibs(); - QString initDir = QDir::convertSeparators(initialDirectory); + QString initDir = QDir::convertSeparators(winPath(initialDirectory)); TCHAR path[MAX_PATH]; TCHAR initPath[MAX_PATH]; initPath[0] = 0; @@ -672,13 +697,13 @@ else { pMalloc->Free(pItemIDList); pMalloc->Release(); - result = QString::fromUcs2((ushort*)path); + result = posixPath(QString::fromUcs2((ushort*)path)); } } else result = QString(""); tTitle = QString(""); } , { - QString initDir = QDir::convertSeparators(initialDirectory); + QString initDir = QDir::convertSeparators(winPath(initialDirectory)); char path[MAX_PATH]; char initPath[MAX_PATH]; QByteArray ctitle = title.local8Bit(); @@ -701,7 +726,7 @@ else { pMalloc->Free(pItemIDList); pMalloc->Release(); - result = QString::fromLocal8Bit(path); + result = posixPath(QString::fromLocal8Bit(path)); } } else result = QString("");
lyxconfig-cygwin
Description: File attachment