Wednesday, May 27, 2009

Linux: Looking at files changed recently

This is really handy (on Linux and Cygwin) when you're working on a project that may not be in source control and you want to see what you changed recently.

I made this blog post, when it seems a trivial use of find, because I don't think the man page covers it well.

This command finds all files modified in the last 60 minutes:

find . -type f -cmin -60

Thursday, May 14, 2009

Linking MingW32 with psapi

Here's something I came across that didn't have a good answer when I googled. If you get link errors with MingW32 like:

undefined reference to `GetProcessMemoryInfo@12' or
c:/justinhj/mem.cpp:55: undefined reference to `EnumProcesses@12'

Then you are not linking with the library psapi, and you need it.

To do this just add -lpsapi to your command line. It needs to be last in the list of libraries too!

Writing quick C++ programs in emacs without a makefile

Cheetah by Storm Crypt

Often when programming in C++ (or many other languages) it's desirable to write a quick program, usually a console application, to test something quickly. Working in developer studio, it takes an amount of fiddling and clicking large enough that you may not want to bother.

Working in emacs and MingW32 (or Microsoft's CL.exe) I can quickly create a CPP file, and then compile it. To compile a program though you need to either write a makefile, or build up a complex g++ command line.

Rather than do either of those I make a helloworld.cpp file which can be built like this:

g++ helloworld.cpp -g -o helloworld.exe

So I hit

M-x compile

then type in the above to compile and link it.

However there's a better way. You can add the compile command as the first line of the file as a file local variable.

// -*- compile-command:"g++ helloworld.cpp -g -o helloworld.exe"; -*-

Now I can hit the compile and it works right away, between sessions. No makefile or project settings in sight, and now there are minimal barriers involved in creating a simple test program beyond copy and pasting the file.

Tuesday, May 12, 2009

Converting flac to mp3

This is just a link to a great description of converting flac to mp3 files. There's a tonne of commercial and useless sites that try to answer this question

So I thought I'd add another link to this one that actually works, and uses free software.