g++ -I. -L. -lfoo main.cpp -o main. is the problem. Recent versions of GCC reuqire that you put the object files ...
stackoverflow.com