code_junkie

Using C/C++ static libraries from iPhone ObjectiveC Apps

Nov 13th, 2011
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #ifdef __cplusplus
  2. extern "C"
  3. #endif
  4. void show_the_world(void);
  5.  
  6. #include <iostream>
  7. #include "stw.h"
  8. using namespace std;
  9.  
  10. extern "C" void show_the_world() {
  11. cout << "Hello, world!n";
  12. }
  13.  
  14. $ g++ -c stw.cpp -o stw.cpp -O0 -g
  15. $ ar rcs stw.a stw.o
  16.  
  17. #include "stw.h"
  18.  
  19. int main() {
  20. show_the_world();
  21. return 0;
  22. }
  23.  
  24. $ gcc -o myapp myapp.c stw.a -lstdc++ -g -O0
  25. $ ./myapp
  26. Hello, world!
  27. $
  28.  
  29. #ifndef HEADER_GUARD_1_H
  30. #define HEADER_GUARD_1_H
  31.  
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35.  
  36. // Declare C function interface here.
  37. int myFunc(int x,char*);
  38.  
  39. #ifdef __cplusplus
  40. }
  41. #endif
  42.  
  43. #endif
Add Comment
Please, Sign In to add comment