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

C/C++: ld: error: undefined symbol: globfree #78

Closed the-unknown closed 10 months ago

the-unknown commented 10 months ago

Hey, First of all, I am using Expo, but as far as I understand this error, this should not be an Expo issue.

When I try to run/build my code, it exits with this error:

C/C++: ld: error: undefined symbol: glob
C/C++: ld: error: undefined symbol: globfree
C/C++: clang: error: linker command failed with exit code 1 (use -v to see invocation)

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

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':dr.pogodin_react-native-static-server:buildCMakeDebug[arm64-v8a][lighttpd]'.
> com.android.ide.common.process.ProcessException: ninja: Entering directory `/home/user/Arbeit/change/project/project-expo/node_modules/@dr.pogodin/react-native-static-server/android/.cxx/Debug/3a3sm4k3/arm64-v8a'
  [0/1] Re-running CMake...
  '/usr/bin/cmake' '/home/user/Arbeit/change/project/project-expo/node_modules/@dr.pogodin/react-native-static-server/pcre2' '-B' '/home/user/Arbeit/change/project/project-expo/node_modules/@dr.pogodin/react-native-static-server/android/.cxx/Debug/3a3sm4k3/arm64-v8a/pcre2' '-DCMAKE_BUILD_TYPE=Release' '-DCMAKE_INSTALL_PREFIX=/home/user/Arbeit/change/project/project-expo/node_modules/@dr.pogodin/react-native-static-server/android/.cxx/Debug/3a3sm4k3/arm64-v8a/sysroot' '-DCMAKE_MAKE_PROGRAM=/usr/bin/ninja' '-DANDROID_ABI=arm64-v8a' '-DANDROID_PLATFORM=android-21' '-DANDROID_STL=' '-DCMAKE_TOOLCHAIN_FILE=/home/user/Android/Sdk/ndk/23.1.7779620/build/cmake/android.toolchain.cmake' '-GNinja' '-DBUILD_SHARED_LIBS=ON'
  -- Could NOT find BZip2 (missing: BZIP2_LIBRARIES BZIP2_INCLUDE_DIR) 
  -- Could not find OPTIONAL package Readline
  -- Could not find OPTIONAL package Editline
  -- 
  -- 
  -- PCRE2-10.42 configuration summary:
  -- 
  --   Install prefix .................. : /home/user/Arbeit/change/project/project-expo/node_modules/@dr.pogodin/react-native-static-server/android/.cxx/Debug/3a3sm4k3/arm64-v8a/sysroot
  --   C compiler ...................... : /home/user/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/bin/clang
  --   C compiler flags ................ : -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fexceptions -O3 -DNDEBUG
  -- 
  --   Build 8 bit PCRE2 library ....... : ON
  --   Build 16 bit PCRE2 library ...... : OFF
  --   Build 32 bit PCRE2 library ...... : OFF
  --   Enable JIT compiling support .... : OFF
  --   Use SELinux allocator in JIT .... : IGNORE
  --   Enable Unicode support .......... : ON
  --   Newline char/sequence ........... : LF
  --   \R matches only ANYCRLF ......... : OFF
  --   \C is disabled .................. : OFF
  --   EBCDIC coding ................... : OFF
  --   EBCDIC coding with NL=0x25 ...... : OFF
  --   Rebuild char tables ............. : OFF
  --   Internal link size .............. : 2
  --   Parentheses nest limit .......... : 250
  --   Heap limit ...................... : 20000000
  --   Match limit ..................... : 10000000
  --   Match depth limit ............... : MATCH_LIMIT
  --   Build shared libs ............... : ON
  --   Build static libs ............... : ON
  --      with PIC enabled ............. : OFF
  --   Build pcre2grep ................. : ON
  --   Enable JIT in pcre2grep ......... : ON
  --   Enable callouts in pcre2grep .... : ON
  --   Enable callout fork in pcre2grep. : ON
  --   Buffer size for pcre2grep ....... : 20480
  --   Build tests (implies pcre2test .. : ON
  --                and pcre2grep)
  --   Link pcre2grep with libz ........ : ON
  --   Link pcre2grep with libbz2 ...... : Library not found
  --   Link pcre2test with libeditline . : Library not found
  --   Link pcre2test with libreadline . : Library not found
  --   Support Valgrind .................: OFF
  --   Use %zu and %td ..................: AUTO
  -- 
  -- Configuring done
  -- Generating done

 -- Up-to-date: /home/user/Arbeit/change/project/project-expo/node_modules/@dr.pogodin/react-native-static-server/android/.cxx/Debug/3a3sm4k3/arm64-v8a/sysroot/share/doc/pcre2/html/pcre2unicode.html
  -- Android: Selected unified Clang toolchain
  -- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
      Reason given by package: The command
        "/usr/bin/pkg-config" --libs-only-l --version
      failed with output:

      stderr: 
        Ignoring incompatible output option "--version"
      Must specify package names on the command line
      result: 
  1

  -- found pcre2-config: /usr/bin/pcre2-config
  -- found pcre2 at: LDFLAGS: -lpcre2-8 CFLAGS: 
  -- Configuring done
  -- Generating done

 FAILED: ../../../../build/intermediates/cxx/Debug/3a3sm4k3/obj/arm64-v8a/liblighttpd.so 
  : && /home/user/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --target=aarch64-none-linux-android21 --sysroot=/home/user/Android/Sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/linux-x86_64/sysroot -fPIC -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fexceptions -DPCRE2_CODE_UNIT_WIDTH=8 -I/home/user/Arbeit/change/project/project-expo/node_modules/@dr.pogodin/react-native-static-server/android/.cxx/Debug/3a3sm4k3/arm64-v8a/sysroot/include -L/home/user/Arbeit/change/project/project-expo/node_modules/@dr.pogodin/react-native-static-server/android/.cxx/Debug/3a3sm4k3/arm64-v8a/sysroot/lib  -pipe -Wall -g -Wshadow -W -pedantic  -g  -fno-limit-debug-info       -O0  -Wl,--build-id=sha1 -Wl,--no-rosegment -Wl,--fatal-warnings -Qunused-arguments -Wl,--no-undefined  -Wl,--gc-sections      -Wl,-export-dynamic -shared -Wl,-soname,liblighttpd.so -o ../../../../build/intermediates/cxx/Debug/3a3sm4k3/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  -lpcre2-8  /home/user/Android/Sdk/ndk/23.1.7779620/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:2465 (/home/user/Arbeit/change/project/project-expo/node_modules/@dr.pogodin/react-native-static-server/lighttpd1.4/src/configfile.c:2465)
  >>>               lighttpd1.4/build/CMakeFiles/lighttpd.dir/configfile.c.o:(config_parse_file)

  ld: error: undefined symbol: globfree
  >>> referenced by configfile.c:2471 (/home/user/Arbeit/change/project/project-expo/node_modules/@dr.pogodin/react-native-static-server/lighttpd1.4/src/configfile.c:2471)
  >>>               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)
  ninja: build stopped: subcommand failed.

  C++ build system [build] failed while executing:
      /usr/bin/ninja \
        -C \
        /home/user/Arbeit/change/project/project-expo/node_modules/@dr.pogodin/react-native-static-server/android/.cxx/Debug/3a3sm4k3/arm64-v8a \
        lighttpd
    from /home/user/Arbeit/change/project/project-expo/node_modules/@dr.pogodin/react-native-static-server/android
  CMake Warning (dev) at CMakeLists.txt:126:
    Syntax Warning in cmake code at column 25

    Argument not separated from preceding token by whitespace.
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at CMakeLists.txt:127:
    Syntax Warning in cmake code at column 30

    Argument not separated from preceding token by whitespace.
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at CMakeLists.txt:128:
    Syntax Warning in cmake code at column 22

    Argument not separated from preceding token by whitespace.
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at CMakeLists.txt:129:
    Syntax Warning in cmake code at column 29

    Argument not separated from preceding token by whitespace.
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at CMakeLists.txt:130:
    Syntax Warning in cmake code at column 30

    Argument not separated from preceding token by whitespace.
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at CMakeLists.txt:1 (project):
    Policy CMP0048 is not set: project() command manages VERSION variables.
    Run "cmake --help-policy CMP0048" for policy details.  Use the cmake_policy
    command to set the policy and suppress this warning.

    The following variable(s) would be set to empty:

      CMAKE_PROJECT_VERSION
      CMAKE_PROJECT_VERSION_MAJOR
      CMAKE_PROJECT_VERSION_MINOR
      CMAKE_PROJECT_VERSION_PATCH
  This warning is for project developers.  Use -Wno-dev to suppress it.

  adding property to lighttpd-angel COMPILE_FLAGS: -DSBIN_DIR=\"/usr/local/sbin\"
  adding property to lighttpd COMPILE_FLAGS:
  adding property to test_common COMPILE_FLAGS:
  adding property to test_configfile COMPILE_FLAGS:
  adding property to test_mod COMPILE_FLAGS:
  adding property to lighttpd LINK_FLAGS: -Wl,-export-dynamic

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1m 13s
229 actionable tasks: 25 executed, 11 from cache, 193 up-to-date

CMake is installed in via commandline as well as in Android Studio. The Android NDKs I have installed: 23.1.7779620 25.2.9519653 26.0.10792818

Any idea what's wrong?

birdofpreyru commented 10 months ago

Yes, you have not set minSdkVersion to 28 or larger, as mentioned in Getting Started for Android (glob library was included into Android SDK since v28).

the-unknown commented 10 months ago

Well, I did change that:

/android/app/build.gradle


android {
    ndkVersion rootProject.ext.ndkVersion

    compileSdkVersion rootProject.ext.compileSdkVersion

    namespace 'com.changeowu.warakruexpo'
    defaultConfig {
        applicationId 'com.changeowu.warakruexpo'
       // minSdkVersion rootProject.ext.minSdkVersion
        minSdkVersion 28
        targetSdkVersion rootProject.ext.targetSdkVersion
        versionCode 1
        versionName "1.0.0"

        buildConfigField("boolean", "REACT_NATIVE_UNSTABLE_USE_RUNTIME_SCHEDULER_ALWAYS", (findProperty("reactNative.unstable_useRuntimeSchedulerAlways") ?: true).toString())
    }
    signingConfigs {
        debug {
            storeFile file('debug.keystore')
            storePassword 'android'
            keyAlias 'androiddebugkey'
            keyPassword 'android'
        }
    }
    buildTypes {
        debug {
            signingConfig signingConfigs.debug
        }
        release {
            // Caution! In production, you need to generate your own keystore file.
            // see https://reactnative.dev/docs/signed-apk-android.
            signingConfig signingConfigs.debug
            shrinkResources (findProperty('android.enableShrinkResourcesInReleaseBuilds')?.toBoolean() ?: false)
            minifyEnabled enableProguardInReleaseBuilds
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
}
birdofpreyru commented 10 months ago

Look carefully at the example app, where it has to be set: https://github.com/birdofpreyru/react-native-static-server/blob/master/example/android/build.gradle (not android/app/build.gradle).

the-unknown commented 10 months ago

Alright! That did the trick! sorry :see_no_evil: