add linker flags and resolve cast errors