LINUX.ORG.RU

не вызывается функция из GD-lib


0

0

вот прога top.cgi.c:

#include <stdio.h>
#include "gd.h"
#include "cgi-lib.h"
#include "html-lib.h"

int main(){
  llist entries;
  gdImagePtr im;
  FILE *pngout, *jpegout;
  int black;
  int white;
  im = gdImageCreate(88, 31);
  black = gdImageColorAllocate(im, 0, 0, 0);
  white = gdImageColorAllocate(im, 255, 255, 255);
  pngout = fopen("test.png", "wb");
  gdImagePng(im, pngout);
  fclose(pngout);
  gdImageDestroy(im);
  printf("content-type: text/html \n\n");
  if (read_cgi_input(&entries)) {
    print_entries(entries);
    print_cgi_env();
  }
  list_clear(&entries);
  return 0;
}

делаю make

[root@server cgihtml-1.6]# make
gcc -O2 top.cgi.o cgihtml.a -o top.cgi
top.cgi.o: In function `main':
/var/www/cgi-bin/cgihtml-1.6/top.cgi.c:12: undefined reference to `gdImageCreate'
/var/www/cgi-bin/cgihtml-1.6/top.cgi.c:13: undefined reference to `gdImageColorAllocate'
/var/www/cgi-bin/cgihtml-1.6/top.cgi.c:14: undefined reference to `gdImageColorAllocate'
/var/www/cgi-bin/cgihtml-1.6/top.cgi.c:16: undefined reference to `gdImagePng'
/var/www/cgi-bin/cgihtml-1.6/top.cgi.c:18: undefined reference to `gdImageDestroy'
collect2: ld returned 1 exit status
make: *** [top.cgi] Ошибка 1
[root@server cgihtml-1.6]#

че это такое за "undefined reference to четотам" и как его лечить?

☆☆

Ответ на: комментарий от bigbit

