2010年10月29日 星期五

wxWidgets in CodeBlocks

wxWidgets has upgraded to 2.9, and I'm migrated from Dev-Cpp to Code::Blocks

Following is the way to setup the wxWidgets project in Code::Blocks

You should build your library with MSYS

1. Open a project

2. Go through Project / Properties...

3. Go to Project's build options...

4. In Compiler settings / #defines tab, we will add some information here.

4.1 Open MSYS, type wx-config --cppflags, and the terminal will popup like:


-I/usr/local/lib/wx/include/msw-unicode-2.9 -I/usr/local/include/wx-2.9 -D_LARGEFILE_SOURCE=unknown -DWXUSINGDLL -D__WXMSW__


4.2 Copy the this part to #defines


5. Go through Linker settings


5.1 For the Link libraries part, you just copy the file's path that end with .dll.a to here by click Edit button.  After testing, without this step, it still works.


5.2 For the other linker options, type wx-config --libs in MSYS, and the terminal will popup like:



-L/usr/local/lib   -Wl,--subsystem,windows -mwindows -lwx_mswu_xrc-2.9 -lwx_mswu_html-2.9 -lwx_mswu_qa-2.9 -lwx_mswu_adv-2.9 -lwx_mswu_core-2.9 -lwx_baseu_xml-2.9 -lwx_baseu_net-2.9 -lwx_baseu-2.9

Copy the this part to Other linker options

6. Goto Search directories

6.1 In compiler tab, add the directory path

mines are:

C:\wx\wxWidgets-2.9.1\mswDebug\lib\wx\include\msw-unicode-2.9
C:\wx\wxWidgets-2.9.1\include


Note that there is always two paths there, former one for the library's setting (unicode? for example).  Later one is for other header files.


6.2 In Linker tab, add the directory path


mines is:


C:\wx\wxWidgets-2.9.1\mswDebug\lib


This is where the library place

2010年5月22日 星期六

如何在jade的環境下動態載入Agent並執行之

對於沒學過java,而直接寫jade的人,一定對這個標題有問題

有問題的原因就是:jade沒有提供function來做

可是在找過網路後,發現有 java.lang.ClassLoaderjava.net.URLClassLoader 可以用。

使用方式如下:

try{
            URL url[] = new URL[1];
            url[0] = new URL("file:///pathTojar.jar");
            ClassLoader m_loader = new ClassLoader(url, ClassLoader.getSystemClassLoader());
            getContainerController().acceptNewAgent("test", (Agent)m_loader.loadClass("examples.hello.HelloWorldAgent").newInstance());
            getContainerController().getAgent("test").start();
        } catch(Exception e) {
            e.printStackTrace();
}

如此一來,就可以將jar檔裡的class檔讀出來,並動態執行之

2010年5月11日 星期二

WallpaperTray is not working in Ubuntu 10.04 (Lucid)

WallpaperTray is a good Gnome applet that it altomatically search user defined directory and ramdomly change your Wallpaper.  But it seems that it do not have anyone to maintaince the project.  And in Ubuntu 10.04, it is not the default packet that you can select from the Synaptic.  But you can install by compiling the orginal code.  Here is how it works.

1), download the wallpaper-tray_0.5.5.orig.tar.gz from Here.

2), extract it to a folder.  For example, /home//wp_tray

3), open the command, change the folder to where it is extracted.
cd ~/wp_tray

4), type the following command
./configure  --prefix=/usr
Normally, it  will have some error.  That is because you have some packet that is not installed. (For example, the gnome-dev.)  The packet you lack of will show at the bottom of the console window, just scroll up a little, and you will see the list.  Open Synaptic and install all packet you need.  Until there is no error when you excute this command.

5), compile the source code by entering the following command
make
This will compile all the source code.  It may takes a while.

6), install WallpaperTray by the following command
sudo make install
This will copy all the binary file that just compiled to the proper location in your OS.

7), logout and login to refresh the gnome setting.  After that, you may select WallpaperTray as the old way.

Also note that there should have no error when excuting the commands upon.

You may also notice that there is the .deb file of WallpaperTray in here when you download the source code on step 1.  Why not just download the .deb file from one of the list?  The reason is simple.  Some of the packet it depands have updated, but the WallpaperTray project did not update.  When installing, it will say that you have no ... package installed, but the packet is the old packet.  And this is the reason that you can not install this applet directly from Synaptic.  However, we can't install from the .deb file, but we can re-compile the source code and link to the newer library, and the problem is solved.