Re: Статическая сборка nginx с GD

Anton Kiryushkin swood на fotofor.biz
Вс Апр 7 19:16:47 UTC 2019


Я взял код из лога и попробовал его собрать ровно так, как написано.
Строка моего configure следующая:
./configure --prefix=/usr --conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-client-body-temp-path=/var/lib/nginx/body
--http-fastcgi-temp-path=/var/lib/nginx/fastcgi
--http-log-path=/var/log/nginx/access.log
--http-proxy-temp-path=/var/lib/nginx/proxy
--http-scgi-temp-path=/var/lib/nginx/scgi
--http-uwsgi-temp-path=/var/lib/nginx/uwsgi
--lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug
--with-http_addition_module --with-http_dav_module --with-http_geoip_module
--with-http_gzip_static_module  --with-http_realip_module
--with-http_stub_status_module --with-http_ssl_module
--with-http_sub_module --with-sha1=/usr/include/openssl
--with-md5=/usr/include/openssl --add-module=/usr/src/naxsi/naxsi_src
--with-debug --with-http_v2_module --with-cc-opt="-static -static-libgcc"
--with-ld-opt="-static -lm" --with-cpu-opt=generic
--with-openssl=./openssl-1.0.2r --with-stream --with-stream_ssl_module
--user=www-data --with-http_image_filter_module

Что-то тут уже устаревшее, но это не очень важно.
Выпадает ошибка:
checking for GD library ... not found
checking for GD library in /usr/local/ ... not found
checking for GD library in /usr/pkg/ ... not found
checking for GD library in /opt/local/ ... not found

Окей. Берем код автотеста:

#include <sys/types.h>
#include <unistd.h>
#include <gd.h>

int main(void) {
    gdImagePtr img = gdImageCreateFromGifPtr(1, NULL);
                      (void) img;
    return 0;
}

Собираем:
cc -static -static-libgcc -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -I
/usr/pkg/include -o objs/autotest objs/autotest.c -static -lm
-L/usr/pkg/lib -lgd (строчка из того же лога).
Не собирается.
Однако, если подвинуть -lm в конец:
cc -static -static-libgcc -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -I
/usr/pkg/include -o objs/autotest objs/autotest.c -static -L/usr/pkg/lib
-lgd -lm

Все соберется.

Вопрос, как передвинуть на уровне сборки?


вс, 7 апр. 2019 г. в 12:34, Anton Kiryushkin <swood at fotofor.biz>:

