自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

通過Makefile在iPhone下創(chuàng)建Dylib實例

移動開發(fā) iOS
本文介紹的是通過Makefile在iPhone下創(chuàng)建Dylib實例,主要是來解決如何通過Makefile在iPhone下創(chuàng)建Dylib,來看內(nèi)容。

通過MakefileiPhone下創(chuàng)建Dylib實例是本文要介紹的內(nèi)容,首先我要聲明下經(jīng)過測試,第三方的dylib是無法在未越獄的iphone上c成功運行的。寫這篇文章也只是為了完善之前的那篇文章。

1、創(chuàng)建dylibtest.c 和.h

這里隨便寫了個test函數(shù)。

dylibtest.h

void test();
 
dylibtest.c

  1. #include "dylibtest.h"  
  2. #include "stdio.h"  
  3. void test() {  
  4.     printf("this is a test\n");  
  5. }  
  6.  
  7. makefile   
  8.  
  9. CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc  
  10. CFLAGS= -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.2.sdk  
  11. CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp  
  12. target:  
  13.  $(CC) $(CFLAGS) -dynamiclib -o sotest-iphone.dylib dylibtest.c 

這里用的是sdk4.2 arch為armv6,另外需要提醒的事,如果你編譯的是.m文件使用到framework的話編譯時可以這樣寫

  1. -framework Foundation 

下面是測試代碼 testdylib

關(guān)鍵代碼如下:

  1. NSString *path = [[NSBundle mainBundle] pathForResource:@"sotest-iphone" ofType:@"dylib"];  
  2. void* handle = dlopen([path cStringUsingEncoding:NSUTF8StringEncoding], RTLD_LAZY);  
  3. if (!handle) {  
  4.     printf("%s\n", dlerror());  
  5.     return;  
  6. }  
  7. void (*test)();  
  8. test = (void (*)())dlsym(handle, "test");  
  9. const char *dlsym_error = dlerror();  
  10. if (dlsym_error) {  
  11.     printf("%s\n", dlsym_error);  
  12.     dlclose(handle);  
  13.     return;  
  14. }  
  15. // use it to do the calculation  
  16. test();      
  17. // close the library  
  18. dlclose(handle); 

你可以去測試下了,不過相信結(jié)果應該不會很讓你滿意。

小結(jié):通過MakefileiPhone下創(chuàng)建Dylib實例的內(nèi)容介紹完了,希望本文對你有所幫助!

責任編輯:zhaolei 來源: 互聯(lián)網(wǎng)
相關(guān)推薦

2011-07-18 15:42:20

Xcode iPhone dylib

2013-08-13 09:54:39

iPhone 4iPhone 5iOS 7

2010-11-19 10:01:08

Oracle創(chuàng)建實例

2011-07-25 18:02:51

iPhone LibFetion 移植

2011-08-10 11:01:54

iPhoneNSThreadRun Loop

2011-08-10 10:18:22

iPhone多線程線程

2011-08-08 16:56:44

iPhone 字符處理 視圖

2010-11-03 13:55:39

創(chuàng)建DB2實例

2023-09-08 14:48:41

動態(tài)共享包HSP

2023-09-07 15:45:30

靜態(tài)庫鴻蒙

2011-12-25 21:00:30

iPhone

2009-11-30 17:40:05

juniper路由

2011-07-06 16:15:46

iPhone 圖片

2009-06-17 09:01:20

JBoss訪問EJB

2011-07-06 18:31:21

Xcode 4 iPhone 模擬器

2015-08-14 10:32:10

CentOSOpenStack搭建本地源

2011-07-22 17:24:46

iPhone 視圖

2011-07-18 15:32:14

iPhone 錄音 播放

2011-07-18 13:37:53

2011-08-02 14:23:09

iPhone UIScrollVi 圖片
點贊
收藏

51CTO技術(shù)棧公眾號