2009-11-26

lparse 1.1.1 conflicts with GCC 4.3.3

by Forrest Sheng Bao http://fsbao.net

An updated version for Ubuntu 9.10 is here: lparse 1.1.1 compiling conflicts with GCC 4.4.1 on Ubuntu Linux 9.10

If you are having problem compiling lparse 1.1.1 using GCC 4.3.3, specifically on Ubuntu 9.04, and your error happens to be like this
g++ -g -O3 -c instance.cc
In file included from instance.cc:23:
extern.h:86: error: previous declaration of ‘long int strtol(const char*, char**, int)’ with ‘C++’ linkage
/usr/include/stdlib.h:186: error: conflicts with new declaration with ‘C’ linkage
/usr/include/stdlib.h:186: error: declaration of ‘long int strtol(const char*, char**, int) throw ()’ throws different exceptions
extern.h:86: error: from previous declaration ‘long int strtol(const char*, char**, int)’
just do a simple step:
Open src/extern.h and comment the line
long int strtol(const char *nptr, char **endptr, int base); 
which is around line 86. strtol is a C++ standard library function used to convert numbers of different radixes (or bases). So it doesn't need to be redefined here.
This is my GCC version info:
$ gcc -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.3.3-5ubuntu4' --with-bugurl=file:///usr/share/doc/gcc-4.3/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --enable-nls --with-gxx-include-dir=/usr/include/c++/4.3 --program-suffix=-4.3 --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --enable-mpfr --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) 

Solving Veena's adsolver conflicts with GCC 4.x

by Forrest Sheng Bao http://fsbao.net
There are many open source projects called adsolver. Here I mean this one http://www.cs.ttu.edu/~mellarko/adsolver.html , made by an alumni of my lab, combining Answer Set Programming and Constraint Logic Programming. If you download her solver, you will find many problems on compiling it on *modern* Linux and gcc. So, here is the solution.
Following procedures are tested on Ubuntu Linux 9.04 with gcc version 4.3.3 (Ubuntu 4.3.3-5ubuntu4) .
First batch of errors:
$ make
g++ -DHAVE_CONFIG_H -I. -I. -I..     -g -O2 -c array.cc
In file included from literal.h:33,
                 from predicate.h:30,
                 from array.cc:33:
instance.h:161: error: ‘RBTreeIterator’ does not name a type
instance.h:162: error: ‘HashSetIterator’ does not name a type
In file included from array.cc:33:
predicate.h:140: error: extra qualification ‘Predicate::’ on member ‘getMixedInstance’
predicate.h:187: error: ISO C++ forbids declaration of ‘InstanceIterator’ with no type
predicate.h:187: error: expected ‘;’ before ‘*’ token
For the 1st error at instance.h:161, add
class HashSetIterator;
class RBTreeIterator; 
at the end of the block of #include statements in instance.h.
For the 2nd error at predicate.h:140, change line 140 from
long Predicate::getMixedInstance(long i); 
to
long getMixedInstance(long i);
since you don't need namespace when declaring a function inside a class .
Second batch of errors:
Now run make again and *hopefully* you will see this error:
sm_smodels.cc:21:22: error: iostream.h: No such file or directory
sm_smodels.cc: In member function ‘void SM_Rule::print()’:
sm_smodels.cc:806: error: ‘cout’ was not declared in this scope
sm_smodels.cc:825: error: ‘endl’ was not declared in this scope
sm_smodels.cc: In member function ‘void SM_Rule::print_internal()’:
sm_smodels.cc:831: error: ‘cout’ was not declared in this scope
sm_smodels.cc:845: error: ‘endl’ was not declared in this scope
sm_smodels.cc: In member function ‘void Dcl::print()’:
sm_smodels.cc:1114: error: ‘cout’ was not declared in this scope
sm_smodels.cc:1114: error: ‘endl’ was not declared in this scope
sm_smodels.cc: In member function ‘void Program::print()’:
sm_smodels.cc:1419: error: ‘cout’ was not declared in this scope
sm_smodels.cc:1438: error: ‘endl’ was not declared in this scope
sm_smodels.cc: In member function ‘void Program::print_internal(long int)’:
sm_smodels.cc:1458: error: ‘cout’ was not declared in this scope
sm_smodels.cc:1458: error: ‘endl’ was not declared in this scope
sm_smodels.cc: In member function ‘void Smodels::print()’:
sm_smodels.cc:1671: error: ‘cout’ was not declared in this scope
sm_smodels.cc:1675: error: ‘endl’ was not declared in this scope
sm_smodels.cc: In member function ‘void Smodels::printAnswer()’:
sm_smodels.cc:1694: error: ‘cout’ was not declared in this scope
sm_smodels.cc:1698: error: ‘endl’ was not declared in this scope
sm_smodels.cc: In member function ‘void Tree::check_consistency(Tree::Node*)’:
sm_smodels.cc:1882: error: ‘cerr’ was not declared in this scope
sm_smodels.cc:1883: error: ‘endl’ was not declared in this scope
sm_smodels.cc:1888: error: ‘cerr’ was not declared in this scope
sm_smodels.cc:1889: error: ‘endl’ was not declared in this scope
make: *** [sm_smodels.o] Error 1
The reason is in C++, including library does not need .h suffix. So, open sm_smodels.cc and remove the .h suffix for iostream library. And do not forget to insert this line
using namespace std;
after #include blocks.
Now you are should have no problems to finish compiling adsolver.

