A simple problem regarding shared libs...
Andrea 'Fyre Wyzard' Bocci
fwyzard@inwind.it
Fri Feb 8 18:49:00 GMT 2002
Hi
I've tried reproducing your problem, but on my machine everything went
smoothly.
Also, I've not set LD_LIBRARY_PATH in any way. Just typed, and it worked !
(gcc 2.96 and gcc 3.0.2, binutils 2.11.90, linux 2.4.7, RedHat 7.2)
[fwyzard@stufis06 test]$ gcc sharobj.c -c -o sharobj.o
[fwyzard@stufis06 test]$ gcc hello.c -c -o hello.o
[fwyzard@stufis06 test]$ gcc sharobj.o -shared -o libshared.so
[fwyzard@stufis06 test]$ gcc hello.o -L. -lshared -o hello
[fwyzard@stufis06 test]$ ./hello
Hello World
Hello from shared lib
Here's the files I've used:
/* hello.c */
#include <stdio.h>
extern const char* func();
int main( void)
{
printf("Hello World\n");
func();
return 1;
}
/* end of hello.c */
/* sharobj.c */
#include <stdio.h>
const char* func(void)
{
printf("Hello from shared lib\n");
}
/* end of sharobj.c */
fwyzard
More information about the Gcc-help
mailing list