I create a .so file with the code below, but when I compile a file that invokes functions in the .so file with GCC, I get an “undefined reference to ‘outlib1′” error.
What’s wrong with my code or my command? Thanks.
OS Ubuntu 11.10
gcc 4.6.1
//file name outscreen.c
#include <stdio.h>
void outlib1(void)
{
printf("out screen func1\n");
}
//file name main.c
int main(int argc, char* argv[])
{
outlib1();
}
gcc outscreen.c -fPIC -shared -o outscreen.so
gcc main.c -L. -loutscreen -o call
./call
Try:
(note the change to the first line – the second line is unchanged)