schwabe / ics-openvpn

OpenVPN for Android
3.29k stars 1.19k forks source link

Cannot loading project #832

Closed Moussawi90 closed 6 years ago

Moussawi90 commented 6 years ago

I tried to open the project with android studio but I get an error before running it The error occurs while loading the project:

CMake Error at CMakeLists.txt:33(add_library) .... ...Labalabla... .... CMake Error: CMake can not determine linker language for target: ovpn3

Moussawi90 commented 6 years ago

It seems that the error is due to the invalidity of path of file "openvpn3/javacli/ovpncli_wrap.cxx" defined in ovpn3_SRC at line 31

schwabe commented 6 years ago

You are missing swig. See the readme.

richardmobile commented 6 years ago

Have same issue. I have read the readme and installed swig, but this issue is occurring on my side. I have been suing Android Studio 3.0.1 on Mac OS X Please help me. Thanks.

schwabe commented 6 years ago

@richardmobile the original error was for missing swig. Try also if gradlew build works.

Also without the real log/error message I can only guess what is wrong

Moussawi90 commented 6 years ago

@richardmobile You may need to restart your PC, because yesterday after I installed the swig I tried to open project but I got the same error, after restarting PC it works to be sure that swig is installed try to open terminal (or whatever its equivalent for mac) and type swig to test if it is installed correctly

richardmobile commented 6 years ago

@schwabe thanks for your quick reply.

Error:

Build command failed.
Error while executing process /Volumes/Data/sdk/cmake/3.6.4111459/bin/cmake with arguments {-H/Volumes/Work/Task/ics-openvpn/main/src/main/cpp -B/Volumes/Work/Task/ics-openvpn/main/.externalNativeBuild/cmake/normalRelease/armeabi-v7a -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-14 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/Volumes/Work/Task/ics-openvpn/main/build/intermediates/cmake/normal/release/obj/armeabi-v7a -DCMAKE_BUILD_TYPE=Release -DANDROID_NDK=/Volumes/Data/sdk/ndk-bundle -DCMAKE_TOOLCHAIN_FILE=/Volumes/Data/sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=/Volumes/Data/sdk/cmake/3.6.4111459/bin/ninja -GAndroid Gradle - Ninja -DANDROID_TOOLCHAIN=clang -DANDROID_STL=c++_static}
-- Check for working C compiler: /Volumes/Data/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang
-- Check for working C compiler: /Volumes/Data/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Volumes/Data/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++
-- Check for working CXX compiler: /Volumes/Data/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
OpenVPN 2.x version v2.4_rc2-260-ga46cc806
OpenVPN 3.x version 902ddf9f
-- The ASM compiler identification is Clang
-- Found assembler: /Volumes/Data/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang
-- Found Perl: /usr/bin/perl (found version "5.18.2") 
No such file: /Volumes/Work/Task/ics-openvpn/main/src/main/cpp/include/mbedtls/config.h
-- Configuring done
CMake Error at CMakeLists.txt:33 (add_library):
    openvpn3/javacli/ovpncli_wrap.cxx
  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx
CMake Error: CMake can not determine linker language for target: ovpn3
-- Generating done
-- Build files have been written to: /Volumes/Work/Task/ics-openvpn/main/.externalNativeBuild/cmake/normalRelease/armeabi-v7a
Build command failed.
Error while executing process /Volumes/Data/sdk/cmake/3.6.4111459/bin/cmake with arguments {-H/Volumes/Work/Task/ics-openvpn/main/src/main/cpp -B/Volumes/Work/Task/ics-openvpn/main/.externalNativeBuild/cmake/normalDebug/armeabi-v7a -DANDROID_ABI=armeabi-v7a -DANDROID_PLATFORM=android-14 -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/Volumes/Work/Task/ics-openvpn/main/build/intermediates/cmake/normal/debug/obj/armeabi-v7a -DCMAKE_BUILD_TYPE=Debug -DANDROID_NDK=/Volumes/Data/sdk/ndk-bundle -DCMAKE_TOOLCHAIN_FILE=/Volumes/Data/sdk/ndk-bundle/build/cmake/android.toolchain.cmake -DCMAKE_MAKE_PROGRAM=/Volumes/Data/sdk/cmake/3.6.4111459/bin/ninja -GAndroid Gradle - Ninja -DANDROID_TOOLCHAIN=clang -DANDROID_STL=c++_static}
-- Check for working C compiler: /Volumes/Data/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang
-- Check for working C compiler: /Volumes/Data/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Volumes/Data/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++
-- Check for working CXX compiler: /Volumes/Data/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
OpenVPN 2.x version v2.4_rc2-260-ga46cc806
OpenVPN 3.x version 902ddf9f
-- The ASM compiler identification is Clang
-- Found assembler: /Volumes/Data/sdk/ndk-bundle/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang
-- Found Perl: /usr/bin/perl (found version "5.18.2") 
No such file: /Volumes/Work/Task/ics-openvpn/main/src/main/cpp/include/mbedtls/config.h
-- Configuring done
CMake Error at CMakeLists.txt:33 (add_library):
    openvpn3/javacli/ovpncli_wrap.cxx
  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx
