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

Get trouble in compiling glog for android! #355

Closed
CarlLyt opened this issue Aug 20, 2018 · 1 comment
Closed

Get trouble in compiling glog for android! #355

CarlLyt opened this issue Aug 20, 2018 · 1 comment

Comments

@CarlLyt
Copy link

CarlLyt commented Aug 20, 2018

Hello everybody.
before compiling, i successfully installed gflag, so there was no warning when i Configure and Generate the glog.
(compile env: win10 ndk17 CMake3.12 MinGW)

test

then i was met errors like this:
D:\Restor\chajian\glog-0.3.5\build>make
[ 44%] Built target glog
[ 55%] Built target utilities_unittest
[ 66%] Built target demangle_unittest
[ 72%] Building CXX object CMakeFiles/logging_unittest.dir/src/logging_unittest.cc.o
D:\Restor\chajian\glog-0.3.5\src\logging_unittest.cc:617:17: error: use of undeclared identifier 'glob'
const int r = glob(pattern.c_str(), 0, NULL, &g);
^
D:\Restor\chajian\glog-0.3.5\src\logging_unittest.cc:622:3: error: use of undeclared identifier 'globfree'
globfree(&g);
^
2 errors generated.
CMakeFiles\logging_unittest.dir\build.make:61: recipe for target 'CMakeFiles/logging_unittest.dir/src/logging_unittest.cc.o' failed
make[2]: *** [CMakeFiles/logging_unittest.dir/src/logging_unittest.cc.o] Error 1
CMakeFiles\Makefile2:1078: recipe for target 'CMakeFiles/logging_unittest.dir/all' failed
make[1]: *** [CMakeFiles/logging_unittest.dir/all] Error 2
Makefile:161: recipe for target 'all' failed
make: *** [all] Error 2

I have no idea with it.
somebody can help me ?

@iliis
Copy link

iliis commented Aug 12, 2019

If you look into $ANDROID_NDK/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/glob.h, you'll find that at least Android API Level 28 (Android 9, "Pie") is required for glob().

However, this is just the compilation of a unittest that fails due to it's reliance on glob(). The library itself doesn't need it. And you don't need those unittests, especially when cross-compiling. So it's enough to just disable BUILD_TESTING in your cmake config.

@sergiud sergiud closed this as completed Mar 30, 2021
@sergiud sergiud mentioned this issue May 6, 2021
Ashoat added a commit to CommE2E/comm that referenced this issue May 24, 2021
Summary:
Atul and I noticed an issue compiling glog. It was [this error](google/glog#355 (comment)), and it should've been addressed by `BUILD_TESTING`, but for some reason it wasn't.

I also noticed that the issue would only consistently repro after cleaning all build artifacts. I'm still not sure why that is.

To debug the issue I ran `./gradlew` with the `-i` flag. I saw this in the output:

```
evaluate library symbolize_unittest (armeabi-v7a)
No CMake version was specified in build.gradle. Using default version 3.10.2.
building target executable symbolize_unittest because no targets are specified.
```

This led me to realize that because we weren't specifying `targets`, Gradle was configured to separately build `glog` directly (instead of through our `CMakeLists.txt`), and that was what was causing the issue.

Test Plan:
Make sure Android can build after cleaning all build artifacts:

```
./gradlew clean && rm -rf build && rm -rf app/build && rm -rf app/.cxx && ./gradlew app:installDebug -PreactNativeDevServerPort=8081
```

Reviewers: karol-bisztyga, atul

Reviewed By: atul

Subscribers: KatPo, palys-swm, Adrian

Differential Revision: https://phabricator.ashoat.com/D1231
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

3 participants