lammertb / libhttp

Multi platform HTTP and HTTPS library
MIT License
957 stars 131 forks source link

Error building libhttp #45

Open bhakta0007 opened 6 years ago

bhakta0007 commented 6 years ago

Hello, I am encountering an error when trying to build. This appears to be a case of warning treated as error. Do the build instructions still hold good? (I tried make build and it gave me an error)

Issue 1: Build issue on ubuntu

$ uname -a Linux ubuntu 4.13.0-16-generic #19-Ubuntu SMP Wed Oct 11 18:35:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

$ make cc -c -Wall -Wextra -Wstrict-prototypes -Wshadow -Wpointer-arith -Wformat-security -Winit-self -Wcast-qual -Wcast-align -Wwrite-strings -Wnested-externs -Wredundant-decls -Werror -O3 -funsigned-char -Iinclude/ -DUSE_STACK_SIZE=102400 -oobj/httplib_error_string.o src/httplib_error_string.c src/httplib_error_string.c: In function ‘httplib_error_string’: src/httplib_error_string.c:170:2: error: ignoring return value of ‘strerror_r’, declared with attribute warn_unused_result [-Werror=unused-result] strerror_r( error_code, buf, buf_len ); ^~~~~~~~~~ cc1: all warnings being treated as errors Makefile:148: recipe for target 'obj/httplib_error_string.o' failed make: *** [obj/httplib_error_string.o] Error 1

Issue-2: on MAC the build failed with a different error:

$ make cc -c -Wall -Wextra -Wstrict-prototypes -Wshadow -Wpointer-arith -Wformat-security -Winit-self -Wcast-qual -Wcast-align -Wwrite-strings -Wnested-externs -Wredundant-decls -Werror -O3 -funsigned-char -Iinclude/ -DUSE_STACK_SIZE=102400 -oobj/extern_sha1.o src/extern_sha1.c In file included from src/extern_sha1.c:28: src/httplib_main.h:130:9: error: 'CLOCK_MONOTONIC' macro redefined [-Werror,-Wmacro-redefined]

define CLOCK_MONOTONIC (1)

    ^

/usr/include/time.h:156:9: note: previous definition is here

define CLOCK_MONOTONIC _CLOCK_MONOTONIC

    ^

In file included from src/extern_sha1.c:28: src/httplib_main.h:131:9: error: 'CLOCK_REALTIME' macro redefined [-Werror,-Wmacro-redefined]

define CLOCK_REALTIME (2)

    ^

/usr/include/time.h:154:9: note: previous definition is here

define CLOCK_REALTIME _CLOCK_REALTIME

    ^

2 errors generated. make: *** [obj/extern_sha1.o] Error 1

$ make -f Makefile.osx cc -c -Wall -Wextra -Wstrict-prototypes -Wshadow -Wpointer-arith -Wformat-security -Winit-self -Wcast-qual -Wcast-align -Wwrite-strings -Wnested-externs -Wredundant-decls -Werror -O3 -funsigned-char -Iinclude/ -DUSE_STACK_SIZE=102400 -oobj/extern_sha1.o src/extern_sha1.c In file included from src/extern_sha1.c:28: src/httplib_main.h:130:9: error: 'CLOCK_MONOTONIC' macro redefined [-Werror,-Wmacro-redefined]

define CLOCK_MONOTONIC (1)

    ^

/usr/include/time.h:156:9: note: previous definition is here

define CLOCK_MONOTONIC _CLOCK_MONOTONIC

    ^

In file included from src/extern_sha1.c:28: src/httplib_main.h:131:9: error: 'CLOCK_REALTIME' macro redefined [-Werror,-Wmacro-redefined]

define CLOCK_REALTIME (2)

    ^

/usr/include/time.h:154:9: note: previous definition is here

define CLOCK_REALTIME _CLOCK_REALTIME

    ^

2 errors generated. make: *** [obj/extern_sha1.o] Error 1

bhakta0007 commented 6 years ago

On removing Werror from Makefile, the Ubuntu compiles, however I am curious to know why there are warnings in the code?

datrilla commented 6 years ago

i just want to use src .example and test noinclude #include "civetweb.h" ,and there is function paragram are error. i set a httplibtest , but core now

CC:=gcc MAKE:=make AR=ar ARFLAGS=rv CFLAGS:=-O -g -Wall BIN=../bin/ LIB=../lib/ SRC=../src/ RM:= rm -f HIDE=@ ##################dynamic static

