[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: libs estaticas en C



Jaime:
> Supongamos un archivo FichLib.c que contiene:
>
> int func()
> {
> 	return 1;
> }
>
> y otro Fich.c que contiene:
>
> int main(int argc,char * argv[])
> {
> 	return func();
> }
>
> Entonces hago lo siguiente:
>
> #cc -c FichLib.c
> #ar rv FichLib.a FichLib.o
> a - FichLib.o
> #cc -o Fich FichLib.a Fich.c
> /tmp/ccRUErMj.o: in function 'main':
> /tmp/ccRUErMj.o(.text+0x7): undefined reference to 'func'
> collect2: ld returned 1 exit status
>
> ¿Qué estoy haciendo mal?

Aparentemente, el orden:

cc -o Fich Fich.c FichLib.a   funciona.

En vez de eso también se puede hacer esto otro:

cc -c Fich.c
cc -o Fich Fich.o FichLib.a

Nota: Existe una lista sobre programación en C: gnu-c@listas.hispalinux.es



Reply to: