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/libzmq.so.3 so try adding it to the linker command line
/usr/local/lib/libzmq.so.3: could not read symbols: Invalid operation

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

Libraries have been installed in:
   /usr/local/lib

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/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) 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?

(0) Comments    Read More   
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.

(0) Comments    Read More   
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:

Directory.SetCurrentDirectory(rootDirectory);
(0) Comments    Read More   
Posted on 14-11-2012
Filed Under (Technology) by bigbang

There are a lot of advantages to use FastCGI as web server solution, and there is also an easy way to construct such kind of server by using Apache and mod_fcgi module.

Let’s use Ubuntu 11.04 and Apache2.2 to develop a FastCGI Web Server.

1. Configure Apache and mod_fcgid module

First, install Apache from command line under Ubuntu:

$ sudo apt-get install apache2

Then we can also install mod_fcgid module in the same way:

$ sudo apt-get install libfcgi-dev

After the installation of Apache and mod_fcgid module, then we can edit configure file

/etc/apache2/sites-enabled/000-default

to modify options about mod_fcgid. BTW: according to Apache edition and installation path, the Apache configure file is under different path, so please check Apache manual for the details.

The example of configuration is:

<Directory /var/www/>
SetHandler fcgid-script
Options +ExecCGI

# Customize the next two directives for your requirements.
Order allow,deny
Allow from all
</Directory>

The above configuration is trying to put FastCGI binary code under path /var/www/ . Or you can choose another path in which Apache can execute the binary code.

2. Install fcig development package

Under Linux operating system, we need to install libfcgi library to use C, C++, Java, Perl to develop FastCGI program. The fcgi library encapsulate FastCGI protocol, so we don’t need to pay attentation to FastCGI protocol details. We can use following command to install it:

$ sudo apt-get install libfcgi-dev

Then create a .c source code file in your work folder, input following C code and compile it:

#include "fcgi_stdio.h"
#include <stdlib.h>

void main(void)
{
    int count = 0;
    while(FCGI_Accept() >= 0)
        printf("Content-type: text/html\r\n"
               "\r\n"
               "<title>FastCGI Hello!</title>"
               "<h1>FastCGI Hello!</h1>"
               "Request number %d running on host <i>%s</i>\n",
                ++count, getenv("SERVER_NAME"));
}

The command to compile the example code is:

$ gcc tiny-fcgi.c -o tiny-fcgi -lfcgi

The binary file of FastCGI program can execute directly (yes, trust me, it can run as normally program as well) and output related result.

Then copy the compiled binary file to Apache FastCGI path.

$ cp tiny-fcgi /var/www/

3. Ping your FastCGI services

Restart Apache service:

$ sudo /usr/sbin/apachectl restart

Then input following address in your favorite web browser, and you can reach your FastCGI service:

http://127.0.0.1/tiny-fcgi

4. Ending

The configuration of FastCGI is not complex and I will introduce some advanced techniques of FastCGI later. FastCGI is some kind of old things in IT world, and I think it is suitable for distributed computation using C as computing engine.

The separation of web server and computing engine is good for web developers and computing program developers to work seperatly and enjoy their work alone.

(0) Comments    Read More   
Posted on 15-10-2012
Filed Under (Technology) by bigbang

I have tried using MinGW, Qt, MSYS to write Windows Application,but I think most of us prefer to use Visual Studio to do coding job and using Qt under Windows is a trend.

1) build the environment

First we install Qt, Visual Studio and add Qt path to system PATH environment:

C:\Qt\4.7.1\bin

and we also add VC++ path into system PATH:

C:\Program Files\Microsoft Visual Studio 9.0\VC\bin

2) Create Qt project for Hellow World

Put Hello World into a cpp file:

#include <QApplication>
#include <QPushButton>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QPushButton hello("Hello world!");
    hello.resize(100, 30);

    hello.show();
    return app.exec();
}

Then open Qt Commandline Prompt , get into this folder and execute following commands:

qmake -project
qmake

According to the platform depended makefile file, we can use VC to compile the project:

nmake

3) using VC integrated development environment

If you want to use VC++ for code editing, then you just need to change the commands in point 2 to following:

qmake -project
qmake -tp vc

Then you will get a VC++ project and it will include all source files under current folder.

4) FAQ

For beginners, if you use Windows commanline to run above commands, then you will get an error when using nmake:

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

The solution is very simple, just use Qt Commandline Prompt for all commands.

(0) Comments    Read More   
Posted on 19-09-2010
Filed Under (Technology) by bigbang

A lot of companys are using Trac to track their daily work, and there are also a lot of small companys which are using Google Apps to build their Email systems and etc..

Here shows an example about how to set Trac for using Google Apps Gmail to send Email notifications. Modify trac.ini file with following part:

[notification]
admit_domains = 
always_notify_owner = false
always_notify_reporter = false
always_notify_updater = true
email_sender = SmtpEmailSender
ignore_domains = 
mime_encoding = none
sendmail_path = sendmail
smtp_always_bcc = 
smtp_always_cc = example@yourcompany.com
smtp_default_domain = 
smtp_enabled = true
smtp_from = trac@yourcompany.com
smtp_from_name = Trac
smtp_password = your_password
smtp_port = 587
smtp_replyto = trac@yourcompany.com
smtp_server = smtp.gmail.com
smtp_subject_prefix = __default__
smtp_user = trac@yourcompany.com
ticket_subject_template = $prefix #$ticket.id: $summary
use_public_cc = false
use_short_addr = false
use_tls = true

Just replace the trac@yourcompany.com with your own Email address. Please check The Trac Configuration File for the detail explanation of the settings.

Then enjoy the Email notifications.

(1) Comment    Read More