|
Home > Archive > Unix Programming > February 2004 > How to declare functions in so to be accessable to applications
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How to declare functions in so to be accessable to applications
|
|
| Micha 2004-02-25, 10:34 am |
| Hi there!
I finally compiled my code (with CC on a SPARC4/Solaris8) and got my
libugs.so
I used this command line to compile:
CC -KPIC -G $(INCS) ugs.o ugsMain.o ugsWrapper.o -o libugs.so
But the application tells my, that it didn't find the entry point
"ugsInit", which is a function delcared as extern in ugsWrapper.h and
implemented in ugsWrapper.cpp.
Do I have to use an other compile command option?
Do I have to set a flag or a macro in the code?
Is there a special syntax to use?
thx, Micha
| |
| Fletcher Glenn 2004-02-25, 12:34 pm |
|
Micha wrote:
> Hi there!
>
> I finally compiled my code (with CC on a SPARC4/Solaris8) and got my
> libugs.so
>
> I used this command line to compile:
>
> CC -KPIC -G $(INCS) ugs.o ugsMain.o ugsWrapper.o -o libugs.so
>
>
> But the application tells my, that it didn't find the entry point
> "ugsInit", which is a function delcared as extern in ugsWrapper.h and
> implemented in ugsWrapper.cpp.
>
> Do I have to use an other compile command option?
> Do I have to set a flag or a macro in the code?
> Is there a special syntax to use?
>
> thx, Micha
Your header file that the application uses, must declare the function
prototype normally, not as an extern. The symbol will then be satisfied
at ld time when you include your library. When you declare it extern,
you are just confusing the linker.
--
Fletcher Glenn
| |
| Måns Rullgård 2004-02-25, 12:34 pm |
| Fletcher Glenn <fletcher@removethisfoglight.com> writes:
> Micha wrote:
>
> Your header file that the application uses, must declare the function
> prototype normally, not as an extern. The symbol will then be satisfied
> at ld time when you include your library. When you declare it extern,
> you are just confusing the linker.
Wrong. Both the header and the source should declare the function as
"extern". Since there is C++ involved, I'd start looking for name
mangling issues.
--
Måns Rullgård
mru@kth.se
|
|
|
|
|