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

GTest fails to build with missing fileno / fdopen #172

Open
jendo42 opened this issue Oct 3, 2024 · 1 comment
Open

GTest fails to build with missing fileno / fdopen #172

jendo42 opened this issue Oct 3, 2024 · 1 comment

Comments

@jendo42
Copy link
Contributor

jendo42 commented Oct 3, 2024

I encountered this build issue

/home/jendo/Sources/ps2dev/build/ps2sdk-ports/build/googletest/googletest/include/gtest/internal/gtest-port.h:2021:40:
error: 'fileno' was not declared in this scope; did you mean 'FileNo'?
 2021 | inline int FileNo(FILE* file) { return fileno(file); }
      |                                        ^~~~~~
      |                                        FileNo
/home/jendo/Sources/ps2dev/build/ps2sdk-ports/build/googletest/googletest/include/gtest/internal/gtest-port.h: In function 'FILE* testing::internal::posix::FDOpen(int, const char*)':
/home/jendo/Sources/ps2dev/build/ps2sdk-ports/build/googletest/googletest/include/gtest/internal/gtest-port.h:2104:56:
error: 'fdopen' was not declared in this scope; did you mean 'fopen'?
 2104 | inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
      |                                                        ^~~~~~
      |                                                        fopen
In file included from /home/jendo/Sources/ps2dev/build/ps2sdk-ports/build/googletest/googletest/src/gtest-all.cc:45:
/home/jendo/Sources/ps2dev/build/ps2sdk-ports/build/googletest/googletest/src/gtest-port.cc: In constructor 'testing::internal::CapturedStream::CapturedStream(int)':
/home/jendo/Sources/ps2dev/build/ps2sdk-ports/build/googletest/googletest/src/gtest-port.cc:1100:31: error: '::mkstemp' has not been declared
 1100 |     const int captured_fd = ::mkstemp(const_cast<char*>(name_template.data()));
      |                               ^~~~~~~
make[3]: *** [googletest/CMakeFiles/gtest.dir/build.make:63: googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.obj] Error 1
make[3]: Leaving directory '/home/jendo/Sources/ps2dev/build/ps2sdk-ports/build/googletest/build_ee'
make[2]: *** [CMakeFiles/Makefile2:227: googletest/CMakeFiles/gtest.dir/all] Error 2
make[2]: Leaving directory '/home/jendo/Sources/ps2dev/build/ps2sdk-ports/build/googletest/build_ee'
make[1]: *** [Makefile:141: all] Error 2
make[1]: Leaving directory '/home/jendo/Sources/ps2dev/build/ps2sdk-ports/build/googletest/build_ee'
make: *** [Makefile:56: cmakelibs] Error 2
make: *** Waiting for unfinished jobs....

When I added -DGTEST_HAS_FILE_SYSTEM=0 then it compiled. Maybe some changes in c glue?

@fjtrujy
Copy link
Member

fjtrujy commented Jan 10, 2025

I encountered this build issue

/home/jendo/Sources/ps2dev/build/ps2sdk-ports/build/googletest/googletest/include/gtest/internal/gtest-port.h:2021:40:
error: 'fileno' was not declared in this scope; did you mean 'FileNo'?
 2021 | inline int FileNo(FILE* file) { return fileno(file); }
      |                                        ^~~~~~
      |                                        FileNo
/home/jendo/Sources/ps2dev/build/ps2sdk-ports/build/googletest/googletest/include/gtest/internal/gtest-port.h: In function 'FILE* testing::internal::posix::FDOpen(int, const char*)':
/home/jendo/Sources/ps2dev/build/ps2sdk-ports/build/googletest/googletest/include/gtest/internal/gtest-port.h:2104:56:
error: 'fdopen' was not declared in this scope; did you mean 'fopen'?
 2104 | inline FILE* FDOpen(int fd, const char* mode) { return fdopen(fd, mode); }
      |                                                        ^~~~~~
      |                                                        fopen
In file included from /home/jendo/Sources/ps2dev/build/ps2sdk-ports/build/googletest/googletest/src/gtest-all.cc:45:
/home/jendo/Sources/ps2dev/build/ps2sdk-ports/build/googletest/googletest/src/gtest-port.cc: In constructor 'testing::internal::CapturedStream::CapturedStream(int)':
/home/jendo/Sources/ps2dev/build/ps2sdk-ports/build/googletest/googletest/src/gtest-port.cc:1100:31: error: '::mkstemp' has not been declared
 1100 |     const int captured_fd = ::mkstemp(const_cast<char*>(name_template.data()));
      |                               ^~~~~~~
make[3]: *** [googletest/CMakeFiles/gtest.dir/build.make:63: googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.obj] Error 1
make[3]: Leaving directory '/home/jendo/Sources/ps2dev/build/ps2sdk-ports/build/googletest/build_ee'
make[2]: *** [CMakeFiles/Makefile2:227: googletest/CMakeFiles/gtest.dir/all] Error 2
make[2]: Leaving directory '/home/jendo/Sources/ps2dev/build/ps2sdk-ports/build/googletest/build_ee'
make[1]: *** [Makefile:141: all] Error 2
make[1]: Leaving directory '/home/jendo/Sources/ps2dev/build/ps2sdk-ports/build/googletest/build_ee'
make: *** [Makefile:56: cmakelibs] Error 2
make: *** Waiting for unfinished jobs....

When I added -DGTEST_HAS_FILE_SYSTEM=0 then it compiled. Maybe some changes in c glue?

Currently, it is being compiled without any issue in the CI/CD, the only custom flag being set on cmake is: -DCMAKE_CXX_FLAGS='-DGTEST_HAS_POSIX_RE=0' and we are using version v1.14.0 not sure if newer version aren't compiling.
Feel free to create a PR upgrading the version.

Cheers

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