2009-05-20

No .h fot C++ Standard Library head file and g++ doesn't import the std namespace by default

by Forrest Sheng Bao http://fsbao.net

I want to talk about two common errors people encounter when they compile old programs, especially when they are using recent version of g++. They may wonder why this code can be compiled in g++3.4 but not g++4.3.

A lot people get shock when they see this:

error: fstream.h: No such file or directory

The answer to solve this problem is that "Header files in the C++ Standard Library do not use the .h extension; have have no extension," -Kyle Loudon, C++ Pocket Reference, p.5, O'Reilly, 2003. So instead of saying

#include 

, you should say

#include 

The second common error is that you have included the library which defines a function, but you still got this:

error: ‘ifstream’ was not declared in this scope

Well, recent versions of g++ does not import std namespace by default. So, you have to add this line

using namespace std;

Above two issues had been address in textbooks a long time ago, at least when I was a college freshman. But I really do not understand why people are still thinking in the old way after so many years.

2009-05-14

Loving a university by seeing it?

by Forrest Sheng Bao http://fsbao.net

"They date. They talk, their likes and their dislikes." - Movie "Enchanted", 2007

“I would trade all of my technology for an afternoon with Socrates.” - Steve Jobs

My sister is going to visit McGill U. tomorrow. She wants to see whether she can "like it."

Maybe I am too old to understand how the next generation thinks - I'm 6 years older than her. But I just wonder. How can someone love a university by seeing it? Can you love a girl after seeing her? You may want to have sex with her but not sufficiently love her.

If I am gonna choose, I only care whether I can meet more "smart" people who can inspire me wonderful ideas. Just as Steve Jobs said “I would trade all of my technology for an afternoon with Socrates.”

I think it's pretty much the same as falling in love with a girl. Few months ago, I told a friend of mine, a boy, that I loved a girl. He said, "do not tell me you love her. You even don't KNOW her." Exactly! You need to know her heart.

A university is not like a park or a hotel. What make a bunch of buildings be called a university are people and their mental behaviors. So loving the buildings, the landscape, etc., does not mean you love this university. We are not coming to a university for a 4-year vacation. Whether you can enjoy exploring the unknown world is more important.

And thus, rationally, you cannot love a university by seeing it.

EDFbrowser working with discontinuous EDF+ file

by Forrest Sheng Bao http://fsbao.net

EDFbrowser is an open source EDF Browser. EDF/EDF+ is an open file format for biomedical time series, especially EEG and ECG/EKG signal.

But, the pain is, new (version 1.08 or later) EDFbrowswer "disabled the possibility to open discontinuous files."

I consulted the author, Teunis van Beelen, and got a solution from him.
  1. Open the file mainwindow.cpp in a texteditor.
  2. Comment the lines 1293 to 1310. Put /* and */ at the beginning and end of following code
    if(edfhdr->discontinuous)
    {
    if(edfhdr->edf)
    {
    UI_Messagewindow popuperror("Error", "EDFbrowser can not show EDF+D (discontinuous) files.\n"
    "Convert this file to EDF+C first. You can find this converter\n"
    "in the Tools menu (EDF+D to EDF+C converter).");
    }

    if(edfhdr->bdf)
    {
    UI_Messagewindow popuperror("Error", "EDFbrowser can not show BDF+D (discontinuous) files.\n"
    "Convert this file to BDF+C first. You can find this converter\n"
    "in the Tools menu (EDF+D to EDF+C converter).");
    }

    free(edfhdr->edfparam);
    free(edfhdr);
    fclose(newfile);

    return;
    }
    Now compile the source code by executing qmake && make and you are done.
Modifying this source code and recompiling it is legal since this software is distributed under GNU GPL v 2.

Installing QTGTKstyle on Ubuntu 9.04

by Forrest Sheng Bao http://fsbao.net

  1. sudo apt-get install libcairo2-dev libatk1.0-dev libgtk2.0-dev
  2. Follow instructions here: http://labs.trolltech.com/page/Projects/Styles/GtkStyle

    Note, the last command should be sudo make install. There is no rule "checkinstall."