все тож самое :(

[root@server cgihtml-1.6]# make
gcc -O2 -g -Wall -DUNIX -lgd    -c -o cgi-lib.o cgi-lib.c
cgi-lib.c: In function `getline':
cgi-lib.c:180: warning: `c' might be used uninitialized in this function
cgi-lib.c: In function `parse_form_encoded':
cgi-lib.c:203: warning: `uploadfile' might be used uninitialized in this function
cgi-lib.c:209: warning: `prevbytesread' might be used uninitialized in this function
gcc: -lgd: linker input file unused since linking not done
gcc -O2 -g -Wall -DUNIX -lgd    -c -o cgi-llist.o cgi-llist.c
gcc: -lgd: linker input file unused since linking not done
gcc -O2 -g -Wall -DUNIX -lgd    -c -o html-lib.o html-lib.c
gcc: -lgd: linker input file unused since linking not done
gcc -O2 -g -Wall -DUNIX -lgd    -c -o string-lib.o string-lib.c
gcc: -lgd: linker input file unused since linking not done
ar cr cgihtml.a cgi-lib.o cgi-llist.o html-lib.o string-lib.o
ranlib cgihtml.a
gcc -O2 -g -Wall -DUNIX -lgd    -c -o query-results.o query-results.c
gcc: -lgd: linker input file unused since linking not done
gcc -O2 query-results.o cgihtml.a -o query-results
gcc -O2 -g -Wall -DUNIX -lgd    -c -o mail.cgi.o mail.cgi.c
gcc: -lgd: linker input file unused since linking not done
gcc -O2 mail.cgi.o cgihtml.a -o mail.cgi
gcc -O2 -g -Wall -DUNIX -lgd    -c -o index-sample.cgi.o index-sample.cgi.c
gcc: -lgd: linker input file unused since linking not done
gcc -O2 index-sample.cgi.o cgihtml.a -o index-sample.cgi
gcc -O2 -g -Wall -DUNIX -lgd    -c -o ignore.cgi.o ignore.cgi.c
ignore.cgi.c: In function `main':
ignore.cgi.c:16: warning: implicit declaration of function `exit'
gcc: -lgd: linker input file unused since linking not done
gcc -O2 ignore.cgi.o cgihtml.a -o ignore.cgi
gcc -O2 -g -Wall -DUNIX -lgd    -c -o test.cgi.o test.cgi.c
gcc: -lgd: linker input file unused since linking not done
gcc -O2 test.cgi.o cgihtml.a -o test.cgi
gcc -O2 -g -Wall -DUNIX -lgd    -c -o top.cgi.o top.cgi.c
top.cgi.c: In function `main':
top.cgi.c:9: warning: unused variable `jpegout'
gcc: -lgd: linker input file unused since linking not done
gcc -O2 top.cgi.o cgihtml.a -o top.cgi
top.cgi.o: In function `main':
/var/www/cgi-bin/cgihtml-1.6/top.cgi.c:12: undefined reference to `gdImageCreate'
/var/www/cgi-bin/cgihtml-1.6/top.cgi.c:13: undefined reference to `gdImageColorAllocate'
/var/www/cgi-bin/cgihtml-1.6/top.cgi.c:14: undefined reference to `gdImageColorAllocate'
/var/www/cgi-bin/cgihtml-1.6/top.cgi.c:16: undefined reference to `gdImagePng'
/var/www/cgi-bin/cgihtml-1.6/top.cgi.c:18: undefined reference to `gdImageDestroy'
collect2: ld returned 1 exit status
make: *** [top.cgi] Ошибка 1
[root@server cgihtml-1.6]#

vilfred ☆☆
() автор топика
Ответ на: комментарий от vilfred

вот мейкфайл:

# Makefile for cgihtml.a
# $Id: Makefile,v 1.6 1996/08/11 04:23:23 eekim Exp $

CC= gcc -O2
RANLIB = ranlib
CFLAGS= -g -Wall -DUNIX -lgd #-DUPLOADDIR=/tmp
CGI-BIN= /home/eekim/Web/cgi-bin

all: cgihtml.a query-results mail.cgi index-sample.cgi ignore.cgi test.cgi top.cgi

cgihtml.a: cgi-lib.o cgi-llist.o html-lib.o string-lib.o
        ar cr cgihtml.a cgi-lib.o cgi-llist.o html-lib.o string-lib.o
        $(RANLIB) cgihtml.a

top.cgi: top.cgi.o cgihtml.a
        $(CC) top.cgi.o cgihtml.a -o top.cgi

query-results: query-results.o cgihtml.a
        $(CC) query-results.o cgihtml.a -o query-results

mail.cgi: mail.cgi.o cgihtml.a
        $(CC) mail.cgi.o cgihtml.a -o mail.cgi

index-sample.cgi: index-sample.cgi.o cgihtml.a
        $(CC) index-sample.cgi.o cgihtml.a -o index-sample.cgi

ignore.cgi: ignore.cgi.o cgihtml.a
        $(CC) ignore.cgi.o cgihtml.a -o ignore.cgi

test.cgi: test.cgi.o cgihtml.a
        $(CC) test.cgi.o cgihtml.a -o test.cgi

install: all
        chmod a+x query-results mail.cgi index-sample.cgi ignore.cgi test.cgi top.cgi
        strip query-results mail.cgi index-sample.cgi ignore.cgi test.cgi top.cgi
        mv -f query-results mail.cgi index-sample.cgi ignore.cgi test.cgi top.cgi $(CGI-BIN)

clean:
        rm -f *.o cgihtml.a
        rm -f query-results mail.cgi index-sample.cgi ignore.cgi test.cgi top.cgi

vilfred ☆☆
() автор топика
Ответ на: комментарий от vilfred

странно, а вот так сработало

gcc -lgd -o top.cgi top.cgi.c выдало test.png с закоментированным всем, что относится к cgihtml.. бредятина вобщем какая-то

vilfred ☆☆
() автор топика
Ответ на: комментарий от vilfred

кто бы мог подумать что в Makefile вместо:

top.cgi: top.cgi.o cgihtml.a
        $(CC) top.cgi.o cgihtml.a -o top.cgi

надо писать:

top.cgi: top.cgi.o cgihtml.a
        $(CC) -lm -lgd top.cgi.o cgihtml.a -o top.cgi

p.s. походу надо ботать про линкеры...

vilfred ☆☆
() автор топика
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.