uriparser / uriparser

:hocho: Strictly RFC 3986 compliant URI parsing and handling library written in C89; moved from SourceForge to GitHub

Home Page:https://uriparser.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failure to Compile: Missing <config.h> CMake Android Target

danoli3 opened this issue · comments

Not sure why this file is missing... is there any documentation to setting one up otherwise??

Or what in CMake is failing

Error in build:

/Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang --target=aarch64-none-linux-android21 --sysroot=/Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot  -I/Users/~/SOURCE/apothecary/apothecary/build/uriparser/src -I/Users/~/SOURCE/apothecary/apothecary/build/uriparser/include -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fexceptions -O3 -DNDEBUG -fPIC -nostdlib -fPIC -MD -MT CMakeFiles/uriparser.dir/src/UriMemory.c.o -MF CMakeFiles/uriparser.dir/src/UriMemory.c.o.d -o CMakeFiles/uriparser.dir/src/UriMemory.c.o -c /Users/one/SOURCE/apothecary/apothecary/build/uriparser/src/UriMemory.c
/Users/~/SOURCE/apothecary/apothecary/build/uriparser/src/UriMemory.c:45:10: fatal error: 'config.h' file not found
#include <config.h>
         ^~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/uriparser.dir/src/UriMemory.c.o] Error 1
make[1]: *** [CMakeFiles/uriparser.dir/all] Error 2
make: *** [all] Error 2

Potential cause:
config.h is in the gitignore:
Screen Shot 2022-01-11 at 5 19 29 pm

Temp solution remove from UriMemory.h

#include <config.h>

Adding PR

Hi @danoli3 ,

Not sure why this file is missing... is there any documentation to setting one up otherwise??

the file is generated by CMake and put into the build directory. The related code is at:

uriparser/CMakeLists.txt

Lines 115 to 117 in 46afee4

check_symbol_exists(wprintf wchar.h HAVE_WPRINTF)
check_function_exists(reallocarray HAVE_REALLOCARRAY) # no luck with CheckSymbolExists
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/UriConfig.h.in config.h)

So either the file is not generated or the compiler doesn't find it. My current guess is the latter, see below.

Error in build:

/Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang --target=aarch64-none-linux-android21 --sysroot=/Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot  -I/Users/~/SOURCE/apothecary/apothecary/build/uriparser/src -I/Users/~/SOURCE/apothecary/apothecary/build/uriparser/include -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fexceptions -O3 -DNDEBUG -fPIC -nostdlib -fPIC -MD -MT CMakeFiles/uriparser.dir/src/UriMemory.c.o -MF CMakeFiles/uriparser.dir/src/UriMemory.c.o.d -o CMakeFiles/uriparser.dir/src/UriMemory.c.o -c /Users/one/SOURCE/apothecary/apothecary/build/uriparser/src/UriMemory.c
/Users/~/SOURCE/apothecary/apothecary/build/uriparser/src/UriMemory.c:45:10: fatal error: 'config.h' file not found
#include <config.h>
         ^~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/uriparser.dir/src/UriMemory.c.o] Error 1
make[1]: *** [CMakeFiles/uriparser.dir/all] Error 2
make: *** [all] Error 2

I don't see any -I/Users/~/SOURCE/apothecary/apothecary/build/uriparser there. That needs more investigation. I should note you are not the first to build "out of source tree", the CI does that as well, and it works over there. So the question is how your case is different.

Temp solution remove from UriMemory.h

#include <config.h>

Adding PR

That's a non-solution. I have created a pull #136 adding a comment what it's needed for. I will close your pull request in a second. It may work in your case, but it's a plaster that doesn't solve the underlying issue.

@danoli3 can you share the full logs for the output from CMake and the build after?

@danoli3 PS: There is this code in CMakeLists.txt as well:

uriparser/CMakeLists.txt

Lines 191 to 197 in 46afee4

target_include_directories(uriparser
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
PRIVATE
${CMAKE_CURRENT_BINARY_DIR} # for config.h
)

Notice the last line about config.h. I have a feeling there is something broken in your environment.

