- i have to make a little modification to existing project and i a have to use eclipse (can only be compiled on linux)
the problem is - there is a library (.so) with some classes and functions. deep in templates of classes is a function accepting parameter, but i need it to use additional values.
the problem is - the desired values are not created by library functions, but by "main" program that will include the library. there will be an array of values as program starts, but i can not refer to it in the library functions, as compiler of course complains those variables are not defined.
what is the usual way to access variables in specific scopes of the "main" program that includes library from functions of library?
what is the usual way to access variables in specific scopes of the "main" program that includes library from functions of library?
You don't.
Like you said, the linker complains about the variables being undefined. While I would agree with you that it would be nice to be able to tell the linker "the main program will define this at some point, so don't bother me about not defining it myself", that just isn't the case. Libraries are self-contained units.
You have to take the extra data as parameters. There are other ways to do it, but I don't recommend them.
thank you for reply
as for "other ways" - i am really interested. adding parameters and overloading some functions is big deal - i am facing 4 classes created of templates here, and i am not exactly sure how to add methods without messing with all the other descendants fo the templates :( i really dont think i am that good to get it without making errors.
i have tried the opposite - create an object using class defined in library and use it as "shared storage", but "main" program doesn't seem to acccept namespaces of library as well (e.g. namespace temp{ class test{...}} is not accessible by temp::test newTestobject; in main. am i doing it wrong?