> Да, конечно, есть:
>
> # find /usr -type f -name 'libm.a'
> /usr/lib/x86_64-linux-gnu/libm.a
>
> Да, я попробовал поставить -lm перед -static, это мне тоже не помогло.
> К слову, libgd тоже там есть:
> # find /usr -type f -name 'libgd.a'
> /usr/lib/x86_64-linux-gnu/libgd.a
>
> Подскажите, пожалуйста, где эти тесты лежат в исходнике, поправлю
> локально, как обычно это делаю с php.
>
> сб, 6 апр. 2019 г. в 19:22, Igor Sysoev <igor at sysoev.ru>:
>
>> А статическая libm.a есть?
>> Можно попробовать поставить -lm до -static:
>>
>> --with-ld-opt="-lm -static ...
>>
>> --
>> Igor Sysoev
>> http://nginx.com
>>
>> > On 6 Apr 2019, at 14:57, Anton Kiryushkin <swood at fotofor.biz> wrote:
>> >
>> > Ситуация очень напоминает предыдущую:
>> >
>> > cc -static -static-libgcc -lm -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -I
>> /usr/pkg/include -o objs/autotest objs/autotest.c -static -lm
>> -L/usr/pkg/lib -lgd
>> > ----------
>> >
>> > ----------------------------------------
>> > checking for GD library in /opt/local/
>> >
>> > /opt/local/lib/libgd.a(gd.o): In function `lsqrt':
>> > /usr/src/libgd/src/gd.c:1722: undefined reference to `sqrt'
>> > /opt/local/lib/libgd.a(gd.o): In function `gdImageDashedLine':
>> > /usr/src/libgd/src/gd.c:1471: undefined reference to `atan2'
>> > /usr/src/libgd/src/gd.c:1471: undefined reference to `sin'
>> > /usr/src/libgd/src/gd.c:1520: undefined reference to `atan2'
>> > /usr/src/libgd/src/gd.c:1520: undefined reference to `sin'
>> > /opt/local/lib/libgd.a(gd.o): In function `gdImageAALine':
>> > /usr/src/libgd/src/gd.c:3514: undefined reference to `atan2'
>> > /usr/src/libgd/src/gd.c:3514: undefined reference to `cos'
>> > /opt/local/lib/libgd.a(gd.o): In function `gdImageLine':
>> > /usr/src/libgd/src/gd.c:1394: undefined reference to `atan2'
>> > /usr/src/libgd/src/gd.c:1394: undefined reference to `sin'
>> > /usr/src/libgd/src/gd.c:1333: undefined reference to `atan2'
>> > /usr/src/libgd/src/gd.c:1333: undefined reference to `cos'
>> > /opt/local/lib/libgd.a(gd.o): In function `gdImageAALine':
>> > /usr/src/libgd/src/gd.c:3514: undefined reference to `atan2'
>> > /usr/src/libgd/src/gd.c:3514: undefined reference to `sin'
>> > /opt/local/lib/libgd.a(gd.o): In function `gdImageCopyRotated':
>> > /usr/src/libgd/src/gd.c:2792: undefined reference to `sincos'
>> > /usr/src/libgd/src/gd.c:2791: undefined reference to `sqrt'
>> > collect2: error: ld returned 1 exit status
>> > ----------
>> >
>> > Версия nginx 1.15.10. gcc version 4.8.2.
>> >
>> > сб, 6 апр. 2019 г. в 12:14, Igor Sysoev <igor at sysoev.ru>:
>> > А что в autoconf.err ?
>> >
>> > --
>> > Igor Sysoev
>> > http://nginx.com
>> >
>> > > On 6 Apr 2019, at 14:07, Anton Kiryushkin <swood at fotofor.biz> wrote:
>> > >
>> > > Добавил и не помогло.
>> > >
>> > > сб, 6 апр. 2019 г. в 11:06, Igor Sysoev <igor at sysoev.ru>:
>> > > > On 6 Apr 2019, at 12:54, Anton Kiryushkin <swood at fotofor.biz>
>> wrote:
>> > > >
>> > > > Здравствуйте.
>> > > >
>> > > > Подскажите, пожалуйста, почему nginx в данном случае никак не может
>> собраться статически с libgd:
>> > > >
>> > > > ----------
>> > > > cc -static -static-libgcc -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -I
>> /usr/pkg/include -o objs/autotest objs/autotest.c -static -L/usr/pkg/lib
>> -lgd
>> > > > ----------
>> > > >
>> > > > ----------------------------------------
>> > > > checking for GD library in /opt/local/
>> > > >
>> > > > /opt/local/lib/libgd.a(gd.o): In function `lsqrt':
>> > > > /usr/src/libgd/src/gd.c:1722: undefined reference to `sqrt'
>> > > > /opt/local/lib/libgd.a(gd.o): In function `gdImageDashedLine':
>> > > > /usr/src/libgd/src/gd.c:1471: undefined reference to `atan2'
>> > > > /usr/src/libgd/src/gd.c:1471: undefined reference to `sin'
>> > > > /usr/src/libgd/src/gd.c:1520: undefined reference to `atan2'
>> > > > /usr/src/libgd/src/gd.c:1520: undefined reference to `sin'
>> > > > /opt/local/lib/libgd.a(gd.o): In function `gdImageAALine':
>> > > > /usr/src/libgd/src/gd.c:3514: undefined reference to `atan2'
>> > > > /usr/src/libgd/src/gd.c:3514: undefined reference to `cos'
>> > > > /opt/local/lib/libgd.a(gd.o): In function `gdImageLine':
>> > > > /usr/src/libgd/src/gd.c:1394: undefined reference to `atan2'
>> > > > /usr/src/libgd/src/gd.c:1394: undefined reference to `sin'
>> > > > /usr/src/libgd/src/gd.c:1333: undefined reference to `atan2'
>> > > > /usr/src/libgd/src/gd.c:1333: undefined reference to `cos'
>> > > > /opt/local/lib/libgd.a(gd.o): In function `gdImageAALine':
>> > > > /usr/src/libgd/src/gd.c:3514: undefined reference to `atan2'
>> > > > /usr/src/libgd/src/gd.c:3514: undefined reference to `sin'
>> > > > /opt/local/lib/libgd.a(gd.o): In function `gdImageCopyRotated':
>> > > > /usr/src/libgd/src/gd.c:2792: undefined reference to `sincos'
>> > > > /usr/src/libgd/src/gd.c:2791: undefined reference to `sqrt'
>> > > > collect2: error: ld returned 1 exit status
>> > > > ----------
>> > > >
>> > > > Сам libgd собран в  /opt/local с флагом static. К сожалению, мне
>> действительно нужна статическая сборка. Остается страдать и все же так не
>> делать или есть способ что-то тут сделать?
>> > >
>> > > Нужно добавить "-lm" в --with-ld-opt
>> > >
>> > >
>> > > --
>> > > Igor Sysoev
>> > > http://nginx.com
>> > > _______________________________________________
>> > > nginx-ru mailing list
>> > > nginx-ru at nginx.org
>> > > http://mailman.nginx.org/mailman/listinfo/nginx-ru
>> > >
>> > >
>> > > --
>> > > Best regards,
>> > > Anton Kiryushkin
>> > >
>> > > _______________________________________________
>> > > nginx-ru mailing list
>> > > nginx-ru at nginx.org
>> > > http://mailman.nginx.org/mailman/listinfo/nginx-ru
>> >
>> > _______________________________________________
>> > nginx-ru mailing list
>> > nginx-ru at nginx.org
>> > http://mailman.nginx.org/mailman/listinfo/nginx-ru
>> >
>> >
>> > --
>> > Best regards,
>> > Anton Kiryushkin
>> >
>> > _______________________________________________
>> > nginx-ru mailing list
>> > nginx-ru at nginx.org
>> > http://mailman.nginx.org/mailman/listinfo/nginx-ru
>>
>> _______________________________________________
>> nginx-ru mailing list
>> nginx-ru at nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx-ru
>
>
>
> --
> Best regards,
> Anton Kiryushkin
>
>

-- 
Best regards,
Anton Kiryushkin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-ru/attachments/20190407/9a6dddbe/attachment-0001.html>


Подробная информация о списке рассылки nginx-ru