fix #1291

I also tried on Linux. This patch is likely to break build on other platforms, or with different configure parameters.
Please verify.