Hi,
Currently, it is not possible to use C++11 mode on Solaris with SolarisStudio
12.4 (test done on Solaris 11.2 sparc).
If I try a simple executable (see attached file), compilation is OK (option
–std=c++11 is correctly passed to compiler) but link failed because, with
SolarisStudio compiler, option –std=c++11 is also required at link time and is
currently missed.
And unfortunately, it seems there is no equivalent to compile configuration
variable CMAKE_CXX11_STANDARD_COMPILE_OPTION for the linker so no so easy to
fix this problem…
Here is the log (see red lines):
/opt/solarisstudio12.4/bin/CC -std=c++11 -o CMakeFiles/Test.dir/test.cpp.o
-c /usr/u/i051466/tests/cmake/build/test.cpp
[100%] Linking CXX executable Test
/usr/u/i051466/INSTALL.122/bin/cmake -E cmake_link_script
CMakeFiles/Test.dir/link.txt --verbose=1
/opt/solarisstudio12.4/bin/CC CMakeFiles/Test.dir/test.cpp.o -o Test
Undefined first referenced
symbol in file
std::ctype<char>::_M_widen_init()const CMakeFiles/Test.dir/test.cpp.o
std::ostream::put(char) CMakeFiles/Test.dir/test.cpp.o
std::__throw_bad_cast() CMakeFiles/Test.dir/test.cpp.o
__SUNW_ABIG3_cpp_personality CMakeFiles/Test.dir/test.cpp.o
__cxxabiv1::register_exit_code(void (*)(void)extern"C")
CMakeFiles/Test.dir/test.cpp.o
std::ostream::flush() CMakeFiles/Test.dir/test.cpp.o
std::cout CMakeFiles/Test.dir/test.cpp.o
[Hint: static member std::cout must be defined in the program]
std::ios::clear(std::_Ios_Iostate) CMakeFiles/Test.dir/test.cpp.o
std::ios_base::Init::~Init() CMakeFiles/Test.dir/test.cpp.o
std::ios_base::Init::Init() CMakeFiles/Test.dir/test.cpp.o
std::ostream & std::__ostream_insert<char, std::char_traits<char>
>(std::ostream &,const char*,int) CMakeFiles/Test.dir/test.cpp.o
ld: fatal: symbol referencing errors
FYI:
* If I add option –std=c++11 in the file …/Test.dir/link.txt, link is successful
* I built CMake using version 12.2 of SolarisStudio because if I use
SolarisStudio 12.4, cmake tool is unsuable (I will sent another mail describing
this problem).
Marc
cmake_minimum_required (VERSION 3.3.2)
project (Test LANGUAGES CXX)
file (WRITE ${CMAKE_BINARY_DIR}/test.cpp "#include <iostream>\nint main
()\n{std::cout <<\"Hello\"<<std::endl;return 0;}\n")
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_CXX_STANDARD 11)
add_executable (Test ${CMAKE_BINARY_DIR}/test.cpp)
--
Powered by www.kitware.com
Please keep messages on-topic and check the CMake FAQ at:
http://www.cmake.org/Wiki/CMake_FAQ
Kitware offers various services to support the CMake community. For more
information on each offering, please visit:
CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers