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

While I update my OpenCV to 2.4.2, it compiles fine but while executing it gives an error saying ‘tbb.dll’ not found.

After checking on internet, I get the answer. it’s part of Intel’s Threading Building Blocks library.

You can find a copy of it in your OpenCV installation in /build/common/tbb and under the platform and compiler your are using. For example, in c:\OpenCV-2.4.2\build\common\tbb\ia32\vc9.

The only thing I need to do is to add this path to my Windows System Path.

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

I am working on a special project with an unusual design.

In my application/process, I will create a sub process to do some work. In my process, I need to get the feedback from sub process. I want to pass the Window handle of my application/process to this sub process, so I can post message from this sub process.

How can I pass Window Handle to sub process? My sub process is a command line application without Windows UI and with the main function like this:

int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                       LPTSTR lpCmdLine, int nCmdShow)

I post this question in stackoverflow and get the answer:

Window handles (HWNDs) are global to the system so you can just print the handle as a decimal number into a string buffer, pass it as a string on the command line when you spawn your sub-process with CreateProcess, and call _wtoi() or similar to convert the string back to a handle again.

If you want to create the subprocess by CreateProcess API, then just pass the handle string to the sub process.

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

I want to add a tag like C++ in Emacs Org Mode file, but Org Mode doesn’t let me to do it. I find the explanation about tags in Org Mode:

Tags are normal words containing letters, numbers, '_', and '@'.

So, if you want to add tags with characters besides letters, numbers, ‘_’, and ‘@’, it seems that the only way is to change the tags into other words.

I use cpp or CPlusPlus to replace C++ in the tag position in my own Org Mode file.

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

While I am using Org Mode to write blog articles, I need to insert source code frequently. Emacs Org Mode provides an easy way to do this job, and I am using Org Mode to insert source code, publish to Html and upload it to WordPress.

While inserting source code in Org Mode, I use YASnippet mode. So, what’s the specific of the Identifiers of programming languages?

Working With Source Code: Languages has already described the abbreviation of the Identifiers, but I still try to make it clearly whether we can use uppercase or lowercase identifier, or both.

After my test, the Identifiers are case sensitive, so we should pay attention to it and input the identifiers according to Org Mode manual exactly.

For example, if we use Cpp to identify following code, the output HTML color theme is:

// assignment operator with lists
#include <iostream>
#include <list>
using namespace std;

int main ()
{
  list<int> first (3);      // list of 3 zero-initialized ints
  list<int> second (5);     // list of 5 zero-initialized ints

  second=first;
  first=list<int>();

  cout << "Size of first: " << int (first.size()) << endl;
  cout << "Size of second: " << int (second.size()) << endl;
  return 0;
}

If we use cpp which is lowercase, the output HTML color theme is:

// assignment operator with lists
#include <iostream>
#include <list>
using namespace std;

int main ()
{
  list<int> first (3);      // list of 3 zero-initialized ints
  list<int> second (5);     // list of 5 zero-initialized ints

  second=first;
  first=list<int>();

  cout << "Size of first: " << int (first.size()) << endl;
  cout << "Size of second: " << int (second.size()) << endl;
  return 0;
}

If we identify above code using C which is upppercase, the output HTML color theme is:

// assignment operator with lists
#include <iostream>
#include <list>
using namespace std;

int main ()
{
  list<int> first (3);      // list of 3 zero-initialized ints
  list<int> second (5);     // list of 5 zero-initialized ints

  second=first;
  first=list<int>();

  cout << "Size of first: " << int (first.size()) << endl;
  cout << "Size of second: " << int (second.size()) << endl;
  return 0;
}

If we use c which is lowercase, the output HTML color theme is:

// assignment operator with lists
#include <iostream>
#include <list>
using namespace std;

int main ()
{
  list<int> first (3);      // list of 3 zero-initialized ints
  list<int> second (5);     // list of 5 zero-initialized ints

  second=first;
  first=list<int>();

  cout << "Size of first: " << int (first.size()) << endl;
  cout << "Size of second: " << int (second.size()) << endl;
  return 0;
}

So, there is tiny difference! Let’s pay attention to programming language identifiers while you insert source code block in Org Mode.

BTW:

  1. please change the HTML CSS file to make the background of source code block to be black. By doing this, Reading code will be visual enjoyment.
  2. Htmlize is just used to output elisp file ( which is using el extention ) to HTML file and keep the color Highlighted. It doesn’t affect Org Mode to export source code as HTML.
(2) 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 10-10-2012
Filed Under (Technology) by bigbang

I can use my style file under 23.1, 23.4, but after I update Emacs to 24.1, I can’t use the old style files. For example, one of my style files is color-theme-arjen.el.

In my elisp file, I use following code to load the color theme:

(load-file "~/emacs/site-lisp/color-theme/master_color-theme-arjen.el")
(color-theme-arjen)

I don’t know why the color theme works under Emacs 23.1 & 23.4 but just doesn’t work under Emacs 24.1.

While Emacs is loading the file, Emacs gives following error:

Symbol's function definition is void: plist-to-alist

If I uncomment above code and don’t load the style file, the error is dismissed.

Why this happens? Here is the answer:

The color theme stuff was heavily revamped in 24, there is a color theme package included with emacs (see M-x customize-themes), and as far as I know breakage of older themes is expected.

The color theme package from marmalade reportedly works as well.

It seems that the only solution is to open a bug report for color-theme-arjen if I want to use the old theme. So I use M-x customize-themes to find my best theme right now.

(0) Comments    Read More