After being utterly disgusted by it for awhile I tried converting all my c libraries into c++ ones. That did the trick it seems.

Very very weird...