Tag Archives: Programming

Build Qt with OpenSSL, VC++ 2005 EE(SP1) on Windows XP

Build Qt with OpenSSL, VC++ 2005 EE(SP1) on Windows XP

1. OS, Compilers and SDK
OS: Windows XP(SP3)
Compiler: Microsoft Visual C++ 2005 Express Edition with Service Pack 1
SDK: Windows Software Development Kit (SDK) for Windows Server 2008 and .NET Framework 3.5

You need set SDK path in your compiler settings by yourself.

2. Build OpenSSL 0.9.8h
Download OpenSSL 0.9.8h Original Source Package, unpack it to C:openssl-0.9.8h.
Please read C:openssl-0.9.8hINSTALL.W32.

Open the Visual Studio 2005 Command Prompt, then


3. Build Qt with OpenSSL
Download qt-win-opensource-src-4.4.3.zip, unpack it to C:Qt4.4.3-oss.

Open the Visual Studio 2005 Command Prompt, then

Build Qt for Symbian

About Symbian development environment, please have a look at:
SYMBIAN Development Environment – 1
SYMBIAN Development Environment – 2

Build Qt for Symbian

Platform: Windows XP with SP3(now we only support Qt/S60 on it.)

0. Patches

Patches for S60 development environment

1. Build Qt for symbian

qt-embedded-s60-opensource-src-4.4.2-pyramid.zip

You need to make sure to use Symbian X86 compiler (version 3.2.5 build 473).

Follow this steps in C:Qt4.4.2-pyramiddocinstall-s60.html

Uncompress the package and put it in C:Qt4.4.2-pyramid.

Set your PATH including C:Qt4.4.2-pyramidbin.

Configure:

C:
cd Qt4.4.2-pyramid
configure -platform win32-mwc -xplatform symbian-abld -qconfig symbian

Build:

bldmake bldfiles
abld build winscw udeb

Notice: Please store the Qt/S60 repository and Symbian SDK in the same hard disk drive, maybe you can store them in different drives, and then use tools like WinMount to mount them to same drive.

Before configure and build, you need set EPOCROOT to your SDK, I use “/S60/devices/S60_3rd_FP2_SDK/”, just because my sdk is in C:S60devicesS60_3rd_FP2_SDK.

2. Build Examples

2-1. How to build Qt/S60 application

C:Qt4.4.2-pyramiddocs60-with-qt-introduction.html

Please make sure to use the qmake in your Qt/S60 build.

qmake
bldmake bldfiles
abld build winscw udeb

Run Carbide.c++ v1.3, In the tab of “Symbian Project Navigator”, right click mouse in white space, choose “Import”, in the “Import” dialog, choose “Symbian OS Bld.inf file” under “Symbian OS”, then “Next”, then “Browse…” to choose the bld.inf in above directory. Then you could build it, run it and debug it in Carbide.c++.

2-2. XML HTML info Example

C:Qt4.4.2-pyramiddocxml-htmlinfo.html

Note: Standard out is redirected on some platforms. On Symbian using Open C stdout is by default directed to the console window, but this window may not always be visible. To redirect to a file instead, locate the c:\system\data\config.ini file (on either the emulator or the device) and change STDOUT to point to MEDIA4. This will redirect the console to c:\system\data\out.txt.

For me, the config.ini is C:S60devicesS60_3rd_FP2_SDKepoc32winscwcsystemdataconfig.ini, the out.txt is C:S60devicesS60_3rd_FP2_SDKepoc32winscwcsystemdataout.txt.

Run the Emulator, Start->S60 Developer Tools->3rd Edition FP2 SDK->Emulator.

In the Emulator, go to Menu->Installations->eshell, and type htmlinfo in prompt mode.

2-3. analogclock Example

Now it works fine for me.

Qt/S60 team are still working on the project to make all things work.

3. Build Qt applications for your mobile phone

Please have a look at C:Qt4.4.2-pyramidREADME and C:Qt4.4.2-pyramidINSTALL.

Just go to your Qt application directory,

qmake
bldmake bldfiles
abld build gcce udeb

Create a package for your mobile phone:

createpackage yourqtapplication_gcce_udeb.pkg

Note: Now the package will include Qt library in the .pkg file, if you already have a Qt application package installed, maybe you can’t install the next one. Then please remove these lines from the .pkg file of your second application.

“epoc32releasegcceudebQtGui.dll” – “c:sysbinQtGui.dll”
“epoc32releasegcceudebQtNetwork.dll” – “c:sysbinQtNetwork.dll”
“epoc32releasegcceudebQtCore.dll” – “c:sysbinQtCore.dll”

SYMBIAN Development Environment – 1

SYMBIAN Development Environment (1)

Platform: Windows XP Pro(SP3)

1. Software Packages

For downloading the packages, you need to register an account in the forum of Nokia,
http://www.forum.nokia.com/main/registration/registration.html

1-1. Carbide.C++
http://www.forum.nokia.com/main/resources/tools_and_sdks/carbide/
http://www.forum.nokia.com/info/sw.nokia.com/id/dbb8841d-832c-43a6-be13-f78119a2b4cb.html

Carbide.C++ 1.3
Carbide.c++_v1.3.exe 185MB

1-2. S60 Platform SDKs for Symbian OS, for C++
http://www.forum.nokia.com/info/sw.nokia.com/id/4a7149a5-95a5-4726-913a-3c6f21eb65a5/S60-SDK-0616-3.0-mr.html

S60 Platform SDKs for Symbian OS, for C++, 3rd Edition, Feature Package 2(FP2)
S60-3.2-SDK-f.inc3.2130.zip 438MB

1-3. Open C/C++ Plug-ins for S60 3rd Edition
http://www.forum.nokia.com/info/sw.nokia.com/id/91d89929-fb8c-4d66-bea0-227e42df9053/Open_C_SDK_Plug-In.html

Plugin_For_S60_3rd_Ed.zip 41.3MB

2. Installation

Please install above 3 packages as default path.

Installation order: Carbide.C++, S60 SDK, Plugin.

After Carbide.C++, you may need to install ActivePerl-5.6.1.635-MSWin32-x86.msi:

http://downloads.activestate.com/ActivePerl/Windows/5.6/ActivePerl-5.6.1.635-MSWin32-x86.msi

3. Emulator
Start->S60 Developer Tools->Emulator

4. Try first example application for S60

Run Carbide.C++ 1.3
Start->Carbide.c++ v1.3->Carbide.c++ v1.3

In the welcome page, you could click “Tutorials”->”Create an application emulator debug example”, and follow this tutorial to build your first example application for S60.

(Info: If the welcome page takes all space of the workspace in Carbide.c++, it makes you can’t find the project tree and other things, PLEASE CLICK “Restore” OPTION IN THE TOP-RIGHT CORNER OF THE WELCOME PAGE!)

Follow above steps to create your project, but if you can’t see any template in “New Symbian OS C++ Project” dialog when you enable “Filter templates based on enabled SDKs”, it means Carbide.c++ doesn’t find the SDK which you had installed. Then please cancel the dialog.

In the main menu of Carbide.c++, Window->Preferences->Carbide.c++->SDK Preferences, you will find out there is nothing in the “Available Symbian OS SDKs”. Please click “Add New SDK”, in the “Add New SDK” dialog, SDK ID: should be “S60_3rd_FP2_SDK”, EPOCROOT: should be “C:S60devicesS60_3rd_FP2_SDK”, Vendor: should be “com.nokia.s60”, Is Default: should be “yes”. Then click “OK” on it. Click “Rescan All SDKs” and “OK”.

Now you can return to your project.

Follow the tutorial, you could run the application in the emulator, in my case the emulator path should be: C:S60devicesS60_3rd_FP2_SDKepoc32releasewinscwudebepoc.exe

Why not try it on your phone?

Copy C:SymbianCarbideworkspaceOroboroussisOroborous_S60_3_X_v_1_0_0.sisx to your phone via usd disk mode. Install it and run it.

If you got some errors like that “Certificate error. Contact the application supplier.”, you need to set your phone like this:
Installations->App. mgr.->Options->Settings, choose “All” for “Software installation”.