Full Build Log:

Android 
android_configure: cmake config
NDK_VESION_MAJOR: 23
NDK_PLATFORM: android-21
ANDROID_NDK_HOME: /Users/~/Library/Android/sdk/ndk/23.1.7779620
SYSROOT: /Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot
Toolchain: /Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include
AR: /Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/llvm-ar
Mkdir build
Mkdir build/armeabi-v7a
-- Android: Targeting API '21' with architecture 'arm', ABI 'armeabi-v7a', and processor 'armv7-a'
-- Android: Selected unified Clang toolchain
-- The C compiler identification is Clang 12.0.8
-- The CXX compiler identification is Clang 12.0.8
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Deprecation Warning at CMakeLists.txt:3 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- Configuring done
-- Generating done
-- Build files have been written to: /Users/~/SOURCE/apothecary/apothecary/build/uriparser/build
/opt/homebrew/Cellar/cmake/3.22.1/bin/cmake -S/Users/~/SOURCE/apothecary/apothecary/build/uriparser -B/Users/~/SOURCE/apothecary/apothecary/build/uriparser/build --check-build-system CMakeFiles/Makefile.cmake 0
/opt/homebrew/Cellar/cmake/3.22.1/bin/cmake -E cmake_progress_start /Users/~/SOURCE/apothecary/apothecary/build/uriparser/build/CMakeFiles /Users/~/SOURCE/apothecary/apothecary/build/uriparser/build//CMakeFiles/progress.marks
/Applications/Xcode.app/Contents/Developer/usr/bin/make  -f CMakeFiles/Makefile2 all
/Applications/Xcode.app/Contents/Developer/usr/bin/make  -f CMakeFiles/uriparser.dir/build.make CMakeFiles/uriparser.dir/depend
cd /Users/~/SOURCE/apothecary/apothecary/build/uriparser/build && /opt/homebrew/Cellar/cmake/3.22.1/bin/cmake -E cmake_depends "Unix Makefiles" /Users/~/SOURCE/apothecary/apothecary/build/uriparser /Users/~/SOURCE/apothecary/apothecary/build/uriparser /Users/~/SOURCE/apothecary/apothecary/build/uriparser/build /Users/~/SOURCE/apothecary/apothecary/build/uriparser/build /Users/~/SOURCE/apothecary/apothecary/build/uriparser/build/CMakeFiles/uriparser.dir/DependInfo.cmake --color=
/Applications/Xcode.app/Contents/Developer/usr/bin/make  -f CMakeFiles/uriparser.dir/build.make CMakeFiles/uriparser.dir/build
[  6%] Building C object CMakeFiles/uriparser.dir/src/UriCommon.c.o
/Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang --target=armv7-none-linux-androideabi21 --sysroot=/Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot  -I/Users/~/SOURCE/apothecary/apothecary/build/uriparser/src -I/Users/~/SOURCE/apothecary/apothecary/build/uriparser/include -O3 -DNDEBUG -fPIC -mfloat-abi=softfp -nostdlib -fPIC -MD -MT CMakeFiles/uriparser.dir/src/UriCommon.c.o -MF CMakeFiles/uriparser.dir/src/UriCommon.c.o.d -o CMakeFiles/uriparser.dir/src/UriCommon.c.o -c /Users/~/SOURCE/apothecary/apothecary/build/uriparser/src/UriCommon.c
[ 12%] Building C object CMakeFiles/uriparser.dir/src/UriCompare.c.o
/Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang --target=armv7-none-linux-androideabi21 --sysroot=/Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot  -I/Users/~/SOURCE/apothecary/apothecary/build/uriparser/src -I/Users/~/SOURCE/apothecary/apothecary/build/uriparser/include -O3 -DNDEBUG -fPIC -mfloat-abi=softfp -nostdlib -fPIC -MD -MT CMakeFiles/uriparser.dir/src/UriCompare.c.o -MF CMakeFiles/uriparser.dir/src/UriCompare.c.o.d -o CMakeFiles/uriparser.dir/src/UriCompare.c.o -c /Users/~/SOURCE/apothecary/apothecary/build/uriparser/src/UriCompare.c
[ 18%] Building C object CMakeFiles/uriparser.dir/src/UriEscape.c.o
/Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang --target=armv7-none-linux-androideabi21 --sysroot=/Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot  -I/Users/~/SOURCE/apothecary/apothecary/build/uriparser/src -I/Users/~/SOURCE/apothecary/apothecary/build/uriparser/include -O3 -DNDEBUG -fPIC -mfloat-abi=softfp -nostdlib -fPIC -MD -MT CMakeFiles/uriparser.dir/src/UriEscape.c.o -MF CMakeFiles/uriparser.dir/src/UriEscape.c.o.d -o CMakeFiles/uriparser.dir/src/UriEscape.c.o -c /Users/~/SOURCE/apothecary/apothecary/build/uriparser/src/UriEscape.c
[ 25%] Building C object CMakeFiles/uriparser.dir/src/UriFile.c.o
/Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang --target=armv7-none-linux-androideabi21 --sysroot=/Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot  -I/Users/~/SOURCE/apothecary/apothecary/build/uriparser/src -I/Users/~/SOURCE/apothecary/apothecary/build/uriparser/include -O3 -DNDEBUG -fPIC -mfloat-abi=softfp -nostdlib -fPIC -MD -MT CMakeFiles/uriparser.dir/src/UriFile.c.o -MF CMakeFiles/uriparser.dir/src/UriFile.c.o.d -o CMakeFiles/uriparser.dir/src/UriFile.c.o -c /Users/~/SOURCE/apothecary/apothecary/build/uriparser/src/UriFile.c
[ 31%] Building C object CMakeFiles/uriparser.dir/src/UriIp4.c.o
/Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang --target=armv7-none-linux-androideabi21 --sysroot=/Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot  -I/Users/~/SOURCE/apothecary/apothecary/build/uriparser/src -I/Users/~/SOURCE/apothecary/apothecary/build/uriparser/include -O3 -DNDEBUG -fPIC -mfloat-abi=softfp -nostdlib -fPIC -MD -MT CMakeFiles/uriparser.dir/src/UriIp4.c.o -MF CMakeFiles/uriparser.dir/src/UriIp4.c.o.d -o CMakeFiles/uriparser.dir/src/UriIp4.c.o -c /Users/~/SOURCE/apothecary/apothecary/build/uriparser/src/UriIp4.c
[ 37%] Building C object CMakeFiles/uriparser.dir/src/UriIp4Base.c.o
/Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang --target=armv7-none-linux-androideabi21 --sysroot=/Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot  -I/Users/~/SOURCE/apothecary/apothecary/build/uriparser/src -I/Users/~/SOURCE/apothecary/apothecary/build/uriparser/include -O3 -DNDEBUG -fPIC -mfloat-abi=softfp -nostdlib -fPIC -MD -MT CMakeFiles/uriparser.dir/src/UriIp4Base.c.o -MF CMakeFiles/uriparser.dir/src/UriIp4Base.c.o.d -o CMakeFiles/uriparser.dir/src/UriIp4Base.c.o -c /Users/~/SOURCE/apothecary/apothecary/build/uriparser/src/UriIp4Base.c
[ 43%] Building C object CMakeFiles/uriparser.dir/src/UriMemory.c.o
/Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang --target=armv7-none-linux-androideabi21 --sysroot=/Users/~/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot  -I/Users/~/SOURCE/apothecary/apothecary/build/uriparser/src -I/Users/~/SOURCE/apothecary/apothecary/build/uriparser/include -O3 -DNDEBUG -fPIC -mfloat-abi=softfp -nostdlib -fPIC -MD -MT CMakeFiles/uriparser.dir/src/UriMemory.c.o -MF CMakeFiles/uriparser.dir/src/UriMemory.c.o.d -o CMakeFiles/uriparser.dir/src/UriMemory.c.o -c /Users/~/SOURCE/apothecary/apothecary/build/uriparser/src/UriMemory.c
/Users/~/SOURCE/apothecary/apothecary/build/uriparser/src/UriMemory.c:45:10: fatal error: 'config.h' file not found
#include <config.h>  /* for HAVE_REALLOCARRAY */
         ^~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/uriparser.dir/src/UriMemory.c.o] Error 1
