Guest User

Untitled

a guest
Apr 22nd, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. Source to main.c:
  2. #include <stdio.h>
  3.  
  4. extern int foo(void);
  5.  
  6. int main(int argc, char** argv)
  7. {
  8. (void) foo();
  9. return 2;
  10. }
  11.  
  12. Source to foo.c:
  13. #include <stdio.h>
  14.  
  15. int foo(void)
  16. {
  17. printf("SUCCESS\n");
  18. }
  19.  
  20. I am able to compile both of these files to main.o and foo.o respectively with the Android NDK, and when I link both of these object files together to create an executable, the resulting executable works.
  21.  
  22. HOWEVER
  23.  
  24. When I link foo.o into a shared library libfoo.so and create an executable from main.o linking with -lfoo, compilation succeeds without warning. When I copy both the resulting executable and the library to my device with adb push and attempt to run the executable, this is what I get:
  25.  
  26. # ./test-c-library
  27. link_image[1995]: failed to link ./test-c-library
  28. CANNOT LINK EXECUTABLE
  29.  
  30. I can supply sanitized command lines for the gcc and ld commands if that would help.
Add Comment
Please, Sign In to add comment