Then all should be ok.

Qt and omniORB

PREFACE

About CORBA, please have a look at http://en.wikipedia.org/wiki/Corba.

omniORB is one of the CORBA implementations, please have a look at http://omniorb.sourceforge.net/.

About Qt, please have a look at http://en.wikipedia.org/wiki/Qt_%28toolkit%29.

And there is one add-on, QtCorba, http://trolltech.com/products/qt/addon/solutions/catalog/4/Utilities/qtcorba/, which is for the integration Qt 4.x with ACE/TAO or MICO(another two CORBA implementations). Then main concept in QtCorba is to convert ACE/TAO or MICO events into Qt event, just because they need the main thread to run their own event loop. QtCorba is not open source(it’s commercial product).

I had inquried the omniORB mailing list how to integrate omniORB with Qt 4.x. The core developer of omniORB, Duncan Grisby, gave me a reply on it.

http://www.omniorb-support.com/pipermail/omniorb-list/2008-February/029227.html
omniORB doesn’t have an application-hookable event loop like Mico. it
always uses its own threads to dispatch CORBA calls. You can just use
the main thread to service Qt’s event loop and it will work fine.

Then I tried some code, it works fine.

1. Install omniORB 4.1.1 and run the examples

I am using openSUSE 10.3, gcc 4.2.1 on 32bit PC.

Download: omniORB-4.1.1.tar.gz
http://sourceforge.net/project/showfiles.php?group_id=51138

There are four parts, BUILD omniORB, RUN omniORB EXAMPLES, BUILD Qt, RUN Qt&omniORB EXAMPLES in this article.

BUILD omniORB

cd ~/tmp
mkdir build
tar zxvf omniORB-4.1.1.tar.gz
cd omniORB-4.1.1
./configure -prefix /user
make
sudo make install

Build examples:
cd ~/tmp/omniORB-4.1.1
cd src/examples/echo
make

Please read Chapter 2 in doc/omniORB.pdf at first.

RUN omniORB EXAMPLES

(1) eg1 is an example which creates a corba object and invokes the method of it in same code.

cd ~/tmp/omniORB-4.1.1
cd src/examples/echo
./eg1

The result should be:
I said, “Hello!”.
The Echo object replied, “Hello!”.

(2) eg2_impl is the server, eg2_clt is the client, they are based on IOR, not need to run omniNames.

In terminal 1, run the server:
cd ~/tmp/omniORB-4.1.1
cd src/examples/echo
./eg2_impl
IOR:010000000d00000049444c3a4563686f3a312e3000000000010000000000000068000000010102000f0000003133342e33322e3138352e3232300000f96600000e000000fe23aab24700000562000000000000000200000000000000080000000100000000545441010000001c00000001000000010001000100000001000105090101000100000009010100

In terminal 2, run the client:
cd ~/tmp/omniORB-4.1.1
cd src/examples/echo
./eg2_clt IOR:010000000d00000049444c3a4563686f3a312e3000000000010000000000000068000000010102000f0000003133342e33322e3138352e3232300000f96600000e000000fe23aab24700000562000000000000000200000000000000080000000100000000545441010000001c00000001000000010001000100000001000105090101000100000009010100

Yeap, you should use the IOR:01000…. string as the parameter of client side.

The output of server side:
Upcall Hello!
Upcall Hello!
Upcall Hello!
Upcall Hello!
Upcall Hello!
Upcall Hello!
Upcall Hello!
Upcall Hello!
Upcall Hello!
Upcall Hello!

The output of client side:
I said, “Hello!”.
The Echo object replied, “Hello!”.
I said, “Hello!”.
The Echo object replied, “Hello!”.
I said, “Hello!”.
The Echo object replied, “Hello!”.
I said, “Hello!”.
The Echo object replied, “Hello!”.
I said, “Hello!”.
The Echo object replied, “Hello!”.
I said, “Hello!”.
The Echo object replied, “Hello!”.
I said, “Hello!”.
The Echo object replied, “Hello!”.
I said, “Hello!”.
The Echo object replied, “Hello!”.
I said, “Hello!”.
The Echo object replied, “Hello!”.
I said, “Hello!”.
The Echo object replied, “Hello!”.

