The error you're getting indicates that the wrong SWI-Prolog.h is getting found. Not sure how that would be happening ... but I can't see that there's any other explanation. If the SWI-Prolog.h that ships with 5.6.1 gets found, then you simply won't get those errors when opaque.c is compiled.