schwabe / ics-openvpn

OpenVPN for Android
3.29k stars 1.19k forks source link

error: conflicting types for 'basename' #1618

Closed Anleop closed 1 year ago

Anleop commented 1 year ago

To make issues more manageable, I would appreciate it if you fill out the following details as applicable:

Description of the issue

When I copy the files include(main->aidl,main->cpp,main->java,main->res) to anther Android project, and when I build it, always buld failed. I don't know why,Am I missing any necessary configuration files?

Log contents:

/Users/leo/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang --target=x86_64-none-linux-android24 --sysroot=/Users/leo/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -DCONFIGURE_GIT_FLAGS=\"\" -DCONFIGURE_GIT_REVISION=\"HEAD-HASH-NOTFOUND\" -DENABLE_CRYPTO_OPENSSL=1 -DHAVE_CONFIG_H -DOPENSSL_API_COMPAT=0x11000000L -DTARGET_ABI=\"x86_64\" -Dopenvpn_EXPORTS -I/Users/leo/Desktop/VPN/TestOpenVpn/app/src/main/cpp/openvpn-config -I/Users/leo/Desktop/VPN/TestOpenVpn/app/src/main/cpp/openvpn/src/compat -I/Users/leo/Desktop/VPN/TestOpenVpn/app/src/main/cpp/openvpn/include -I/Users/leo/Desktop/VPN/TestOpenVpn/app/src/main/cpp/mbedtls/include -I/Users/leo/Desktop/VPN/TestOpenVpn/app/src/main/cpp/lzo/include -I/Users/leo/Desktop/VPN/TestOpenVpn/app/src/main/cpp/openvpn -I/Users/leo/Desktop/VPN/TestOpenVpn/app/src/main/cpp/crypto/include -I/Users/leo/Desktop/VPN/TestOpenVpn/app/src/main/cpp/openssl/include -I/Users/leo/Desktop/VPN/TestOpenVpn/app/src/main/cpp/openssl/crypto/include -I/Users/leo/Desktop/VPN/TestOpenVpn/app/src/main/cpp/openssl -I/Users/leo/Desktop/VPN/TestOpenVpn/app/src/main/cpp/openssl/crypto -I/Users/leo/Desktop/VPN/TestOpenVpn/app/src/main/cpp/openssl/crypto/ec/curve448/arch_32 -I/Users/leo/Desktop/VPN/TestOpenVpn/app/src/main/cpp/openssl/crypto/ec/curve448 -I/Users/leo/Desktop/VPN/TestOpenVpn/app/src/main/cpp/openssl/providers/common/include -I/Users/leo/Desktop/VPN/TestOpenVpn/app/src/main/cpp/openssl/providers/implementations/include -I/Users/leo/Desktop/VPN/TestOpenVpn/app/src/main/cpp/lz4/lib -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fno-limit-debug-info -fPIC -MD -MT CMakeFiles/openvpn.dir/openvpn/src/openvpn/schedule.c.o -MF CMakeFiles/openvpn.dir/openvpn/src/openvpn/schedule.c.o.d -o CMakeFiles/openvpn.dir/openvpn/src/openvpn/schedule.c.o -c /Users/leo/Desktop/VPN/TestOpenVpn/app/src/main/cpp/openvpn/src/openvpn/schedule.c In file included from /Users/leo/Desktop/VPN/TestOpenVpn/app/src/main/cpp/openvpn/src/openvpn/schedule.c:30: In file included from /Users/leo/Desktop/VPN/TestOpenVpn/app/src/main/cpp/openvpn/src/openvpn/syshead.h:87: In file included from /Users/leo/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/sys/un.h:41: /Users/leo/Library/Android/sdk/ndk/25.2.9519653/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/string.h:180:7: error: conflicting types for 'basename' char basename(const char path) RENAME(__gnu_basename) __INTRODUCED_IN(23); ^ /Users/leo/Desktop/VPN/TestOpenVpn/app/src/main/cpp/openvpn/src/compat/compat.h:46:7: note: previous declaration is here char basename(char str); ^ 1 error generated.

Configuration file

plugins { id 'com.android.application' }

android { namespace 'com.test.testopenvpn' compileSdk 33

ndkVersion = "25.2.9519653"

defaultConfig {
    applicationId "com.test.testopenvpn"
    minSdk 24
    targetSdk 33
    versionCode 1
    versionName "1.0"

    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}
externalNativeBuild {
    cmake {
        path file('src/main/cpp/CMakeLists.txt')
        version '3.22.1'
    }
}

buildFeatures {
    viewBinding true
}

splits {
    abi {
        include("x86", "x86_64", "armeabi-v7a", "arm64-v8a")
    }
}

}

dependencies {

implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

}

add the contents of the configuration file if applicable
be careful to not post private keys
schwabe commented 1 year ago

You have have different SDK target version (minSDK) than mine which come with different predefined types. You probably need to to either you use the same SDK target version or figure out the differences in the NDK header files and adjust the build files for OpenVPN