And you also can separately run server and client on different machines.

(3) eg3_impl is the server, eg3_clt is the client, they are based on omniNames(the nameing service).

Now we need do something about config file. There is a sample.cfg in ~/tmp/omniORB-4.1.1.

We create a server3.cfg and a client3.cfg in ~/tmp/cfg/.

diff -c sample.cfg server3.cfg
*** sample.cfg 2008-02-13 09:34:57.000000000 +0100
— server3.cfg 2008-02-13 09:54:42.000000000 +0100
***************
*** 329,334 ****
— 329,335 —-
# corbaname URI:
#
# InitRef = NameService=corbaname::my.host.name
+ InitRef = NameService=corbaname::localhost
#
#
# Specify the Trading service and the interface repository using corbaloc:

diff -c sample.cfg client3.cfg
*** sample.cfg 2008-02-13 09:34:57.000000000 +0100
— client3.cfg 2008-02-12 14:27:59.000000000 +0100
***************
*** 329,334 ****
— 329,335 —-
# corbaname URI:
#
# InitRef = NameService=corbaname::my.host.name
+ InitRef = NameService=corbaname::localhost
#
#
# Specify the Trading service and the interface repository using corbaloc:

We create a log directory for omniNames.
cd ~/tmp
mkdir log

In terminal 1, run the omniNames:
export OMNIORB_CONFIG=~/tmp/cfg/server3.cfg
omniNames -start -log ~/tmp/log
(This is for first time to run.)
omniName -log ~/tmp/log
(This is for not first time to run.)

In terminal 2, run the server:
cd ~/tmp/omniORB-4.1.1
cd src/examples/echo
unset OMNIORB_CONFIG
./eg3_impl

In terminal 3, run the client:
cd ~/tmp/omniORB-4.1.1
cd src/examples/echo
export OMNIORB_CONFIG=~/tmp/cfg/client3.cfg
./eg3_clt

The output of client side is same as previous case.

If the Nameing Service(omniNames) is not running, then you will get:
./eg3_clt
Caught system exception TRANSIENT — unable to contact the server.

And you also can separately run server and client on different machines.
Please make sure to edit the config file correctly, for example:
You can replace “localhost” with your server’s ip or domain name in server3.cfg and client3.cfg.

(4) The applications are same with previous, but the config file are different, follow an old way.

diff -c sample.cfg server4.cfg
*** sample.cfg 2008-02-13 10:07:09.000000000 +0100
— server4.cfg 2008-02-13 10:23:49.000000000 +0100
***************
*** 329,334 ****
— 329,335 —-
# corbaname URI:
#
# InitRef = NameService=corbaname::my.host.name
+ InitRef = NameService=corbaname::192.168.249.130
#
#
# Specify the Trading service and the interface repository using corbaloc:
***************
*** 1041,1044 ****
# bootstrap agent protocol. This enables interoperability between omniORB
# servers and Sun’s javaIDL clients. When this option is enabled, an
# omniORB server will respond to a bootstrap agent request.
! supportBootstrapAgent = 0
— 1042,1045 —-
# bootstrap agent protocol. This enables interoperability between omniORB
# servers and Sun’s javaIDL clients. When this option is enabled, an
# omniORB server will respond to a bootstrap agent request.
! supportBootstrapAgent = 1

diff -c sample.cfg client4.cfg
*** sample.cfg 2008-02-13 09:34:57.000000000 +0100
— client4.cfg 2008-02-13 10:24:48.000000000 +0100
***************
*** 1042,1044 ****
— 1042,1046 —-
# servers and Sun’s javaIDL clients. When this option is enabled, an
# omniORB server will respond to a bootstrap agent request.
supportBootstrapAgent = 0
+ bootstrapAgentHostname = 192.168.249.130
+ bootstrapAgentPort = 2809

