Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling error 'popen' not declared in this scope #40

Open
yygcode opened this issue Nov 19, 2017 · 1 comment
Open

Compiling error 'popen' not declared in this scope #40

yygcode opened this issue Nov 19, 2017 · 1 comment

Comments

@yygcode
Copy link

yygcode commented Nov 19, 2017

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

@zheng7fu2
Copy link

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants