Grails, an In-Memory HSQL Database and Squirrel

Starting the HQSL Database

java -cp c:grails-1.2.0libhsqldb-1.8.0.10.jar org.hsqldb.Server -database.0 mem:devDB -dbname.0 devDB

Accessing the DB

java -cp c:grails-1.2.0libhsqldb-1.8.0.10.jar org.hsqldb.util.DatabaseManager

Grails database connection information, in DataSource.groovy

dbCreate = "create-drop"
url = "jdbc:hsqldb:hsql://localhost:9001/devDB"
username = "sa"
password = ""

Squirrel wouldn’t start until I correctly quote the CLASSPATH environment variable.

Testing with Google’s C++ Test Framework (gtest)

The other day I was playing around with Google’s C++ Testing Framework (a.k.a. gtest). I tried to build the Code with Visual Studio 2008 Express and got some strange linker errors. I was able to solve the errors thanks to this site. In essence, I had to change the “Runtime Library” Setting in the C/C++ Code Generation options to “Multi-Threaded” for a release build and to “Multi-Threaded Debug” for a debug build.

Linker Sets

Reminder: When placing something in a dedicated section using __attribute__((section("foobar"))), the GNU toolchain will automatically add a symbol __start_foobar at the beginning and a symbol __stop_foobar at the end of the section.

However, you will need a reference to that symbol in order to prevent the linker from optimizing the symbol away. In other words, you need to declare something like extern void *__start_foobar; and use it.

When using the Microsoft toolchain, the symbols need to be added explicitly. To do that, one can make use of the fact that when the Microsoft linker encounters several sections with a “$_” in their name, it will merge the contents into one final output section. The name of the output section will be the common prefix of the declared sections. The beauty is that the contents are in the order of the section names.

Here’s an example: Supposed you placed something into a section called “foobar$_something”. You can then add a variable __start_foobar into a section “foobar$_a” and a variable __stop_foobar into a section “foobar$_z”. The resulting binary will have one section “foobar” with the contents of variable __start_foobar placed at the beginning, followed the contents of everything in section “foobar$_something” and the contents of the variable __stop_foobar at the end.

Fix Windows Full Text search

I’ve recently noticed that using the Windows full text search may not always turn up the expected results. Apparently, Windows requires a program to install a search filter for a given file type. There is some plain text filter available by default, but it’s only registered for some endings. Source code files, e.g. Groovy files, will not be included, even though they contain nothing but plain ASCII text. Anyways, there’s a fix available, but it’s nowhere near intuitive…