Fix FreeBSD linking issues