jay94ks / libnhttp

Native HTTP Server/Client Library
MIT License
2 stars 1 forks source link

nhttpd 빌드 오류 #3

Open maze888 opened 3 years ago

maze888 commented 3 years ago

빌드 환경은 아래와 같습니다.

[maze@devcube 13:12:06 nhttpd]$ uname -a
Linux devcube 5.11.0-17-generic #18-Ubuntu SMP Thu May 6 20:10:11 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

[maze@devcube 13:13:06 nhttpd]$ g++ --version
g++ (Ubuntu 10.3.0-1ubuntu1) 10.3.0
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

컴파일은 되나, 링크 에러가 발생합니다.

[maze@devcube 13:06:49 nhttpd]$ make
g++ -O3 -fPIC -I../libnhttp -c main.cpp
g++ -o httpd main.o -L../libnhttp -lnhttp
/usr/bin/ld: main.o: in function `nhttp::server::xfwk::xfwk_lambda_target::handle(std::shared_ptr) const':
main.cpp:(.text+0x2811): undefined reference to `nhttp::http_mime_type::TEXT_HTML'
/usr/bin/ld: main.o: in function `nhttp::server::xfwk::xfwk_lambda_target)#3}::operator()(std::shared_ptr) const::{lambda(std::shared_ptr)#4}>::handle(std::shared_ptr) const':
main.cpp:(.text+0x2afc): undefined reference to `nhttp::http_mime_type::TEXT_HTML'
/usr/bin/ld: main.o: in function `nhttp::server::xfwk::xfwk_lambda_target)#3}::operator()(std::shared_ptr) const::{lambda(std::shared_ptr)#2}>::handle(std::shared_ptr) const':
main.cpp:(.text+0x2f3a): undefined reference to `nhttp::http_mime_type::TEXT_HTML'
/usr/bin/ld: main.o: in function `nhttp::server::xfwk::xfwk_lambda_target)#2}>::handle(std::shared_ptr) const':
main.cpp:(.text+0x31d8): undefined reference to `nhttp::http_mime_type::TEXT_HTML'
/usr/bin/ld: main.o: in function `nhttp::server::xfwk::xfwk_lambda_target)#3}::operator()(std::shared_ptr) const::{lambda(std::shared_ptr)#5}>::handle(std::shared_ptr) const':
main.cpp:(.text+0x36ca): undefined reference to `nhttp::http_mime_type::TEXT_HTML'
/usr/bin/ld: main.o:main.cpp:(.text+0x3bca): more undefined references to `nhttp::http_mime_type::TEXT_HTML' follow
collect2: error: ld returned 1 exit status
make: *** [Makefile:3: all] Error 1
[maze@devcube 13:06:57 nhttpd]$

Makefile 이 제공되는것이 없어서, 제가 임의로 간단히 작성했습니다.

제가 뭔가 빠뜨린게 있는건가요..?

jay94ks commented 3 years ago

앗 안녕하세요!

아래 경로에 Makefile이 제공되고 있습니다!

https://github.com/jay94ks/libnhttp/blob/main/libnhttp/Makefile

2021년 5월 26일 (수) 오후 1:17, maze888 @.***>님이 작성:

빌드 환경은 아래와 같습니다.

@.*** 13:12:06 nhttpd]$ uname -a

Linux devcube 5.11.0-17-generic #18-Ubuntu SMP Thu May 6 20:10:11 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

@.*** 13:13:06 nhttpd]$ g++ --version

g++ (Ubuntu 10.3.0-1ubuntu1) 10.3.0

Copyright (C) 2020 Free Software Foundation, Inc.

This is free software; see the source for copying conditions. There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

컴파일은 되나, 링크 에러가 발생합니다.

@.*** 13:06:49 nhttpd]$ make

g++ -O3 -fPIC -I../libnhttp -c main.cpp

g++ -o httpd main.o -L../libnhttp -lnhttp

/usr/bin/ld: main.o: in function `nhttp::server::xfwk::xfwk_lambda_target::handle(std::shared_ptr) const':

