{"thread":{"id":"47916","subject":"Git 2.16.2: Build failure linking static libcurl / static SSL","startedAt":"2018-02-24T00:46:07Z","lastAt":"2018-02-24T00:46:07Z","messageCount":1,"participants":["Paul Smith"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"340114","messageId":"1519431904.3405.933.camel@mad-scientist.net","threadId":"47916","inReplyTo":null,"subject":"Git 2.16.2: Build failure linking static libcurl / static SSL","fromName":"Paul Smith","fromEmail":"paul@mad-scientist.net","sentAt":"2018-02-24T00:25:04Z","receivedAt":"2018-02-24T00:46:07Z","isPatch":false,"sender":{"key":"paul@mad-scientist.net","avatar":"https://avatars.githubusercontent.com/u/109636?v=4"},"body":"I'm compiling Git with my own static libcurl and my own static\nLibreSSL.  They live in two different locations.\n\nBuilding Curl with a pointer to my LibreSSL works fine, and compiling\nGit works fine: the correct -I options are added to the compile line\nwhen I configure with --with-openssl=/path/to/libressl/dist\n\nHowever, linking fails to find the crypto and ssl libraries, because\nthe OPENSSLDIR lib directory is not added to the link line with -L. \nThe link line in question is from Makefile:\n\n  git-http-fetch$X: http.o http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS)\n        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n                $(CURL_LIBCURL) $(LIBS)\n  git-http-push$X: http.o http-push.o GIT-LDFLAGS $(GITLIBS)\n        $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \\\n                $(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)\n\nThe OpenSSL libraries are included in CURL_LIBCURL, but the -L flags\nare not:\n\n        ifdef NEEDS_SSL_WITH_CURL\n                CURL_LIBCURL += -lssl\n                ifdef NEEDS_CRYPTO_WITH_SSL\n                        CURL_LIBCURL += -lcrypto\n                endif\n        endif\n\nThis section needs to add in the OPENSSL_LINK variable, or maybe it has\nto go directly in the git-http-fetch/push recipe, I'm not sure which is\nappropriate.  There seems to be a lot of different variables that have\nsimilar content, that maybe should be aligned (OPENSSL_LIBSSL,\nOPENSSL_LINK, LIB_4_CRYPTO, CURL_LIBCURL, etc.)\n\nBut, the -L is definitely missing:\n\n  gcc -g -O2 -I. -DGIT_HOST_CPU=\"\\\"x86_64\\\"\" -DHAVE_ALLOCA_H -I/work/src/git/Linux-Release-make/dist/include -I/work/src/libressl/Linux-Release-make/dist/include -DNO_GETTEXT -DSHA1_DC -DSHA1DC_NO_STANDARD_INCLUDES -DSHA1DC_INIT_SAFE_HASH_DEFAULT=0 -DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"\\\"cache.h\\\"\" -DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"\\\"git-compat-util.h\\\"\" -pthread -DHAVE_PATHS_H -DHAVE_STRINGS_H -DHAVE_DEV_TTY -DHAVE_CLOCK_GETTIME -DHAVE_CLOCK_MONOTONIC -DHAVE_GETDELIM  -DFREAD_READS_DIRECTORIES -DNO_STRLCPY -DSHELL_PATH='\"/bin/sh\"' -DPAGER_ENV='\"LESS=FRX LV=-c\"' -o git-http-fetch   http.o http-walker.o http-fetch.o common-main.o \\\n        -L/work/src/git/Linux-Release-make/dist/lib -L/work/src/git/Linux-Release-make/dist/lib -lcurl -lssl -lcrypto -lidn libgit.a xdiff/lib.a  -lz -pthread -lrt\n  ld: error: cannot find -lssl\n  ld: error: cannot find -lcrypto\n\nNote how the -I.../libressl/.../include option is present, but the\n-L.../libressl/.../lib option is missing.\n"}]}