I wonder why there is no for QTGTKStyle Ubuntu deb package in which I can use apt-get to install in one line of command. Coz QTGTKStyle is too new?

2009-05-13

Displaying compiling process in MAKE

by Forrest Sheng Bao http://fsbao.net

I need to play around with couple of logic stuffs this summer, SAT solvers, ASP solvers, ASP grounders, etc. So, I need to compile lotta codes this summer. Today, I found a cool stuff.

There is an ASP grounder called Gringo, a Spanish word used by Latin Americans to call {Crazy} Yankees (not Asian/African/Hispanic/Native Americans or Martian(from the Mars) Americans but Caucasian Americans) as we call Canadians "Canuck." - How do Canadians call Russians on the North side? Well, over the pole.

Their source code is packed with cmake scripts. So, when I compile it, it looks like this:
forrest@dophin:~/gringo-2.0.3-source/build/gringo/release$ make
Scanning dependencies of target gringo-lib_pch_dephelp
[ 1%] Building CXX object lib/gringo/CMakeFiles/gringo-lib_pch_dephelp.dir/gringo-lib_pch_dephelp.o
Linking CXX static library ../libgringo-lib_pch_dephelp.a
[ 1%] Built target gringo-lib_pch_dephelp
Scanning dependencies of target pch_Generate_gringo-lib
[ 1%] Generating gringo.h
[ 1%] Generating gringo.h.gch/gringo-lib_Release.h++
[ 4%] Built target pch_Generate_gringo-lib
Scanning dependencies of target gringo-lib
[ 6%] Building CXX object lib/gringo/CMakeFiles/gringo-lib.dir/src/avgaggregate.o
[ 7%] Building CXX object lib/gringo/CMakeFiles/gringo-lib.dir/src/statementchecker.o
[ 9%] Building CXX object lib/gringo/CMakeFiles/gringo-lib.dir/src/smodelsconverter.o
[ 10%] Building CXX object lib/gringo/CMakeFiles/gringo-lib.dir/src/output.o
and this at the end:
[ 90%] Building CXX object lib/gringo/CMakeFiles/gringo-lib.dir/generated/plainlparselexer.o
[ 92%] Building CXX object lib/gringo/CMakeFiles/gringo-lib.dir/generated/lparseconverter_impl.o
Linking CXX static library ../libgringo.a
[ 92%] Built target gringo-lib
Scanning dependencies of target gringo-app
[ 93%] Building CXX object app/CMakeFiles/gringo-app.dir/main.o
[ 95%] Building CXX object app/CMakeFiles/gringo-app.dir/options.o
/home/forrest/gringo-2.0.3-source/app/options.cpp: In function ‘bool::parseInt(const std::string&)’:
/home/forrest/gringo-2.0.3-source/app/options.cpp:172: warning: ignoring return value of ‘long int strtol(const char*, char**, int)’, declared with attribute warn_unused_result
[ 96%] Building CXX object app/CMakeFiles/gringo-app.dir/timer.o
[ 98%] Building CXX object app/CMakeFiles/gringo-app.dir/program_opts/program_options.o
[100%] Building CXX object app/CMakeFiles/gringo-app.dir/program_opts/value.o
Linking CXX executable ../bin/gringo
[100%] Built target gringo-app
I do not know how the process is shown. But it looks pretty cool. If you know how, please let me know.

2009-05-01

An article about my work on MIT Technology Review Blog

by Forrest Sheng Bao http://fsbao.net

There was an article related to my work on an MIT Technology Review Blog Wednesday. http://www.technologyreview.com/blog/arxiv/23465/

I didn't know this until someone else in my university told me. I guess the author saw a paper I pre-printed at arXiv and felt it was interesting. I appreciate the author to report my work, but I have some words to say regarding the report.

Maybe because I didn't express my ideas very clearly in my paper, some words in the report are not accurate, such as "dramatic impact" or "Nobody." Firstly, there are many similar or close research done by other groups. Secondly, our work is just a very primitive trial, using limited testing methods on very small amount of patient data, only 6 patients.

So above are things I want to make clear. I only did a small trial and the contribution is not very big as some reader may feel.