Chce sobie skompilowac prosty program/skrypt cgi ktory pobiera dane za pomoca post lub get. Mam w sumie 2 pliki zrodlowe i 1 naglowkowy. Niestety przy linkowaniu jest blad:
index.o(.text+0x1e): In function main': : undefined reference to
postAll(int)'
collect2: ld returned 1 exit status
Tak wygladaje te pliki:
"getPost.h"
typedef struct Pair
{
char *name;
char *value;
} Pair;
Pair *getAll(int numberOfElements);
Pair *postAll(int numberOfElements);
"3.cpp" //troche taka glupia nazwa
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#include "getPost.h"
Pair *getAll(int &numberOfElements)
{
...
}
Pair *postAll(int &numberOfElements)
{
....
}
"index.cpp"
#include "stdio.h"
#include "getPost.h"
int main(int argc, char *argv)
{
int j = 0;
Pair *pairs = postAll(j);
printf("Content-type: text/html\n\n");
printf("<html><head></head><body>");
for(int i = 0; i < j; i++)
printf("%s = %s<br>", pairs[i].name, pairs[i].value);
printf("</body></html>");
return 0;
}
Kompiluje 3.cpp poleceniem:
g++ -c 3.cpp
index.cpp tez poleceniem g++ -c 3.cpp
I potem to wszystko linkuje
g++ 3.o index.o -o index.cgi
No i niestety tu wlasnie jest ten blad. Pomozcie bo nie za bardzo wiem gdzie jest blad.