Open chenbotao828 opened 6 years ago
How did you install gtm? Did you use one of the prebuilt binaries from here https://github.com/git-time-metric/gtm/releases or are you trying to build the GTM project?
I installed prebuilt binaries gtm from here
That's odd. Not sure why it's trying to load libcurl. I'll have to do some research on that one. We've had problems in the past with Linux builds not statically linking to required libraries. For example on Fedora #58.
The issue is we use the libgit2 library which links to the libcurl library if available but I'm not sure if I can statically link to it or just remove it.
If you want to, lets try installing the libraries it depends on. Try this from the terminal.
sudo apt-get install -y curl libcurl3 libcurl3-gnutls libcurl4-gnutls-dev
. You may only need libcurl3
so I would first only install that one and test.
Your mileage may vary on this one. I have not tested it yet :).
It worked, Thanks!
With this modifications I can build gtm w/o redundant dependencies:
diff --git a/script/build-libgit2-static.sh b/script/build-libgit2-static.sh
index 5723721..83fdbc7 100755
--- a/script/build-libgit2-static.sh
+++ b/script/build-libgit2-static.sh
@@ -10,6 +10,11 @@ mkdir -p build &&
cd build &&
cmake -DTHREADSAFE=ON \
-DBUILD_CLAR=OFF \
+ -DSYSTEM_ZLIB=FALSE \
+ -DCURL=OFF -DCURL_FOUND=FALSE \
+ -DUSE_SSH=OFF -DLIBSSH2_FOUND=FALSE \
+ -DUSE_OPENSSL=OFF -DOPENSSL_FOUND=FALSE \
+ -DSYSTEM_HTTP_PARSER=FALSE \
-DBUILD_SHARED_LIBS=OFF \
-DCMAKE_C_FLAGS=-fPIC \
-DCMAKE_BUILD_TYPE="RelWithDebInfo" \
I added SYSTEM_ZLIB
and SYSTEM_HTTP_PARSER
because FIND_PACKAGE()
enables *_FOUND variables:
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4bfd1b499..50651ea64 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -320,7 +320,9 @@ IF(WIN32 OR AMIGA OR CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
ENDIF()
# Optional external dependency: http-parser
-FIND_PACKAGE(HTTP_Parser)
+IF (SYSTEM_HTTP_PARSER)
+ FIND_PACKAGE(HTTP_Parser)
+ENDIF()
IF (HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2)
INCLUDE_DIRECTORIES(${HTTP_PARSER_INCLUDE_DIRS})
LINK_LIBRARIES(${HTTP_PARSER_LIBRARIES})
@@ -332,7 +334,9 @@ ELSE()
ENDIF()
# Optional external dependency: zlib
-FIND_PACKAGE(ZLIB)
+IF (SYSTEM_ZLIB)
+ FIND_PACKAGE(ZLIB)
+ENDIF()
IF (ZLIB_FOUND)
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS})
LINK_LIBRARIES(${ZLIB_LIBRARIES})
Also you can use
CGO_LDFLAGS="-s" go build --tags static -ldflags "-X main.Version=${TRAVIS_TAG}"
or
go build --tags static -ldflags "-extldflags -s -X main.Version=${TRAVIS_TAG}"
for release phase to minify executable a bit. But I'm not sure about this as have no experience with go
developing/compiling.
So here what i got:
$ ldd gtm
linux-vdso.so.1 (0x00007ffd1f503000)
librt.so.1 => /lib64/librt.so.1 (0x0000003478e00000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003478200000)
libc.so.6 => /lib64/libc.so.6 (0x0000003477e00000)
/lib64/ld-linux-x86-64.so.2 (0x00007fc6ae7aa000)
$ ls -sh gtm*
5.4M gtm 2.1M gtm.local.tar.gz 13M gtm.orig
Thank you for providing this information. I've had several lost days in the past dealing with the c build for libgit2.
Hi, everybody! Everything is fine except an error message shown in terminal when I run
gtm
command. Here is the message:gtm: /usr/lib/libcurl.so.4: no version information available (required by gtm)
os: Linux Mint 18.1 Serena