Hy, I am having the following structure:
lib1.a
U f1
00000000 T f2
lib2.a
00000000 T f3
main.c:
#define f1(a, b) f3(a, b)
int main(){
f2(a, b);
}
Note that f2 uses f1.
Is there a way to compile this that will solve the 'undefined reference' without modifying the code or libraries?
The main question is not why I am getting 'undefined reference' for f1 (because it's undefined, obvious), but how I can compile this without having f1 implemented. Something similar to mapping, I want to be called f3 instead of f1 after the compiling is done something similar to redirect (that is why is the define set in main.c).
Thanks
==== Edited == : Ok, so, due to the fact that the problem is too hard to understand, I'll add the sources:
lib2.c -->$gcc -c lib2.c ; ar rcs lib2.a lib2.o
#include <stdio.h>
#include <stdlib.h>
int f3(int c, char *d)
{
printf("Rly: %d %s \n", c,d);
return 1;
}
lib2.h
int f3(int c, char *d);
lib.c -->$gcc -c lib.c ; ar rcs lib.a lib.o
#include <stdio.h>
#include <stdlib.h>
int f2(int c, char *d)
{
printf("%d %s\n", c,d);
f1(c,d);
return 1;
}
lib.h
int f2(int c, char *d);
main.c -->$gcc main.c lib.a lib2.a
#include <stdio.h>
#include <stdlib.h>
#include "lib.h"
#include "lib2.h"
#define f1(a, b) f3(a, b)
int main(int argc, char **argv)
{
f2(argc, argv[0]);
return
}
This are the files I created to generate a similar scenario. The lib.a and lib2.a cannot be modified. Only the main.c and how I compile them.