The error you are getting is because the file twi.h can't be found. However, the file twi.h is a library based on the AVR architecture. This means that it won’t work on Galileo because its architecture is different. That's the reason why the file can't be found. If you compile the same sketch for the Arduino UNO board, it shouldn't have errors because the twi.h file is available for the AVR architecture (Arduino boards).
Therefore, the library NXShield.h is not compatible with Galileo because of the architecture dependencies. My suggestion would be to re-write the library. Check what the library NXShield.h does, and try to write a new one based on it.
Another alternative would be to check for what purpose the library twi.h is used in the NXShield.h library. If it doesn’t have critical uses in the functionality of the NXShield.h library, you could comment the line where it is called to avoid getting the error message.