2009-11-19

You have a parallel pin array on your *modern* motherboard

For anyone who works with MCU, DSP or in general embedded systems, you must know how important the parallel port on your PC is. But, it seems in lately few years, fewer and fewer motherboards have a pink parallel port.

Well, I just found the trick lately. There is a parallel pin array on your boardboard, like USB extension pins. On the PCB, around the parallel pin array, it prints something like "J_PRINTER"

So, what you need is a socket to parallel port, the IEEE 1284 D-sub connector. You just need to google something like "Motherboard Parallel Port Adapter," then you can get it within few dollars from places like eBay. Then you can have a regular parallel port on your computer.

In general, *modern* motherboard will say it has a "Printer port" at the "Internal I/O Connectors" section of its specification.

2009-11-12

How Republicans screwed up America from 1998 to 2008

I checked the currency rate between US dollar and Canadian dollar today. It shocked me that one USD is only 1.04 CAD now! So I used Google Finance to figure out how this change happened. (Full URL http://www.google.com/finance?chdnp=1&chdd=1&chds=1&chdv=1&chvs=Linear&chdeh=0&chdet=1258005666708&chddm=2144693&q=CURRENCY:USDCAD&ntsp=0)

I compared USD to Euro and Canadian dollars in past 5 years. You can see two greatest changes, late 2004 and late 2008, when Bush Jr. and Obama won the presidency respectively. It went down a lot when Bush Jr. won and came up a lot when Obama won.

So, can I infer that the whole world got disappointed when Bush Jr. won in 2004 and got pleased when Obama won in 2008?

Can we say most countries out there are American allies? Why did they dislik Bush and preferred Obama? Why did only a few countries join US  actions in Afhganistan and Iraq? Remember that, they joined America in World War II and the Cold War.

From the currency rate plot, I have to say that the whole world had seen that Republicans screwed up this country.

I am conservative and religious. But I dislike anyone taking advantage of religion or ethics to get their ballots. I really got confused on things as follows:
  • Abortion is wrong; so war is right? Even when war is not the last option?
  • Jesus healed people in the Bible; so we can refuse giving people medical service since they are illegal immigrants? Did Jesis ever ask them "Are you legal in Israel?" before taking care of them?
  • Not accepting the Gospel of God is wrong; so death penalty is right? Banning criminals to know the name of Jesus and be saved through His name? 
  • We are made from the image of God - I assume someone out there agrees this. Including terrorists, right? So can you torture them? Torture a being made from the image of God, thru the hand of God, with the spirit of God? 
I have no answers to above debates but I do struggle a lot on them. I really don't like anyone influencing others' choice and claiming it's based on the Bible. Repeating a lie a thousand times will make it a truth. That's the trick of Nazi and Communists. You should inspire people to think and refer the Bible by themselves. I don't believe torturing, death penalty, wars or banning illegal immigrants to get free medicare are consistent with the ideas of Bible.

I don't think American allies, Europeans and Canadians, are all wrong or they are all bad people. Just see the currency and stock market in past few years - the economy has been screwed up. Things are not good.

To the best of my understanding to my religion, if we insist to do something, and things are getting worse during a long time, probably we are not on the track that God want us to go.

It's hard to know the plan of God. So don't pretend you know and make claims. What I can do is to think rather than listen to your repeating. That's how Martin Luther noticed the problems of Catholic church, right?

2009-11-06

AVR32 development on Linux

by Forrest Sheng Bao http://forrest.bao.googlepages.com
I have to say that ATMEL is the most Linux-friendly company among all MCU/DSP makers in the world, followed by TI. Both TI and ATMEL use tons of open source toolchains so Linux zealots can build their apps on Linux.
I learned how to play with AVR 8-bit instruction set when I was an undergraduate. Now, I am gonna use AVR32, which is a 32-bit instruction set.
Here is some good information:
AVR32 32-bit MCU - Tools & Software: http://www.atmel.com/dyn/products/tools.asp?family_id=682#1443
ATEVK1100 development kit: http://www.atmel.com/dyn/products/tools_card.asp?tool_id=4114 only $129
AVR32 Studio: http://www.atmel.com/dyn/Products/tools_card.asp?tool_id=4116 IDE on Linux, better than TI's solution
And, ATMEL has a tool chain, buildroot, to build Linux OS targetting AVR32 MCU. It says a very funny sentence on their website: Buildroot will not run under Windows. Atmel recommends beginners to use Ubuntu Linux, available from www.ubuntu.com.