"DIAL 샘플 빌드하기"의 두 판 사이의 차이

잔글
91번째 줄: 91번째 줄:
</source>
</source>


*패치
== 패치 ==
아래 패치 코드 복사하여 패치 수행
<source lang="bash">
<source lang="bash">
patch -p1 < dial.patch
patch -p1 < dial.patch
</source>
</source>


==소스 변동 내역==
* 모든 수정 내역을 포함한 패치
<source lang="diff">  
<source lang="diff">  
diff -rupN src_org/client/DialConformance.cpp src/client/DialConformance.cpp
diff -rupN src_org/client/DialConformance.cpp src/client/DialConformance.cpp

2013년 12월 31일 (화) 12:09 판

DIAL (DIscovery And Launch) 샘플 빌드하기

1 테스트 환경

  • Ubuntu 13.10 64 bit
  • Firefox 25.0.1 (Mozilla Firefox for Ubuntu canonical - 1.0)
  • g++ (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1
  • curl 7.32.0 (x86_64-pc-linux-gnu) libcurl/7.32.0 OpenSSL/1.0.1e zlib/1.2.8 libidn/1.28 librtmp/2.3

2 다운로드 및 압축해제

tar zxvf DIAL-1.0.2-1676049.tar.gz 
cd src
make

3 오류 조치 (소스 수정 및 패키지 설치)

  • fatal error: bits/c++config.h: No such file or directory
gcc-4.8-multilib g++-4.8-multilib 설치
sudo apt-get install gcc-4.8-multilib g++-4.8-multilib
  • main.cpp:287:12: error: ‘sleep’ was not declared in this scope
client/main.cpp에 내용 추가
#include <unistd.h>
  • DialConformance.cpp:424:33: error: ‘usleep’ was not declared in this scope
client/DialConformance.cpp 에 내용 추가
#include <unistd.h>
  • DialServer.cpp:27:23: fatal error: curl/curl.h: No such file or directory
libcurl4-openssl-dev 설치
sudo apt-get install libcurl4-openssl-dev
  • /usr/include/curl/curlrules.h:143:41: error: size of array ‘__curl_rule_01__’ is negative
client/makefile 에서 -m32 제거
#         $(CC) -Wall -Werror -g $(OBJS) $(INCLUDES) $(LDFLAGS) -ldl -lpthread -lcurl -lz -lcrypto -lssl -lcares -m32 -o dialclient
            $(CC) -Wall -Werror -g $(OBJS) $(INCLUDES) $(LDFLAGS) -ldl -lpthread -lcurl -lz -lcrypto -lssl -lcares -o dialclient
  • main.cpp:59:40: error: format ‘%Zu’ expects argument of type ‘size_t’, but argument 2 has type ‘int’ [-Werror=format=]
client/main.cpp (size_t) 추가
        printf("%Zu: Server IP[%s] UUID[%s] FriendlyName[%s] \n",
            (size_t)i+1, (*it)->getIpAddress().c_str(),
            uuid.c_str(), name.c_str() );
                   printf("Server %Zu: %s\n", (size_t)i+1, name.c_str());
  • DialDiscovery.cpp:134:14: error: variable ‘res’ set but not used [-Werror=unused-but-set-variable]
client/DialDiscovery.cpp 에 (void)res 추가
     CURL *curl;
     CURLcode res = CURLE_OK;
     (void)res;
  • DialDiscovery.cpp:257:84: error: too many arguments for format [-Werror=format-extra-args]
client/DialDiscovery.cpp 수정
     send_size = snprintf(send_buf, sizeof(send_buf), ssdp_msearch/*, ip_addr, my_port*/);
    //static char ip_addr[INET_ADDRSTRLEN] = "127.0.0.1";
    //static int my_port = 0;
  • /usr/bin/ld: cannot find -lcares
-lcares 제거
#         $(CC) -Wall -Werror -g $(OBJS) $(INCLUDES) $(LDFLAGS) -ldl -lpthread -lcurl -lz -lcrypto -lssl -lcares -m32 -o dialclient
            $(CC) -Wall -Werror -g $(OBJS) $(INCLUDES) $(LDFLAGS) -ldl -lpthread -lcurl -lz -lcrypto -lssl -o dialclient
  • main.c:319:13: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
server/main.c 에 (long) 추가
319     waitpid((pid_t)(long)run_id, NULL, WNOHANG); // reap child

4 패치

아래 패치 코드 복사하여 패치 수행

patch -p1 < dial.patch
  • 모든 수정 내역을 포함한 패치
 
diff -rupN src_org/client/DialConformance.cpp src/client/DialConformance.cpp
--- src_org/client/DialConformance.cpp	2013-12-30 12:51:43.017984698 +0900
+++ src/client/DialConformance.cpp	2013-12-30 12:54:19.853987278 +0900
@@ -32,6 +32,7 @@
 #include <time.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 // Number of milliseconds to sleep between launches when doing a launch=ALL
 #define LAUNCH_SLEEP 6000
diff -rupN src_org/client/DialDiscovery.cpp src/client/DialDiscovery.cpp
--- src_org/client/DialDiscovery.cpp	2013-12-30 12:51:43.009984698 +0900
+++ src/client/DialDiscovery.cpp	2013-12-30 12:54:02.941987000 +0900
@@ -48,8 +48,8 @@ using namespace std;
 
 DialDiscovery *DialDiscovery::sDiscovery = 0;
 
-static char ip_addr[INET_ADDRSTRLEN] = "127.0.0.1";
-static int my_port = 0;
+//static char ip_addr[INET_ADDRSTRLEN] = "127.0.0.1";
+//static int my_port = 0;
 static struct sockaddr_in saddr;
 typedef struct
 {
@@ -132,6 +132,7 @@ static void getServerInfo( const string
 {
     CURL *curl;
     CURLcode res = CURLE_OK;
+    (void)res;
 
     if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
         fprintf(stderr, "curl_global_init() failed\n");
@@ -253,7 +254,7 @@ void * DialDiscovery::send_mcast(void *p
     pthread_attr_t attr;
     search_conn connection;
 
-    send_size = snprintf(send_buf, sizeof(send_buf), ssdp_msearch, ip_addr, my_port);
+    send_size = snprintf(send_buf, sizeof(send_buf), ssdp_msearch/*, ip_addr, my_port*/);
     ATRACE("[%s:%d] %s\n", __FUNCTION__, __LINE__, send_buf);
 
     if (-1 == (my_sock = socket(AF_INET, SOCK_DGRAM, 0))) {
diff -rupN src_org/client/main.cpp src/client/main.cpp
--- src_org/client/main.cpp	2013-12-30 12:51:43.009984698 +0900
+++ src/client/main.cpp	2013-12-30 12:52:37.113985588 +0900
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
 
 using namespace std;
 
@@ -54,7 +55,7 @@ static void printServerList( vector<Dial
         (*it)->getFriendlyName( name );
         (*it)->getUuid( uuid );
         printf("%Zu: Server IP[%s] UUID[%s] FriendlyName[%s] \n", 
-            i+1, (*it)->getIpAddress().c_str(),
+            (size_t)i+1, (*it)->getIpAddress().c_str(),
             uuid.c_str(), name.c_str() );
     }
 }
@@ -181,7 +182,7 @@ int handleUser(DialDiscovery *pDial) {
                 {
                     string name;
                     list[i]->getFriendlyName(name);
-                    printf("Server %Zu: %s\n", i+1, name.c_str());
+                    printf("Server %Zu: %s\n", (size_t)i+1, name.c_str());
                 }
                 printf("\n*********************************\n\n");
             }break;
diff -rupN src_org/client/makefile src/client/makefile
--- src_org/client/makefile	2013-12-30 12:51:43.009984698 +0900
+++ src/client/makefile	2013-12-30 12:53:00.333985970 +0900
@@ -8,7 +8,7 @@ OBJS := main.cpp DialServer.cpp DialDisc
 
 # You may not need all these libraries.  This example uses a build of curl that needs crypto, ssl, cares, and zlib
 dialclient: $(OBJS) ${includes}
-	$(CC) -Wall -Werror -g $(OBJS) $(INCLUDES) $(LDFLAGS) -ldl -lpthread -lcurl -lz -lcrypto -lssl -lcares -m32 -o dialclient
+	$(CC) -Wall -Werror -g $(OBJS) $(INCLUDES) $(LDFLAGS) -ldl -lpthread -lcurl -lz -lcrypto -lssl -o dialclient
 
 clean:
 	rm -f *.o dialclient
diff -rupN src_org/server/main.c src/server/main.c
--- src_org/server/main.c	2013-12-30 12:51:43.025984698 +0900
+++ src/server/main.c	2013-12-30 12:54:37.861987574 +0900
@@ -316,7 +316,7 @@ static DIALStatus netflix_status(DIALSer
     // Netflix application can stop
     *pCanStop = 1;
 
-    waitpid((pid_t)run_id, NULL, WNOHANG); // reap child
+    waitpid((pid_t)(long)run_id, NULL, WNOHANG); // reap child
     return isAppRunning( spAppNetflix, NULL ) ? kDIALStatusRunning : kDIALStatusStopped;
 }

5 실행 예시

$ ./server/dialserver 
Netflix is Not Running
YouTube is Not Running
launcher listening on gDialPort 56789
SSDP listening on 172.30.1.1:56790

Sending SSDP reply to 172.30.1.1:59347
$ ./client/dialclient 
0. List DIAL servers
1. Launch Netflix
2. Kill Netflix
3. Netflix status
4. Launch YouTube
5. Kill YouTube
6. YouTube status
7. Run conformance tests
8. QUIT

6 같이 보기

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}