Is it possible to add a shared library to a static library ?
I have created a new shared library "libshared.so" . There is a existing static library "libstatic.a" . I need to refer the new code of .so into the .a files.
The libstatic.a compiles fine after I add -I<path_of_the_files_shared.so> in its Makefile. Now this static.a is referenced in a exe . To avoid any linker issues I added -L<path_of_shared.so> -lshared in the Makefile of the exe . But when I try to compile it I get linker issue , of undefined reference to the libstatic.a for the methods of .so . Even the nm for libstatic.a gives "U" for the methods of .so Now my question is : 1) Is it valid to have a shared library call in a static library? 2) How to get rid of this undefined reference error ? Please help me solve this issue. Thanks. |
Hi -
1. You can add anything you want to a library ... including your grocery list, if you wanted. 2. You can mix'n'match shared and static references in your program: some symbols can be static, others can be dynamic. 3. By the same token, Yes: it's absolutely legal for a subroutine in a shared library to call a static reference (in which case the static reference will be included in your actual .so file). It's also legal for a subroutine in a static library to call a shared reference. |
Thanks for confirming. So can you pls elaborate on how to get rid of the linking issue when building the exe ?
|
All times are GMT -5. The time now is 09:33 PM. |