sdcv icon indicating copy to clipboard operation
sdcv copied to clipboard

Compiling error 'popen' not declared in this scope

Open yygcode opened this issue 6 years ago • 1 comments

My work need windows. I use cygwin64 as terminal. Compile sdcv in cygwin64 would failed with 'popen' not declared error.

This is because popen is not standard ISO C++. The problem can be fix with compiling flag CMAKE_CXX_FLAGS="-U__STRICT_ANSI__". I suggest that you can add the option '-U__STRICT_ANSI__' to the file cmake/compiler.cmake: ~$ git diff `diff --git a/cmake/compiler.cmake b/cmake/compiler.cmake index cf94ed3..f8ebd58 100644 --- a/cmake/compiler.cmake +++ b/cmake/compiler.cmake @@ -23,7 +23,7 @@ elseif (MSVC) elseif (NOT MSVC) check_cxx_compiler_flag("-std=c++11" CXX_SUPPORTS_CXX11) if (CXX_SUPPORTS_CXX11)

  • append("-std=c++11" CMAKE_CXX_FLAGS)
  • append("-std=c++11 -U__STRICT_ANSI__" CMAKE_CXX_FLAGS) else () message(FATAL_ERROR "sdcv requires C++11 support but the '-std=c++11' flag isn't supported.") endif()`

Follows are error details: ~$ git show --oneline 51db56f (HEAD -> master, origin/master, origin/HEAD) Merge pull request #38 from nijel/master ~$ mkdir build; cd build ~$ cmake .. -- The C compiler identification is GNU 6.3.0 -- The CXX compiler identification is GNU 6.3.0 CMake Warning at /usr/share/cmake-3.6.2/Modules/Platform/CYGWIN.cmake:15 (message): CMake no longer defines WIN32 on Cygwin! ... ... -- Configuring done -- Generating done -- Build files have been written to: /cygdrive/e/yanyg-data/git/sdcv/build ~$ make Scanning dependencies of target sdcv [ 12%] Building CXX object CMakeFiles/sdcv.dir/src/sdcv.cpp.o [ 25%] Building CXX object CMakeFiles/sdcv.dir/src/readline.cpp.o [ 37%] Building CXX object CMakeFiles/sdcv.dir/src/libwrapper.cpp.o /cygdrive/e/yanyg-data/git/sdcv/src/libwrapper.cpp: In constructor ‘{anonymous}::sdcv_pager::sdcv_pager(bool)’: /cygdrive/e/yanyg-data/git/sdcv/src/libwrapper.cpp:299:48: error: ‘popen’ was not declared in this scope if (pager && (output = popen(pager, "w")) == nullptr) { ^ /cygdrive/e/yanyg-data/git/sdcv/src/libwrapper.cpp: In destructor ‘{anonymous}::sdcv_pager::~sdcv_pager()’: /cygdrive/e/yanyg-data/git/sdcv/src/libwrapper.cpp:309:26: error: ‘pclose’ was not declared in this scope pclose(output); ^ make[2]: *** [CMakeFiles/sdcv.dir/build.make:111: CMakeFiles/sdcv.dir/src/libwrapper.cpp.o] Error 1 make[1]: *** [CMakeFiles/Makefile2:100: CMakeFiles/sdcv.dir/all] Error 2 make: *** [Makefile:150: all] Error 2

yygcode avatar Nov 19 '17 16:11 yygcode

👍

zheng7fu2 avatar Apr 07 '21 06:04 zheng7fu2