ClashForAndroid icon indicating copy to clipboard operation
ClashForAndroid copied to clipboard

[BUG] libclash.h' file not found

Open CMingTseng opened this issue 3 years ago • 19 comments

描述出现的错误 根據Readme 同步最新版本 (c78431a0fbd3658d439c819887427c0fa6dfc7f6)

Windows 下 編譯缺少libclash.h

顯示 core\src\main\cpp\main.c:7:10: fatal error: 'libclash.h' file not found

Error while executing process D:\SDK\cmake\3.10.2.4988404\bin\ninja.exe with arguments {-C D:\WorkSpace\Compose\ClashForAndroid\core.cxx\RelWithDebInfo\5r2i6x1z\armeabi-v7a bridge} ninja: Entering directory `D:\WorkSpace\Compose\ClashForAndroid\core.cxx\RelWithDebInfo\5r2i6x1z\armeabi-v7a' [1/2] Building C object CMakeFiles/bridge.dir/main.c.o FAILED: CMakeFiles/bridge.dir/main.c.o D:\SDK\ndk\23.0.7599858\toolchains\llvm\prebuilt\windows-x86_64\bin\clang.exe --target=armv7-none-linux-androideabi21 --gcc-toolchain=D:/SDK/ndk/23.0.7599858/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=D:/SDK/ndk/23.0.7599858/toolchains/llvm/prebuilt/windows-x86_64/sysroot -Dbridge_EXPORTS -ID:/WorkSpace/Compose/ClashForAndroid/core/build/outputs/golang/premiumRelease/armeabi-v7a -ID:/WorkSpace/Compose/ClashForAndroid/core/src/main/golang/native -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -march=armv7-a -mthumb -Wformat -Werror=format-security -O2 -g -DNDEBUG -fPIC -MD -MT CMakeFiles/bridge.dir/main.c.o -MF CMakeFiles\bridge.dir\main.c.o.d -o CMakeFiles/bridge.dir/main.c.o -c D:/WorkSpace/Compose/ClashForAndroid/core/src/main/cpp/main.c D:/WorkSpace/Compose/ClashForAndroid/core/src/main/cpp/main.c:7:10: fatal error: 'libclash.h' file not found #include "libclash.h" ^~~~~~~~~~~~ 1 error generated. ninja: build stopped: subcommand failed.

CMingTseng avatar Nov 04 '21 08:11 CMingTseng

Macbook下也报同样的问题

M78Code avatar Nov 12 '21 03:11 M78Code

更新一下你的Go版本

ByWaveSite avatar Dec 06 '21 17:12 ByWaveSite

使用最新版本的go?

BiteFoo avatar Dec 07 '21 08:12 BiteFoo

同样的问题,另外 想请教 Android Studio 咋编译GO 的?

wksxlwywlyy avatar Dec 10 '21 11:12 wksxlwywlyy

请问楼上的几位,升级go的版本后你们这个问题解决了吗?

BlainPeng avatar Dec 11 '21 05:12 BlainPeng

@BlainPeng @wksxlwywlyy @BiteFoo @M78Code

我來回答這題好了 !!

  1. 請先安裝 Go (Windows - https://go.dev/dl/go1.17.5.windows-amd64.msi /OSX - https://go.dev/dl/go1.17.5.darwin-amd64.pkg)

  2. 設定好 Go的path

  3. git clone [email protected]:Kr328/ClashForAndroid.git

  4. cd ClashForAndroid

  5. git submodule update --init --recursive ( 或 git submodule init & git submodule sync & git submodule update)

(注意 這邊有 submodule)

  1. 這樣就可以編譯專案了

  2. 如果 往後要節省編譯時間

可以參考我的 https://github.com/CMingTseng/ClashForAndroid/tree/as_library 加上 產生aar的部分

往後其他專案可以用

app & design 是 UI部分 可以自己改一個 !!

CMingTseng avatar Dec 11 '21 17:12 CMingTseng

git clone [email protected]:Kr328/ClashForAndroid.git Cloning into 'ClashForAndroid'... [email protected]: Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

EazyConqueror avatar Dec 13 '21 10:12 EazyConqueror

git clone [email protected]:Kr328/ClashForAndroid.git Cloning into 'ClashForAndroid'... [email protected]: Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

first fork, then clone from your own repo git clone https://github.com/Garlic6694/ClashForAndroid.git

Garlic6694 avatar Mar 03 '22 13:03 Garlic6694

@CMingTseng 你好,看了你的方案还是没有解决。。。可以回复邮件帮助下吗?

gmingrui avatar Mar 26 '22 13:03 gmingrui

在@CMingTseng 的帮助下已解决。大陆用户主要考虑vpn或网络原因导致无法获取库。

gmingrui avatar Mar 28 '22 15:03 gmingrui

在@CMingTseng 的帮助下已解决。大陆用户主要考虑vpn或网络原因导致无法获取库。

我用Android Studio编译的,我也挂了vpn,也拉了代码,拉代码时没有报错。Go也更新了(不知道Go在Android Studio里面是怎么用的),还是不行啊。不知道你说的无法获取的是哪个库,编译后还是报少了libclash.h这个文件,我不知道这个文件是在哪个库里面的。有没有编译后的源码发一份给我,感谢!@gmingrui image

huijiawanquba avatar Mar 29 '22 10:03 huijiawanquba

在@CMingTseng 的帮助下已解决。大陆用户主要考虑vpn或网络原因导致无法获取库。

我用Android Studio编译的,我也挂了vpn,也拉了代码,拉代码时没有报错。Go也更新了(不知道Go在Android Studio里面是怎么用的),还是不行啊。不知道你说的无法获取的是哪个库,编译后还是报少了libclash.h这个文件,我不知道这个文件是在哪个库里面的。有没有编译后的源码发一份给我,感谢!@gmingrui image 我推了 一個有go的

你們自己試試看

https://github.com/CMingTseng/ClashForAndroid/tree/1cc88cc_add_go_need/go/pkg/mod

前天幫忙測試

你們有的就算 "翻牆"

但是VPN可能是半殘

所以Go編譯的相關library拉取不到

我這邊提供我的cahce部分

你們自己放到對應位置(要參考go的設定)

CMingTseng avatar Mar 29 '22 17:03 CMingTseng

你好,我拷贝了你发的go编译的文件到C:\Users\Administrator\go\pkg\mod,结果Android Studio每次编译都会重新下载,并没有使用我配置的文件,我不知道从哪配置Android Studio编译go的路径。

huijiawanquba avatar Mar 30 '22 08:03 huijiawanquba

@BlainPeng @wksxlwywlyy @BiteFoo @M78Code

我來回答這題好了 !!

  1. 請先安裝 Go (Windows - https://go.dev/dl/go1.17.5.windows-amd64.msi /OSX - https://go.dev/dl/go1.17.5.darwin-amd64.pkg)
  2. 設定好 Go的path
  3. git clone [email protected]:Kr328/ClashForAndroid.git
  4. cd ClashForAndroid
  5. git submodule update --init --recursive ( 或 git submodule init & git submodule sync & git submodule update)

(注意 這邊有 submodule)

  1. 這樣就可以編譯專案了
  2. 如果 往後要節省編譯時間

可以參考我的 https://github.com/CMingTseng/ClashForAndroid/tree/as_library 加上 產生aar的部分

往後其他專案可以用

app & design 是 UI部分 可以自己改一個 !!

你好,你的项目我能跑起来,为什么首页的点击事件都无效呢?需要设置什么吗?

int-long avatar Apr 01 '22 08:04 int-long

我直接clone 历经千辛万苦 终于 build success

tangjiaqq avatar May 29 '22 05:05 tangjiaqq

不需要搞vpn 直接给go上代理

$ go env -w GO111MODULE=on
$ go env -w GOPROXY=https://goproxy.cn,direct

参考:https://goproxy.cn/

DzwsGo avatar Jun 01 '22 07:06 DzwsGo

@BlainPeng @wksxlwywlyy @BiteFoo @M78Code

我來回答這題好了 !!

  1. 請先安裝 Go (Windows - https://go.dev/dl/go1.17.5.windows-amd64.msi /OSX - https://go.dev/dl/go1.17.5.darwin-amd64.pkg)
  2. 設定好 Go的path
  3. git clone [email protected]:Kr328/ClashForAndroid.git
  4. cd ClashForAndroid
  5. git submodule update --init --recursive ( 或 git submodule init & git submodule sync & git submodule update)

(注意 這邊有 submodule)

  1. 這樣就可以編譯專案了
  2. 如果 往後要節省編譯時間

可以參考我的 https://github.com/CMingTseng/ClashForAndroid/tree/as_library 加上 產生aar的部分

往後其他專案可以用

app & design 是 UI部分 可以自己改一個 !!

请问如何在android studios上虚拟机测试,目前可以通过命令构建,但是无法在android stuidio上虚拟机测试和构建

zhugelail1998 avatar Jun 17 '22 09:06 zhugelail1998

缺少libclash.h'文件的终极答案 按照 @CMingTseng 的步奏安装到 5.git submodule update --init --recursive ( 或 git submodule init & git submodule sync & git submodule update) (注意 這邊有 submodule)

libclash.h文件就是通过git submodule update --init --recursive 这条命令下载下来的,你必须要在项目根目录执行此条命令,没有执行永远会提示缺少libclash.h'文件。

所以要给git上个代理,在下载,没代理下载失败。

我是win系统上android studio 来开发的。

运行项目 可以成功编译并安装。

New-Zero-Zero avatar Aug 03 '22 04:08 New-Zero-Zero

git config --global http.sslVerify "false" 关闭SSL验证

ribychen avatar Sep 14 '22 07:09 ribychen