Posted on 01-04-2014
Filed Under (Technology) by bigbang

While I make my cpp source files linking ZeroMQ under Ubuntu, I got following error:

/usr/bin/ld: test_server.o: undefined reference to symbol 'zmq_strerror'
/usr/bin/ld: note: 'zmq_strerror' is defined in DSO /usr/local/lib/ so try adding it to the linker command line
/usr/local/lib/ could not read symbols: Invalid operation

The ZeroMQ library has already installed. By checking the man:

Libraries have been installed in:

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and manual pages.

I get rid of the error by following steps:

  1. install libtool;
  2. add the library path to LD_LIBRARY_PATH;
  3. use root to make.

I think the last one, using root to make, is the key point. Why?

Posted on 27-03-2014
Filed Under (Technology) by bigbang

While I am using ‘go get’ command to install the libraries of GoLang, I get this error:

# pkg-config --cflags libzmq libzmq libzmq libzmq
exec: "pkg-config": executable file not found in $PATH

We need to install pkg-config to fix this problem. On Ubuntu, just use command:

sudo apt-get install pkg-config

It’s because that package (sdl) uses pkg-config to get necessary cflags and ldfalgs for compiler and linker, respectively.

Posted on 23-02-2014
Filed Under (Technology) by bigbang

I am using Clojure & Compojure to write my webpages, and I am trying to use Selmer as template system for Clojure.

Here is my template file structure: there is a basic template file base.tpl which defines basic header, footer or something else. And some other files like index.tpl, search.tpl to do the real job by including base.tpl template. The base.tpl file defines the common part of my site and changes few times during my project lifetime.

In some suitations, we need to modify base.tpl. But after modification of base.tpl, Clojure & Selmer don’t re-render base.tpl when I visit and render index.tpl file. So I need to restart lein ring server every time after I modify base.tpl.

It is too troublesome and forgettable to restart lein ring server every time after modified base.tpl. Finally I find the reason on Selmer official doc site:

Note that changes in files referenced by the template will not trigger a recompile. This means that if your template extends or includes other templates you must touch the file that’s being rendered for changes to take effect.

Alternatively you can turn caching on and off using





(0) Comments    (933) Views   
Posted on 13-02-2014
Filed Under (Technology) by bigbang

While I am using Visual Studio 2008, there is an warning of this content:

warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.

There is also this kind of warnings when you are using sprintf etc.. We can use preprocessor _CRT_SECURE_NO_WARNINGS to shutdown this warning.

(0) Comments    (732) Views   
Posted on 22-01-2014
Filed Under (Technology) by bigbang

I am using Clojure & Compojure to write my webpages, and I am trying to use Selmer as template system for Clojure.

Today I find a strange thing in my template file. I used following code to take the position of real content:


Then I generate real html content in my clojure code like this:

(defn index-render [params]
    "render file content of index.html"
    (let [basecon "<B>to be done</B>"]
    (render-file "./myproject/templates/front.tpl" 
               {:content basecon})))

But after render the content, the page just shows following content:

<B>to be done</B>

and I printed the html result I found following content in html:

&lt;B&gt;to be done&lt;/B&gt;

which means the render has escaped < and > to &lt; and &gt; for me.

The solution is very easy. Just use filter in template files.

Selmer is basically the same as The Django template language, so the Automatic HTML escaping is also basically the same. According to Filters part in Selmer online doc, the problem can be done by specifying a filter ‘safe’ following the name of the variable. The filters are separated using the | character.

So I change my templete file into


and it works fine!

Posted on 16-01-2014
Filed Under (Technology) by bigbang

There are many basic startup code examples for Compojure on the web, but I don’t see any kind of deployment tutorial. Here are some basic collections if you want to use Clojure to start a web development.

  1. First, clone the code of compojure-example, and run it with the instructions on the page. If you can run it successfully by command
    lein ring server

    , then you can proceed to next step.

  2. Try to develop your web site with the lein ring server. This is the best way to develop Clojure web application for it can refresh your code automatically.
  3. Here comes the final step to deploy Clojure code to web server to provide official service for other people. First, package all resources such as code, css, html template files to war file:
    lein ring uberwar

    Then config your Tomcat according to manual and deploy the war file with http://localhost:8080/manager. There is a “WAR file to deploy” option on the manager page. It is the key point of deploying Clojure service to Tomcat. You can just think it is a Java application and use the normal way to deploy it.

BTW: the Tomcat root folder is something like D:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ROOT. If you web application can’t load some resource file, please check the relative path for it.

Posted on 07-12-2013
Filed Under (Technology) by bigbang

I am using C# HttpListener Class to produce a local web server. But by default, HttpListener Class will read the path which my code is defaulting to.

If I want to set a different path as server root path, just like Apache can choose a root path, how to do it with HttpListener?

I have read the HttpListener document, but there is no method for doing this. So I think here is the only answer, change the current directory:

Posted on 25-10-2013
Filed Under (Technology) by bigbang

QtService is a library not maintained by Qt right now, but a lot of engineers find that it is useful when you want to write a Windows application with Windows Service.

First, git clone the code from


After checkout, there is a folder qtservice which is the target in this post. Enter the folder and we will compile the library for later usage.

Second, compile the code into a library under Windows. Use Qt Command Prompt, jump to the source folder and use following commands to compile it:




The nmake.exe is the Visual Studio compiler, you can find it under Visual Studio installation path.

If the command prompt provides you with an error code:

NMAKE : fatal error U1077: 'cl' : return code '0x1'
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\bin
\nmake.exe"' : return code '0x2'
NMAKE : fatal error U1077: 'cd' : return code '0x2'

The reason is that you don’t use Qt Command Prompt.

After Compiled the code successfully, you can copy qtservice.h and generated library files such as QtSolutions_Service-head.dll, QtSolutions_Service-head.lib to your project folder. You link them in your pro file, then you can write QtService code. Just read examples under doc folder, and you will find the way.

If you use QtService in your application which name is example.exe for example, you can use following command to check the usage:

example.exe -help

and you can use following command to run the application as normal command line tool:

example.exe -exec
Posted on 02-10-2013
Filed Under (Technology) by bigbang

I tried to write a simple http server using Qt as a desktop tool. But when I tried to handle Chinese characters in UTF-8 encoding, my Firefox will always get mess characters.

The reason must be the difference between QString encoding and http encoding. I have encoded the http content using UTF-8, and I also should do something for QString.

Finally, I find the steps to let this simple http server handle Chinese characters.

First, in main function of your program, using following code to set global QString handler:

QTextCodec *codec = QTextCodec::codecForLocale();

Second, when you get http request, process the request and generate the feedback of the http request, you can send the content by following code using UTF-8:

//generate html content according to http request
//which is result
QString content = tr("HTTP/1.0 200 Ok\r\n"
                                "Content-Type: text/html; charset=\"utf-8\"\r\n"
content = content + result;

QTcpSocket* socket = (QTcpSocket*)sender();
QTextStream os(socket);
os << content;

Then you will get the right output in you web browser.

Scarpy recommands using Pillow instead of PIL to get image things done. But under Windows, if you install Pillow directly by

pip install pillow

, there will be an error while you download item images in Scrapy. The error is:

exceptions.IOError: decoder jpeg not available

If you are using Linux, the solution is very simple, just fix this by installing libjpeg and re-installing Pillow.

But under Windows, it is very exhausted to re-compile libjpeg with Pillow or PIL. In this suituation, I recommand to use pre-compiled PIL instead. Just install the pre-compiled PIL library, then you won’t get the above error.