make[1]: *** [CMakeFiles/uriparser.dir/all] Error 2
make: *** [all] Error 2

 ^ Received error ^

Ahhh looks like the build system was replacing the core CMakeList with its own:

project(uriparser)

cmake_minimum_required(VERSION 2.6)

set (SRC_LIST "src/*.c")

file( GLOB SOURCES ${SRC_LIST} )

add_library(uriparser STATIC ${SOURCES})

target_include_directories( uriparser PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
target_include_directories( uriparser PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include")

if (${ANDROID_ABI} STREQUAL "armeabi-v7a")
   target_compile_options( uriparser PRIVATE "-mfloat-abi=softfp" )
endif()

target_compile_options( uriparser PRIVATE "-nostdlib" )
target_compile_options( uriparser PRIVATE "-fPIC" )

Build Script was:

echo "Android "
		source ../../android_configure.sh $ABI cmake
	    #cp $FORMULA_DIR/CMakeLists.txt . # <--- CAUSE OF BUG


	    echo "Mkdir build"
		mkdir -p build
		echo "Mkdir build/${ABI}"
		local BUILD_TO_DIR="build/${ABI}"

		cd build
		mkdir -p build/${ABI}
		#echo "cd build/${ABI}"
		#cp $FORMULA_DIR/CMakeLists.txt .
		CFLAGS=""
        export CMAKE_CFLAGS="$CFLAGS"
        export CFLAGS=""
        export CPPFLAGS="-fvisibility-inlines-hidden -Wno-implicit-function-declaration"
        export CXXFLAGS="-fvisibility-inlines-hidden -Wno-implicit-function-declaration"
        export CMAKE_LDFLAGS="$LDFLAGS"
       	export LDFLAGS=""
       	
       	
		cmake \
			-DCMAKE_TOOLCHAIN_FILE="$NDK_ROOT/build/cmake/android.toolchain.cmake" \
 			-DANDROID_ABI=${ABI} \
 			-DANDROID_NDK=${NDK_ROOT} \
 			-DANDROID_STL=c++_shared \
 			-DANDROID_PLATFORM=${ANDROID_PLATFORM} \
 			-DURIPARSER_BUILD_TESTS=FALSE \
 			-DURIPARSER_BUILD_DOCS=FALSE \
       		-DCMAKE_C_COMPILER=${CC} \
      	 	-DCMAKE_CXX_COMPILER_RANLIB=${RANLIB} \
      	 	-DCMAKE_C_COMPILER_RANLIB=${RANLIB} \
      	 	-DCMAKE_CXX_COMPILER_AR=${AR} \
      	 	-DCMAKE_C_COMPILER_AR=${AR} \
      	 	-DCMAKE_C_COMPILER=${CC} \
      	 	-DCMAKE_CXX_COMPILER=${CXX} \
      	 	-DCMAKE_C_FLAGS=${CFLAGS} \
      	 	-DCMAKE_CXX_FLAGS=${CXXFLAGS} \
         	-DANDROID_ABI=${ABI} \
         	-DCMAKE_CXX_STANDARD_LIBRARIES=${LIBS} \
         	-DCMAKE_C_STANDARD_LIBRARIES=${LIBS} \
         	-DCMAKE_STATIC_LINKER_FLAGS=${LDFLAGS} \
         	-DANDROID_NATIVE_API_LEVEL=${ANDROID_API} \
         	-DANDROID_TOOLCHAIN=clang++ \
         	-DCMAKE_BUILD_TYPE=Release \
         	 ..
 		make -j${PARALLEL_MAKE} VERBOSE=1
 			
		make VERBOSE=1
		
		cd ..

Custom CMakeList was the cause of the problem! Solved by fixing that override

Thanks for the update!