mutecomm / go-sqlcipher

Self-contained Go sqlite3 driver with an AES-256 encrypted sqlite3 database
Other
159 stars 60 forks source link

multiple definition error #12

Closed shishuwu closed 4 years ago

shishuwu commented 4 years ago

I'm leveraging golang-migrate to do database schema init & update. Aligned with go-sqlcipher, it always pops up the following error:

# command-line-arguments c:\go\pkg\tool\windows_amd64\link.exe: running gcc failed: exit status 1 C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\ADMINI~1\AppData\Local\Temp\go-link-302618435\000053.o: in functionsqlite3_status64': C:\Users\Administrator\go\pkg\mod\github.com\mattn\go-sqlite3@v1.10.0/sqlite3-binding.c:20370: multiple definition of sqlite3_status64'; C:\Users\ADMINI~1\AppData\Local\Temp\go-link-302618435\000033.o:C:\Users\Administrator\go\pkg\mod\github.com\mutecomm\go-sqlcipher\v4@v4.4.0/sqlite3.c:26352: first defined here C:/TDM-GCC-64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:\Users\ADMINI~1\AppData\Local\Temp\go-link-302618435\000053.o: in functionsqlite3_status': C:\Users\Administrator\go\pkg\mod\github.com\mattn\go-sqlite3@v1.10.0/sqlite3-binding.c:20390: multiple definition of sqlite3_status'; C:\Users\ADMINI~1\AppData\Local\Temp\go-link-302618435\000033.o:C:\Users\Administrator\go\pkg\mod\github.com\mutecomm\go-sqlcipher\v4@v4.4.0/sqlite3.c:26372: first defined here C...

frankbraun commented 4 years ago

golang-migrate depends on github.com/mattn/go-sqlite3. Both github.com/mattn/go-sqlite3 and go-sqlcipher have an embedded sqlite3 database. When the linker wants to build your binary you get the error above.

I know that you can somehow get go-sqlite3 to use an external sqlite3 library instead of the included one, but I don't know if you can get it to use the one included in go-sqlcipher.

A hackish way to fix your problem would be to fork golang-migrate and replace go-sqlite3 with go-sqlcipher. Make sure you use the latest head of go-sqlcipher to have full go-sqlite3 compatibility.

frankbraun commented 4 years ago

Since there doesn't seem to be anything that can be done from the go-sqlcipher side I'm closing the issue.