CMake Error: CMake can not determine linker language for target: ovpn3
-- Generating done
-- Build files have been written to: /Volumes/Work/Task/ics-openvpn/main/.externalNativeBuild/cmake/normalDebug/armeabi-v7a

please have a look for me.

Moussawi90 commented 6 years ago

@richardmobile As Arne say, make sure that swig is installed

richardmobile commented 6 years ago

yeah i have installed swig and swig is working now on terminal

richardmobile commented 6 years ago

@schwabe I have installed swig already and it is working correctly on terminal now, but same issue is occurring. Any idea to solve this issue?

Moussawi90 commented 6 years ago

@schwabe The same problem occurs from new with me after a clean cloning of the project and swig is installed correctly What happens? the log error is the same posted by @richardmobile

schwabe commented 6 years ago

@Moussawi90 no idea. I cannot reproduce the problem here and neither can travis.

richardmobile commented 6 years ago

@Moussawi90 did you solve the issue?

Moussawi90 commented 6 years ago

@richardmobile @schwabe Yes I found the cause of error The error is due to command file(MAKE_DIRECTORY ovpn3/java/net/openvpn/ovpn3) which is equivalent to mkdir in linux and this will give error because you should use mkdir -p So the solution is by mannualy creating the following directory ovpn3/java/net/openvpn/ovpn3 because there is no cmake command to create recursive directory

schwabe commented 6 years ago

cmake docu says it will also create parent directories

MAKE_DIRECTORY will create the given directories, also if their parent directories don’t exist yet
Moussawi90 commented 6 years ago

@schwabe May be it is a bug because I checked if the directory created but nothing created and after I created the path manually It loads the project fine

schwabe commented 6 years ago

@Moussawi90 also the travis CI, which also Linux based, does not fail.

schwabe commented 6 years ago

And that just downloads the ndk, clones the git and does gradlew build.

Moussawi90 commented 6 years ago

@schwabe I tried file(MAKE_DIRECTORY ...) with one directory only (e.g. without subdirectories), and also not creating the directory. So may the position of the command is false or the command does not work well So the problem is not with directory or subdirectories, the problem is with executing file(MAKE_DIRECTORY ..)

Moussawi90 commented 6 years ago

@schwabe and @richardmobile After many tests, here is the final solution: replace add_custom_command(.....) withe the following two lines: file(MAKE_DIRECTORY ovpn3/java/net/openvpn/ovpn3) execute_process(COMMAND swig -outdir ovpn3/java/net/openvpn/ovpn3/ -c++ -java -package net.openvpn.ovpn3 -I${CMAKE_SOURCE_DIR}/openvpn3/client -I${CMAKE_SOURCE_DIR}/openvpn3 ${CMAKE_SOURCE_DIR}/openvpn3/javacli/ovpncli.i)

After many tests it appears that the error is due to add_custom_command that seems it is not working and what cited above is a working solution @schwabe I hope that you apply the above changes to CMakeLists.txt

richardmobile commented 6 years ago

@Moussawi90 thank you so much for your help. the issue was solved.

schwabe commented 6 years ago

@Moussawi90 can you make a pull request for that? Alos in last version I fiddled a bit with the swig comand to output its files in the build folder and not in the openvpn3 folder. You might need to port your solution to that.