Google Test 1.6 with Cygwin: 'fileno' was not declared in this scope

1,244 views
Skip to first unread message

Bill

unread,
Sep 12, 2013, 3:05:50 PM9/12/13
to googletes...@googlegroups.com
Error message when building a simple test on Factorial() function in Eclipse CDT:
Invoking: Cygwin C++ Compiler
g++ -std=c++0x -DGTEST_OS_CYGWIN=1 -I"E:\source\gtest-1.6.0\include" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/challenge.d" -MT"src/challenge.d" -o "src/challenge.o" "../src/challenge.cpp"
In file included from E:\source\gtest-1.6.0\include/gtest/internal/gtest-internal.h:40:0,
                 from E:\source\gtest-1.6.0\include/gtest/gtest.h:57,
                 from ../src/challenge.cpp:11:
E:\source\gtest-1.6.0\include/gtest/internal/gtest-port.h: In function 'int testing::internal::posix::FileNo(FILE*)':
E:\source\gtest-1.6.0\include/gtest/internal/gtest-port.h:1589:51: error: 'fileno' was not declared in this scope
E:\source\gtest-1.6.0\include/gtest/internal/gtest-port.h:1595:57: error: 'strdup' was not declared in this scope
E:\source\gtest-1.6.0\include/gtest/internal/gtest-port.h:1627:71: error: 'fdopen' was not declared in this scope

Eclipse CDT 8.1 running gcc 4.7.3 on Cygwin 1.7.22
gTest 1.6 succesfully built including demo tests, with cmake 2.8.9 on Cygwin 1.7.22
I've linked the built lib with full path, E:\lib\gtest-1.6.0\Cygwin\libgtest.a

The following command option was added manually, got same error without it.
-DGTEST_OS_CYGWIN=1

Seems the errors have nothing to do with my code. Any advice please?

Thank you,

RK

unread,
Sep 17, 2013, 2:11:33 PM9/17/13
to googletes...@googlegroups.com
Even I'm getting the same error in cygwin..! If I don't specific the C++ standard as "-std=C++0x", I don't get any compilation error. Also, another observation is it compiles successfully in my RHEL6 OS, so I think it's got something to do with cygwin..! but not sure what it is..

RK

unread,
Sep 18, 2013, 2:01:44 AM9/18/13
to googletes...@googlegroups.com
Try Setting the c++ standard to -std=gnu++0x rather than -std=c++0x. It worked for me. Your compile statement would be something like :
g++ -std=gnu++0x -DGTEST_OS_CYGWIN=1 -I"E:\source\gtest-1.6.0\include" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/challenge.d" -MT"src/challenge.d" -o "src/challenge.o" 


On Friday, September 13, 2013 12:35:50 AM UTC+5:30, Bill wrote:
Reply all
Reply to author
Forward
0 new messages