main.cpp:(.text+0x2811): undefined reference to `nhttp::http_mime_type::TEXT_HTML'

/usr/bin/ld: main.o: in function `nhttp::server::xfwk::xfwk_lambda_target)#3}::operator()(std::shared_ptr) const::{lambda(std::shared_ptr)#4}>::handle(std::shared_ptr) const':

main.cpp:(.text+0x2afc): undefined reference to `nhttp::http_mime_type::TEXT_HTML'

/usr/bin/ld: main.o: in function `nhttp::server::xfwk::xfwk_lambda_target)#3}::operator()(std::shared_ptr) const::{lambda(std::shared_ptr)#2}>::handle(std::shared_ptr) const':

main.cpp:(.text+0x2f3a): undefined reference to `nhttp::http_mime_type::TEXT_HTML'

/usr/bin/ld: main.o: in function `nhttp::server::xfwk::xfwk_lambda_target)#2}>::handle(std::shared_ptr) const':

main.cpp:(.text+0x31d8): undefined reference to `nhttp::http_mime_type::TEXT_HTML'

/usr/bin/ld: main.o: in function `nhttp::server::xfwk::xfwk_lambda_target)#3}::operator()(std::shared_ptr) const::{lambda(std::shared_ptr)#5}>::handle(std::shared_ptr) const':

main.cpp:(.text+0x36ca): undefined reference to `nhttp::http_mime_type::TEXT_HTML'

/usr/bin/ld: main.o:main.cpp:(.text+0x3bca): more undefined references to `nhttp::http_mime_type::TEXT_HTML' follow

collect2: error: ld returned 1 exit status

make: *** [Makefile:3: all] Error 1

@.*** 13:06:57 nhttpd]$

Makefile 이 제공되는것이 없어서, 제가 임의로 간단히 작성했습니다.

제가 뭔가 빠뜨린게 있는건가요..?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jay94ks/libnhttp/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH6TKOKEPJNUOWWMSSPKVHLTPRY4LANCNFSM45QYHGDQ .

maze888 commented 3 years ago

음.. 앗.. 안녕하세요. 그래도 빌드 에러가 나네요.. (make bench-app)

[maze@devcube 18:50:54 libnhttp]$ ll
total 4188
drwxrwxr-x  4 maze maze    4096 May 26 18:46 .
drwxrwxr-x  8 maze maze    4096 May 26 12:46 ..
-rw-rw-r--  1 maze maze 1397876 May 26 12:47 libnhttp.a
-rwxrwxr-x  1 maze maze  761184 May 26 12:47 libnhttp.so
-rw-rw-r--  1 maze maze   15451 May 26 12:46 libnhttp.vcxproj
-rw-rw-r--  1 maze maze   16044 May 26 12:46 libnhttp.vcxproj.filters
-rw-rw-r--  1 maze maze    8685 May 26 12:46 Makefile
drwxrwxr-x 10 maze maze    4096 May 26 12:46 nhttp
-rw-rw-r--  1 maze maze    3067 May 26 18:46 test-main.cpp
-rw-rw-r--  1 maze maze 2056392 May 26 18:46 test-main.gcno
drwxrwxr-x  2 maze maze    4096 May 26 18:46 tests
[maze@devcube 18:51:21 libnhttp]$ 
[maze@devcube 18:51:22 libnhttp]$ pwd
/home/maze/git/libnhttp/libnhttp
[maze@devcube 18:51:23 libnhttp]$ make bench-app
g++ -O3 -o bench-app ../nhttpd/main.cpp -lpthread -lrt -lnhttp -std=c++17
../nhttpd/main.cpp:2:10: fatal error: nhttp/types.hpp: No such file or directory
    2 | #include "nhttp/types.hpp"
      |          ^~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:81: bench-app] Error 1
[maze@devcube 18:51:28 libnhttp]$ 

Makefile 에 -I. -L. 넣어주면 빌드가 되긴해요~ 위에 제가 작성한 Makefile 에는 -std=c++17 넣으니까 링크 에러 문제는 해결했어요

jay94ks commented 3 years ago

-I 옵션이랑 -L 옵션이 누락되었었네요 ㅠㅠ 수정하겠습니다!