Понадобилось статически прилинковать к своему приложению curl+libssl.

Собираю openssl-1.1.1b:

./Configure linux-generic64 no-hw no-engine no-threads no-shared --prefix=/home/user/prg/openssl-1.1.1b_custom --openssldir=/home/user/prg/openssl-1.1.1b_custom

Собираю curl-7.64.1

export PKG_CONFIG_PATH=/home/user/prg/openssl-1.1.1b_custom/lib/pkgconfig
./configure --with-ssl=/home/user/prg/openssl-1.1.1b_custom --disable-shared --without-zlib --disable-pthreads --disable-threaded-resolver --disable-unix-sockets --disable-cookie --without-libssl1.0.2 --without-libssl1.0-dev --without-libssl1.1 --disable-ftp --disable-file --disable-ldap --disable-ldaps --disable-rtsp --disable-proxy --disable-dict --disable-telnet --disable-tftp --disable-pop3 --disable-imap --disable-smtp --disable-gopher --disable-sspi --disable-crypto-auth --disable-ntlm-wb --disable-tls-srp --disable-soname-bump --without-libssh2 --disable-curldebug --disable-debug --disable-ipv6 --without-librtmp --disable-ntlm-wb --disable-manual --prefix=/home/user/prg/curl-7.64.1_custom

Пишем тестовое приложение, типа

#include <curl/curl.h>

void test() {

const char* url = "ya.ru";;
CURL* curl;
CURLcode res;

curl = curl_easy_init();
curl_easy_setopt(curl, CURLOPT_URL, url);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);

res = curl_easy_perform(curl);

//Если что-то пошло не так...
if(res != CURLE_OK) {

curl_easy_strerror(res);
} else {

//Все OK
}

curl_easy_cleanup(curl);
}

int main(int argc, char** argv) {

curl_global_init(CURL_GLOBAL_ALL);
test();
}

и собираем строчкой


cc -Wall --static `pkg-config --static --libs --cflags /home/user/prg/curl-7.64.1_custom/lib/pkgconfig/libcurl.pc /home/user/prg/openssl-1.1.1b_custom/lib/pkgconfig/libcrypto.pc /home/user/prg/openssl-1.1.1b_custom/lib/pkgconfig/libssl.pc` curl-test-1.c -o curl-test-1


Результат:

In function `test':
curl-test-1.c.text+0x105): undefined reference to `curl_easy_init'
curl-test-1.c.text+0x12a): undefined reference to `curl_easy_setopt'
curl-test-1.c.text+0x14c): undefined reference to `curl_easy_setopt'
curl-test-1.c.text+0x16e): undefined reference to `curl_easy_setopt'
curl-test-1.c.text+0x192): undefined reference to `curl_easy_setopt'
curl-test-1.c.text+0x19e): undefined reference to `curl_easy_perform'
curl-test-1.c.text+0x1b1): undefined reference to `curl_easy_strerror'
curl-test-1.c.text+0x1bd): undefined reference to `curl_easy_cleanup'
/tmp/ccxVQLrA.o: In function `main':
curl-test-1.c.text+0x1db): undefined reference to `curl_global_init'
collect2: error: ld returned 1 exit status

Голову ломаю и не пойму, ведь все библиотеки нормально собрались. Почему не видит статическую библиотеку?








 , ,






URL записи