By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,778 Members | 1,997 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,778 IT Pros & Developers. It's quick & easy.

How to make a library that comples the users to define some function

P: n/a
Hi,
I am trying to create a library and want its user to define a function
in their executable if that library is linked. some thing like, if some
uses my library and haven't defined a function like

void Initialize( long a, long b)
{
}
at link time I should get an error like "unresolved symbols"
I am able to get it done if I create a dummy fnction in header file of
library which indirectly calls this function, whose decleration is
persent in the library, but no defination is given.
But the loop-hole remains, if some one modifies the header and then
uses the library. I am trying it out on UNIX. Please let me know if
this needs to be posted in the UNIX group. for gcc compiler there is an
option "-rdynamic" , but not finding the same for CC compiler
regards,
Jitu

Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a

<ji************@gmail.com> schrieb im Newsbeitrag
news:11*********************@c13g2000cwb.googlegro ups.com...
Hi,
I am trying to create a library and want its user to define a
function
in their executable if that library is linked. some thing like, if
some
uses my library and haven't defined a function like

void Initialize( long a, long b)
{
}
at link time I should get an error like "unresolved symbols"
I am able to get it done if I create a dummy fnction in header file
of
library which indirectly calls this function, whose decleration is
persent in the library, but no defination is given.
But the loop-hole remains, if some one modifies the header and then
uses the library. I am trying it out on UNIX. Please let me know if
this needs to be posted in the UNIX group. for gcc compiler there is
an
option "-rdynamic" , but not finding the same for CC compiler
regards,
Jitu

header:
void foo();
void DoWork();
cpp:

void DoWork()
{
foo();
somework ...
}
if you make a lib, it will call "foo". If you remove it from the
header, you still need it for the linker, since your lib calls it.
-Gernot
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.