In terminal 1, run the omniNames:
export OMNIORB_CONFIG=~/tmp/cfg/server4.cfg
omniNames -start -log ~/tmp/log
(This is for first time to run.)
omniName -log ~/tmp/log
(This is for not first time to run.)

In terminal 2, run the server:
cd ~/tmp/omniORB-4.1.1
cd src/examples/echo
unset OMNIORB_CONFIG
./eg3_impl

In terminal 3, run the client:
cd ~/tmp/omniORB-4.1.1
cd src/examples/echo
export OMNIORB_CONFIG=~/tmp/cfg/client4.cfg
./eg3_clt

The output of client side is same as previous case.

BUILD Qt

4.3.3 X11(Open Source or Commercial)

Ignore.

RUN Qt&omniORB EXAMPLES

Based on Duncan Grisby’s reply, first I tried to run the omniORB code in a QThread, it works fine. Then I just run the omniORB code in my GUI code, it also works fine.

(1) eg1.tar.gz, just like the first example in echo.

cd ~/tmp
tar zxvf eg1.tar.gz
cd eg1
ls
echo.cpp echo.h echo.idl eg1.pro main.cpp omniorbthread.cpp omniorbthread.h

echo.h and echo.cpp are generated from echo.idl with omniidl.

omniidl -bcxx echo.idl

It will generate echo.hh and echoSK.cc.

mv echo.hh echo.h
mv echoSK.cc echo.cpp

Then you need to modify the echo.cpp to include “echo.h”, not “echo.hh”.

qmake
make

unset OMNIORB_CONFIG
./eg1

I said, “Hello!”.
The Echo object replied, “Hello!”.
OmniORBThread is over!

(2) eg3.tar.gz, just like the third example in echo.

cd ~/tmp
tar zxvf eg3.tar.gz
cd eg3
qmake
make

ls
client echo.cpp echo.h echo.idl eg3.pro guiclient guiclient2 server

server is a console server application which runs the omniORB code in a thread.
client is a console client application which runs the omniORB code in a thread.
guiclient is a gui client application which runs the omniORB code in a thread.
guiclient2 is a gui client application which runs the omniORB code in main thread.

You can use server3.cfg/client3.cfg or server4.cfg/client4.cfg to run these examples application.

Files
README
cfg
eg1
eg3

KDE 4中农历系统代码讨论

代码主页:
http://code.google.com/p/kcalendar/

KDE 4.0已经非常临近了,但非常遗憾的是KDE系统中一直没有面向中国以及东亚用户使用的农历。

最近基于ccal的代码,做了一些封装,目前基本可用,但是效率还有待提高。

欢迎大家测试并且提出修改意见。

代码使用方法:
有关如何构建KDE 4开发环境和KDE 4应用开发,请参考:
http://techbase.kde.org/Getting_Started/Build/KDE4
http://techbase.kde.org/Development/Tutorials#Introduction_To_KDE_4_Programming

只需要kdelibs以及之前的步骤,完成后。
将kde4/kcalendarsystemchinese.h, kde4/kcalendarsystemchinese.cpp,
kde4/kcalendarsystem.cpp复制到kde/src/KDE/kdelibs/kdecore/date下。

将kde4/CMakeList.txt复制到kde/src/KDE/kdelibs/kdecore下。

切换到kde/src/KDE/kdelibs下,cmakekde即可编译新的库。

有关测试用例:
example/test用来测试各API接口。
example/guitest使用KDatePicker测试,比较慢的说,请大家稍等待一下。

编译方法:
cd example/test
cmake .
make

cd example/guitest
cmake .
make

主要问题,addMonths还需要改进,目前的算法太耗时间了,加1000个月时,基本无法忍受(test中)。

讨论方法:
kde-china邮件列表
http://mail.kde.org/mailman/listinfo/kde-china

kde-cn irc
irc://irc.freenode.net/#kde-cn

我参考的相关文档

http://thunder.cwru.edu/ccal/index.html
http://thunder.cwru.edu/ccal/rule.htm
http://www.math.nus.edu.sg/aslaksen/calendar/chinese.html

有关农历年份,我参考了这篇文档
http://en.wikipedia.org/wiki/Chinese_calendar