![]() If you have this linking order on your command line: OK in case it's useful for followers, I have found a very useful (and odd) behavior. Hope this will be useful to other people as well! The specified archives are searched repeatedly until no newįor Android NDK libraries, only the first and the second options seem to be available, as NDK's makefiles don't provide a way to specify the archive group List the b twice: ld -shared -o test.so -undefined=b.For such cases there are 3 possible solutions I have found: In the original problem I had there was a circular reference between two static libraries.Īs if I had in the b archive a file b1.c with function foo_b() that is called from foo(). So in my example I should have told him that b() will be called externally, I could do it by using -undefined=b: ld -shared -o test.so -undefined=b. So if the second library uses a symbol from the first one - the symbol will remain undefined, as the linker does not go back. The libraries are processes only once and in the order they appear on the command line. Once found it adds the symbols they use to its list and so force. These are looked up in the current library. First to my example above: the linker starts from the entry points and searches for all symbols they use. Is there a way to tell the linker not to throw away the object files he thinks are unused without having to list all object files? I know there is a -whole-archive option, but I build the library as a part of Android NDK project and did not find a way to pass this option for specific library one.Īn update I've fully understood my original problem and found the correct solution. If I provide the object files instead of archives: ld -shared -o test.so. I've recreated the situation using the simplest files I could think of: The problem is that the linker throws away the usefulFunc.o and I get error " undefined reference ". ![]() One of them, say libUsefulFunc.a contains an object file usefulFunc.o with a function, usefulFunc() that is only used from another static library, let's say usingFunc(), residing in usingFunc.c hosted in libUsingFunc.a I have a number of static libraries which I link together into one shared library.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |