go-tdlib icon indicating copy to clipboard operation
go-tdlib copied to clipboard

Build problems on Windows

Open tomas-lejdung opened this issue 4 years ago • 6 comments

I am running GO version 1.15.7 and first of all the install instructions does not work that is stated in the readme file. There is no makefile for the "make install" to execute, at least not for me. So I followed the installation guide at https://tdlib.github.io/td/build.html?language=Go

I've managed to build everything but I have no idea where to place the TD folder so my program can link to it. When running "go build" or "go run main.go" I get

# github.com/Arman92/go-tdlib
vendor\github.com\Arman92\go-tdlib\tdlib.go:10:10: fatal error: td/telegram/td_json_client.h: No such file or directory
 //#include <td/telegram/td_json_client.h>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

So the problem seems to be that GO does not find the C files, and hopefully this can be easily fixed by moving the "td" folder to the correct place.

Thanks in advance.

tomas-lejdung avatar Feb 07 '21 14:02 tomas-lejdung

In my case i found in the sources that actually it try to find the relative path "td/telegram/td_json_client.h" at "C:\src\td".

Drathveloper avatar Feb 17 '21 18:02 Drathveloper

Thank you @Drathveloper , it seems like it did something. Though I'm now getting another error

# github.com/Arman92/go-tdlib
C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -ltdjson
collect2.exe: error: ld returned 1 exit status

Did you mean that you should place the root td folder that is generated from following the instructions on how to install TDLib. td

The tdjson file that it says that it can't find is located at C:\src\td\tdlib\lib

tomas-lejdung avatar Feb 17 '21 20:02 tomas-lejdung

can you post the output of: gcc -print-search-dirs?

er-azh avatar Apr 15 '21 21:04 er-azh

@fukpy i got the same error as @tomas-lejdung here is my gcc -print-search-dirs output

`C:\Users\250799>gcc -print-search-dirs

install: C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/ programs: =C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../libexec/gcc/;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/x86_64-w64-mingw32/8.1.0/;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ libraries: =C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/x86_64-w64-mingw32/8.1.0/;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../x86_64-w64-mingw32/8.1.0/;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../lib/;C:/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/mingw/lib/x86_64-w64-mingw32/8.1.0/;C:/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/mingw/lib/../lib/;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../;C:/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/mingw/lib/`

Touexe avatar May 06 '21 02:05 Touexe

Add These in Windows environments variable :

CGO_LDFLAGS=-LC:\dev\tdlib\bin -ltdjson CGO_CFLAGS=-IC:\dev\tdlib\include

C:\dev = Place that build tdlib in my pc

yaasinhamidi avatar Jul 22 '21 13:07 yaasinhamidi

在 Windows 环境变量中添加这些:

CGO_LDFLAGS=-LC:\dev\tdlib\bin -ltdjson CGO_CFLAGS=-IC:\dev\tdlib\include

C:\dev = 在我的电脑中构建 tdlib

谢谢,非常有用, 头文件是找到了,但是链接库报错: D:/Dev/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible D:/Workspace/GoLang/td/tdlib/bin/tdjson.dll when searching for -ltdjson D:/Dev/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible D:/Workspace/GoLang/td/tdlib/bin/tdjson.dll when searching for -ltdjson D:/Dev/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -ltdjson collect2.exe: error: ld returned 1 exit status

BigCatGit avatar May 23 '22 17:05 BigCatGit