$(shell uname -s)

OS:=Linux LDFLAGS= -lpthread -lrt -L../lib/
CPPFLAGS:= -I. -I../src/ -I../include/

httplib_FNAMES=extern_md5 \ extern_sha1 \ extern_ssl_lut \ httplib_abort_start \ httplib_accept_new_connection \ httplib_addenv \ httplib_atomic_dec \ httplib_atomic_inc \ httplib_authorize \ httplib_base64_encode \ httplib_check_acl \ httplib_check_authorization \ httplib_check_feature \ httplib_check_password \ httplib_close_all_listening_sockets \ httplib_close_connection \ httplib_close_socket_gracefully \ httplib_closedir \ httplib_compare_dir_entries \ httplib_connect_client \ httplib_connect_socket \ httplib_connect_websocket_client \ httplib_construct_etag \ httplib_consume_socket \ httplib_create_client_context \ httplib_cry \ httplib_delete_file \ httplib_destroy_client_context \ httplib_difftimespec \ httplib_dir_scan_callback \ httplib_discard_unread_request_data \ httplib_download \ httplib_error_string \ httplib_event_queue \ httplib_fclose \ httplib_fclose_on_exec \ httplib_fgets \ httplib_fopen \ httplib_forward_body_data \ httplib_free_config_options \ httplib_free_context \ httplib_get_builtin_mime_type \ httplib_get_cookie \ httplib_get_debug_level \ httplib_get_first_ssl_listener_index \ httplib_get_header \ httplib_get_mime_type \ httplib_get_option \ httplib_get_random \ httplib_get_rel_url_at_current_server \ httplib_get_remote_ip \ httplib_get_request_handler \ httplib_get_request_info \ httplib_get_request_len \ httplib_get_response \ httplib_get_response_code_text \ httplib_get_server_ports \ httplib_get_system_name \ httplib_get_uri_type \ httplib_get_user_connection_data \ httplib_get_user_data \ httplib_get_var \ httplib_getreq \ httplib_global_data \ httplib_gmt_time_string \ httplib_handle_cgi_request \ httplib_handle_directory_request \ httplib_handle_file_based_request \ httplib_handle_form_request \ httplib_handle_not_modified_static_file_request \ httplib_handle_propfind \ httplib_handle_request \ httplib_handle_static_file_request \ httplib_handle_websocket_request \ httplib_header_has_option \ httplib_inet_pton \ httplib_init_options \ httplib_initialize_ssl \ httplib_interpret_uri \ httplib_is_authorized_for_put \ httplib_is_file_in_memory \ httplib_is_file_opened \ httplib_is_not_modified \ httplib_is_put_or_delete_method \ httplib_is_valid_http_method \ httplib_is_valid_port \ httplib_is_websocket_protocol \ httplib_process_options \ httplib_pthread_join \ httplib_kill \ httplib_load_dll \ httplib_lock_unlock_connection \ httplib_lock_unlock_context \ httplib_log_access \ httplib_lowercase \ httplib_malloc \ httplib_master_thread \ httplib_match_prefix \ httplib_md5 \ httplib_mkcol \ httplib_mkdir \ httplib_modify_passwords_file \ httplib_must_hide_file \ httplib_next_option \ httplib_open_auth_file \ httplib_opendir \ httplib_option_value_to_bool \ httplib_option_value_to_int \ httplib_parse_auth_header \ httplib_parse_date_string \ httplib_parse_http_headers \ httplib_parse_http_message \ httplib_parse_net \ httplib_parse_range_header \ httplib_path_to_unicode \ httplib_poll \ httplib_prepare_cgi_environment \ httplib_print_dir_entry \ httplib_printf \ httplib_process_new_connection \ httplib_produce_socket \ httplib_pull \ httplib_pull_all \ httplib_push_all \ httplib_put_dir \ httplib_put_file \ httplib_read \ httplib_read_auth_file \ httplib_read_request \ httplib_read_websocket \ httplib_readdir \ httplib_redirect_to_https_port \ httplib_refresh_trust \ httplib_remove \ httplib_remove_bad_file \ httplib_remove_directory \ httplib_remove_double_dots \ httplib_reset_per_request_attributes \ httplib_scan_directory \ httplib_send_authorization_request \ httplib_send_file \ httplib_send_file_data \ httplib_send_http_error \ httplib_send_no_cache_header \ httplib_send_options \ httplib_send_static_cache_header \ httplib_send_websocket_handshake \ httplib_set_acl_option \ httplib_set_auth_handler \ httplib_set_close_on_exec \ httplib_set_debug_level \ httplib_set_gpass_option \ httplib_set_handler_type \ httplib_set_non_blocking_mode \ httplib_set_ports_option \ httplib_set_request_handler \ httplib_set_ssl_option \ httplib_set_sock_timeout \ httplib_set_tcp_nodelay \ httplib_set_thread_name \ httplib_set_throttle \ httplib_set_uid_option \ httplib_set_user_connection_data \ httplib_set_websocket_handler \ httplib_should_decode_url \ httplib_should_keep_alive \ httplib_skip \ httplib_skip_quoted \ httplib_snprintf \ httplib_sockaddr_to_string \ httplib_spawn_process \ httplib_ssi \ httplib_ssl_error \ httplib_ssl_get_client_cert_info \ httplib_ssl_get_protocol \ httplib_ssl_id_callback \ httplib_ssl_locking_callback \ httplib_ssl_use_pem_file \ httplib_sslize \ httplib_start \ httplib_start_thread \ httplib_start_thread_with_id \ httplib_stat \ httplib_stop \ httplib_store_body \ httplib_strcasecmp \ httplib_strcasestr \ httplib_strdup \ httplib_strlcpy \ httplib_strncasecmp \ httplib_strndup \ httplib_substitute_index_file \ httplib_suggest_connection_header \ httplib_system_exit \ httplib_system_init \ httplib_timer \ httplib_tls_dtor \ httplib_uninitialize_ssl \ httplib_url_decode \ httplib_url_encode \ httplib_version \ httplib_vprintf \ httplib_vsnprintf \ httplib_websocket_client_thread \ httplib_websocket_client_write \ httplib_websocket_write \ httplib_websocket_write_exec \ httplib_worker_thread \ httplib_write \ osx_clock_gettime \ win32_clock_gettime \ httplib_pthread_cond_broadcast \ httplib_pthread_cond_destroy \ httplib_pthread_cond_init \ httplib_pthread_cond_signal \ httplib_pthread_cond_timedwait \ httplib_pthread_cond_wait \ httplib_pthread_getspecific \ httplib_pthread_key_create \ httplib_pthread_key_delete \ httplib_pthread_mutex_destroy \ httplib_pthread_mutex_init \ httplib_pthread_mutex_lock \ httplib_pthread_mutex_trylock \ httplib_pthread_mutex_unlock \ httplib_pthread_self \ httplib_pthread_setspecific \ httplib_gmtime_r \ httplib_localtime_r \ lh_ipt_to_ip \ lh_ipt_to_ip4 \ lh_ipt_to_ip6 \ wince_rename \ wince_stat \ wince_strftime \ wince_time include_HEADERS = libhttp.h httplib_utils.h httplib_main.h httplib_ssl.h httplib_pthread.h httplib_OBJECTS=$(foreach aName,$(httplib_FNAMES),$(LIB)$(aName).o) ARlibhttp=$(LIB)libhttp.a

ALLFN= $(httplib_FNAMES)
ALLOBJ= $(httplib_OBJECTS)

../lib/name.o

pOBJCB= $(foreach aobj,$(ALLOBJ),../lib/$(aobj))

###########链接规则 $(BIN)httplibtest:$(ARlibhttp) $(CC) $(CFLAGS) $(ARlibhttp) $(LDFLAGS) $(CPPFLAGS) -o $@ $(ARlibhttp):$(ALLOBJ) $(AR) $(ARFLAGS) $(ARlibhttp) $(ALLOBJ)

###########自动生成编译规则########################

../lib/name.o:../src/name.call

$(CC) -c $(CFLAGS) $(CPPFLAGS) $^ -o $@

################################################### define Function_prec $2:$1 $$(CC) -c $$(CFLAGS) $$(CPPFLAGS) $$^ -o $$@ endef
$(foreach one,$(ALLFN),\ $(eval $(call Function_prec,../src/$(one).c,../lib/$(one).o))\ ) ###########清空 clear: $(RM) $(LIB)*.o $(RM) $(BIN)httplibtest

bhakta0007 commented 6 years ago

update: I moved over to civetweb project and the same example builds there.

datrilla commented 6 years ago

dir example and dir test don‘t adapt the project.should modify parameter and struct .