birdofpreyru / react-native-static-server

Embedded HTTP server for React Native
https://dr.pogodin.studio/docs/react-native-static-server
Other
135 stars 21 forks source link

> Task :dr.pogodin_react-native-static-server:buildCMakeDebug[arm64-v8a][lighttpd] FAILED #102

Closed Ahmedhussein-92 closed 4 months ago

Ahmedhussein-92 commented 5 months ago

Hello Mr Sergey! @birdofpreyru Hope you are having a great day/night.

I'm facing some kind of problem when I'm trying to use the library @dr.pogodin_react-native-static-server with my react native expo on Ubuntu 22.04 system when I try to build and run the application.


Task :dr.pogodin_react-native-static-server:buildCMakeDebug[arm64-v8a][lighttpd] FAILED C/C++: ninja: error: 'sysroot/bin/pcre2-config: 3: -: not found-L/lib -lpcre2-8', needed by '../../../../build/intermediates/cxx/Debug/v4915133/obj/arm64-v8a/liblighttpd.so', missing and no known rule to make it

FAILURE: Build failed with an exception.

BUILD FAILED in 10s 541 actionable tasks: 4 executed, 6 from cache, 531 up-to-date Error: /home/peace/Ramses - Work/super-app/android/gradlew exited with non-zero code: 1 Error: /home/peace/Ramses - Work/super-app/android/gradlew exited with non-zero code: 1 at ChildProcess.completionListener (/home/peace/Ramses - Work/super-app/node_modules/@expo/spawn-async/build/spawnAsync.js:52:23) at Object.onceWrapper (node:events:632:26) at ChildProcess.emit (node:events:517:28) at maybeClose (node:internal/child_process:1098:16) at ChildProcess._handle.onexit (node:internal/child_process:303:5) ... at Object.spawnAsync [as default] (/home/peace/Ramses - Work/super-app/node_modules/@expo/spawn-async/build/spawnAsync.js:17:21) at spawnGradleAsync (/home/peace/Ramses - Work/super-app/node_modules/@expo/cli/build/src/start/platforms/android/gradle.js:72:46) at Object.assembleAsync (/home/peace/Ramses - Work/super-app/node_modules/@expo/cli/build/src/start/platforms/android/gradle.js:52:18) at runAndroidAsync (/home/peace/Ramses - Work/super-app/node_modules/@expo/cli/build/src/run/android/runAndroidAsync.js:36:24) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)


So would like to ask please if you could help me trying to solve it?

Thanks a lot in advance!

Ahmedhussein-92 commented 5 months ago

Screenshot from 2024-03-22 01-17-39

Screen shot of the problem

Ahmedhussein-92 commented 5 months ago

Screenshot from 2024-03-22 02-05-25

This is the first time I encountered this error

birdofpreyru commented 5 months ago

Sorry @Ahmedhussein-92 , as of now I not supporting Expo for this library.

Ahmedhussein-92 commented 5 months ago

Hello Dr Sergey! @birdofpreyru Thanks a lot for replying.

Well, I created a new react native project without using expo at all and just installed the library. But still got the same error, unfortunately.

So, is there any pre configurations I have to do? Or suggestions how to solve it?

gstrauss commented 5 months ago

@Ahmedhussein-92 you might try building in a directory tree which does not contain spaces and dashes in the directory names, i.e. without "/Ramses - Work/"

fullStackOasis commented 4 months ago

@Ahmedhussein-92 I haven't been able to solve this, but I think I can confirm that your issue exists and may be related to Ubuntu's libraries (also on Ubuntu 22 here).

My detailed output failure is at this line:

/home/user/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=aarch64-none-linux-android21 --sysroot=/home/user/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -I/home/user/Projects/ReactNativeFS/node_modules/@dr.pogodin/react-native-static-server/android/.cxx/Debug/5q3g5m60/arm64-v8a/sysroot/include -pipe -Wall -g -Wshadow -W -pedantic -fno-limit-debug-info -O0 -static-libstdc++ -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Wl,--gc-sections -Wl,--no-undefined -Qunused-arguments -Wl,--gc-sections -Wl,-export-dynamic -shared -Wl,-soname,liblighttpd.so -o ../../../../build/intermediates/cxx/Debug/5q3g5m60/obj/arm64-v8a/liblighttpd.so lighttpd1.4/build/CMakeFiles/lighttpd.dir/server.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/response.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/connections.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/h1.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/sock_addr_cache.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/fdevent_impl.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/http_range.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/network.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/network_write.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/data_config.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/configfile.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/configparser.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/base64.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/buffer.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/burl.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/log.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/http_header.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/http_kv.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/keyvalue.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/chunk.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/http_chunk.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/fdevent.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/fdevent_fdnode.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/gw_backend.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/stat_cache.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/http_etag.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/array.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/algo_md5.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/algo_sha1.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/algo_splaytree.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/configfile-glue.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/http-header-glue.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/http_cgi.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/http_date.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/plugin.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/reqpool.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/request.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/sock_addr.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/rand.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/fdlog_maint.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/fdlog.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/sys-setjmp.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/ck.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_rewrite.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_redirect.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_access.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_alias.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_indexfile.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_staticfile.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_setenv.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_expire.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_simple_vhost.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_evhost.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_fastcgi.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_scgi.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_accesslog.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_ajp13.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_auth.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_auth_api.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_authn_file.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_cgi.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_deflate.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_dirlisting.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_extforward.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_proxy.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_rrdtool.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_sockproxy.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_ssi.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_status.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_userdir.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_vhostdb.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_vhostdb_api.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_webdav.c.o lighttpd1.4/build/CMakeFiles/lighttpd.dir/mod_wstunnel.c.o -llog lighttpd1.4/build/libmod_accesslog.a lighttpd1.4/build/libmod_ajp13.a lighttpd1.4/build/libmod_auth.a lighttpd1.4/build/libmod_authn_file.a lighttpd1.4/build/libmod_cgi.a lighttpd1.4/build/libmod_deflate.a lighttpd1.4/build/libmod_dirlisting.a lighttpd1.4/build/libmod_extforward.a lighttpd1.4/build/libmod_h2.a lighttpd1.4/build/libmod_proxy.a lighttpd1.4/build/libmod_rrdtool.a lighttpd1.4/build/libmod_sockproxy.a lighttpd1.4/build/libmod_ssi.a lighttpd1.4/build/libmod_status.a lighttpd1.4/build/libmod_userdir.a lighttpd1.4/build/libmod_vhostdb.a lighttpd1.4/build/libmod_webdav.a lighttpd1.4/build/libmod_wstunnel.a -L/home/user/Projects/ReactNativeFS/node_modules/@dr.pogodin/react-native-static-server/android/.cxx/Debug/5q3g5m60/arm64-v8a/sysroot/lib -lpcre2-8 /home/user/Android/Sdk/ndk/25.1.8937393/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/21/libz.so -latomic -lm ld: error: undefined symbol: glob

