marcboeker / go-duckdb

go-duckdb provides a database/sql driver for the DuckDB database engine.
MIT License
623 stars 97 forks source link

Compilation error #175

Closed vvv9912 closed 6 months ago

vvv9912 commented 6 months ago

I have the "go1.21.5 windows/amd64" version of duckdb installed: github.com/marcboeker/go-duckdb@windows ( v1.5.6-0.202312231650447c5d8e055ee8)

gcc --version gcc (Rev5, Built by MSYS2 project) 13.2.0

# initDbGo
C:\Program Files\Go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/vvv/go/pkg/mod/github.com/marcboeker/go-duckdb@v1.5.6-0.20231223165044-7c5d8e055ee8/deps/windows_amd64/libduckdb.a(ub_duckdb_main_extension.cpp.obj):ub_duckdb_main_extension.cpp:(.text$_ZN14duckdb_httplib6Server19handle_file_requestERKNS_7RequestERNS_8ResponseEb[_ZN14duckdb_httplib6Server19handle_file_requestERKNS_7RequestERNS_8ResponseEb]+0x49e): undefined reference to `std::istream::seekg(std::fpos<_Mbstatet>)'
C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/13.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/vvv/go/pkg/mod/github.com/marcboeker/go-duckdb@v1.5.6-0.20231223165044-7c5d8e055ee8/deps/windows_amd64/libduckdb.a(ub_duckdb_main_extension.cpp.obj):ub_duckdb_main_extension.cpp:(.rdata$_ZTVN14duckdb_httplib8DataSink19data_sink_streambufE[_ZTVN14duckdb_httplib8DataSink19data_sink_streambufE]+0x38): undefined reference to `std::basic_streambuf<char, std::char_traits<char> >::seekpos(std::fpos<_Mbstatet>, std::_Ios_Openmode)'
collect2.exe: error: ld returned 1 exit status
marcboeker commented 6 months ago

We have huge problems with Windows right now, so I can't give any support on that. What you could try to do is download the latest DuckDB Windows release from Github that contains the .dll file and try linking to that. Windows support is something that is on the list but has not ETA.

hongnod commented 2 months ago

There is a solution:

  1. pacman -Syu update all packages.
  2. pacman -S ucrt64/mingw-w64-ucrt-x86_64-duckdb, verify there "libduckdb.dll" under ucrt64/bin and "libduckdb.dll.a" etc. under ucrt64/lib
  3. run go env -w CGO_LDFLAGS="-Lmsys2root\ucrt64\lib"
  4. go build -tags=duckdb_use_lib youmain.go
  5. copy "libduckdb.dll" to your app folder
  6. run your app
marcboeker commented 2 months ago

@hongnod Thanks for figuring this out. Could you please add this to https://github.com/marcboeker/go-duckdb/blob/main/.github/workflows/test.yaml and see if you can get it working? Once it compiles and the tests are green I'll add it to the README.md.

hongnod commented 2 months ago

Sorry for I don't know to do it. I am not really a programming engineer. I hope someone can help.