I found the solution to my problem. I post it in case someone else have this problem.
Mariocup's solution was good in general, but for mingw32 it needs a little tunning, since I need to add mingw32 as the first library.
Here is my solution:
local libs_bk = base.GetLinkLibs();
base.SetLinkLibs(_T("mingw32"));
base.AddLinkLib(&libs_bk);
First, we get the current list of libraries (specified on the linker settings page). We replace the list of libraries with mingw32, than we append the original list of the libraries to the list.