Sample Header Ad - 728x90

Autoconf - setting compiler flags for checks

2 votes
2 answers
3228 views
I am trying to use autoconf to create a configure script. However, some of the headers I want to check for require additional compiler flags (e.g. c++11). I can get partly there with the answer [here](https://unix.stackexchange.com/questions/241286/autoconf-ac-check-headers-for-c11) where the relevant lines look like this in the configure.ac file. AX_CXX_COMPILE_STDCXX_11(,[mandatory]) AC_CHECK_HEADER("CL/cl2.hpp") but the std=gnu++11 flag isn't passed to the preprocessing step of AC_CHECK_HEADERS where I end up with the strange result where it is usable but not present: checking CL/cl2.hpp usability... yes checking CL/cl2.hpp presence... no Looking in the config.log shows the following lines: configure:3423: checking CL/cl2.hpp presence configure:3423: g++ -E conftest.cpp In file included from conftest.cpp:19:0 /usr/include/CL/cl2.hpp:442:2: error #error Visual studio 2013 or another C++11-supported compiler required where I can clearly see that the C++ flag is not being used. How can I have compiler flags be used in these preprocessor steps? **EDIT** I can manually get around this by setting the CXXCPP manually when running configure but I'd like it to run without the end user needing to know this. ./configure CXXCPP="g++ -E -std=gnu++11"
Asked by cdeterman (121 rep)
Nov 6, 2015, 05:50 PM
Last activity: Aug 7, 2025, 09:07 PM