referenced by configfile.c:2428 (/home/user/Projects/ReactNativeFS/node_modules/@dr.pogodin/react-native-static-server/lighttpd1.4/src/configfile.c:2428) lighttpd1.4/build/CMakeFiles/lighttpd.dir/configfile.c.o:(config_parse_file)

ld: error: undefined symbol: globfree

referenced by configfile.c:2434 (/home/user/Projects/ReactNativeFS/node_modules/@dr.pogodin/react-native-static-server/lighttpd1.4/src/configfile.c:2434) lighttpd1.4/build/CMakeFiles/lighttpd.dir/configfile.c.o:(config_parse_file) clang: error: linker command failed with exit code 1 (use -v to see invocation)

So the ultimate issue seems to be glob not found?

birdofpreyru commented 4 months ago

@fullStackOasis have you set minSdkVersion for Android equal 28 or above? That glob library is not included into older Android SDKs, thus not found if build with smaller min SDK version.

fullStackOasis commented 4 months ago

Hi @birdofpreyru thank you for responding.

May I suggest that you please remove the "Expo" tag from this issue, since it doesn't seem to be related to Expo?

My situation is that I tried to install and use your react-native-fs, and I found the error that was described above. While searching, I found this same error here, and so I left this feedback.

To be clear: I had installed a completely new React Native project from scratch, using react-native init. Like this:

npx react-native@0.73.7 init ReactNativeStaticServer --version 0.73.7

I had to specify 0.73.7 because we have the good misfortune that RN 0.74 was released yesterday and lots of things are breaking.

I did this because I wanted a very simple project where I could test this library to see if it does what I need it to do.

When you run npx react-native@0.73.7 init, minSdkVersion in build.gradle is set to 21.

I've updated android/build.gradle to set minSdkVersion = 28 and the compile message was fixed!

I think this issue must also affect react-native-fs, which is where I came from.... I don't see the requirement for minSdkVersion in that project (but maybe I missed it somewhere). Does it make sense to add some documentation about this to react-native-fs, as well?

@Ahmedhussein-92 please note the above possible solution to your issue.

birdofpreyru commented 4 months ago

@fullStackOasis

May I suggest that you please remove the "Expo" tag from this issue, since it doesn't seem to be related to Expo?

The error originally reported by @Ahmedhussein-92 in this ticket was different (failure to link another library for different reasons), and it happened to him in Expo project, thus the tag.

When you run npx react-native@0.73.7 init, minSdkVersion in build.gradle is set to 21.

This is correct, RN@0.73 supports Android SDKs starting from 21, and RN@0.74 aims to support Android SDKs starting from 23. However, this react-native-static-server library only supports Android SDKs 28+, and it is mentioned in the README's Getting Started section. And this is exactly because Lighttpd relies on Glob library, which is not a part of older Android SDKs, thus it would be needed to be built from sources during the build to support those older versions, and I don't want to invest my time (thus my money) into it, if nobody else sponsors it (considering SDK 28 was released back in August 2018, supporting 28+ is fine for me and my own projects).

I think this issue must also affect react-native-fs, which is where I came from....

react-native-fs (my fork of it) itself does not rely on this react-native-static-server, thus this SDK version stuff is irrelevant to it. The example app of react-native-fs does rely on react-native-static-server, and it has the correct minSdkVersion set in its build.gradle. So, I am not sure why would you bump into this issue there.

Finally, considering that @Ahmedhussein-92 did not follow-up on the issue, and your problem was different and perhaps solved, I am closing this ticket. If you find more issues with the build, feel free to open a new one.

Ahmedhussein-92 commented 4 months ago

Hello! @birdofpreyru. Sorry was so busy at a work last couple of weeks. So couldn't reply to it. Thanks for your relpying!

@fullStackOasis, Hello! Thanks a lot for trying to help. Part of the problem was related to some Ubuntu configurations and libraries as you mentioned. Had to do some clean up but even after that, the issue was still happening, so I installed a new version of Ubuntu.

Then I had to use this command from the official npm package page of the library: https://www.npmjs.com/package/@dr.pogodin/react-native-static-server

npx install-peerdeps @dr.pogodin/react-native-static-server

Just for the first time of the installation. And after that the problem didn't occur.

@birdofpreyru. I guess as you said Dr Sergey, the issue is solved now. Thanks a lot for your time and helping.