davidmoreno / onion

C library to create simple HTTP servers and Web Applications.
http://www.coralbits.com/libonion/
Other
2.02k stars 252 forks source link

Unable to compile on OSX #98

Open nrj opened 9 years ago

nrj commented 9 years ago

On master branch I get this:

CMake Warning (dev):
Policy CMP0042 is not set: MACOSX_RPATH is enabled by default.  Run "cmake
--help-policy CMP0042" for policy details.  Use the cmake_policy command to
set the policy and suppress this warning.

MACOSX_RPATH is not specified for the following targets:

i18n
onion
onioncpp

On the darwin branch and I get this error when running cmake

CMake Error: Error in cmake code at
/Users/me/onion/tests/CMakeLists.txt:18:
Parse error.  Function missing ending ")".  Instead found bad character with text "[".`

Any idea how to get this building on OSX 10.10?

davidmoreno commented 9 years ago

Sadly I have no easy access to any Mac computer.. so I dont know how to help you.

If you manage to solve the problem, please let me know how you did fix it so I can fix it upstream.

Anyway it looks like a cmake version problem. Which version do you have installed?

Regards, David.

loggerhead commented 9 years ago

@davidmoreno It should be a cmake version problem since my cmake version is 3.2.3 and no cmake error happened on OS X 10.10. But I got other problem...

File not found error

onion/handlers/auth_pam.c:29:10: fatal error:
      'security/pam_misc.h' file not found

This error can be fixed by modify line 26 in CMakeLists.txt.

if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")

Undefined symbols error

Scanning dependencies of target onion
[  0%] Building C object src/onion/CMakeFiles/onion.dir/onion.c.o
[  1%] Building C object src/onion/CMakeFiles/onion.dir/codecs.c.o
[  2%] Building C object src/onion/CMakeFiles/onion.dir/dict.c.o
/Users/fz/Downloads/onion/src/onion/dict.c:85:15: warning: implicitly declaring library function 'strcasecmp' with type 'int (const char *, const char *)'
    dict->cmp=strcasecmp;
              ^
/Users/fz/Downloads/onion/src/onion/dict.c:85:15: note: include the header <strings.h> or explicitly provide a declaration for 'strcasecmp'
1 warning generated.
[  2%] Building C object src/onion/CMakeFiles/onion.dir/low.c.o
[  3%] Building C object src/onion/CMakeFiles/onion.dir/request.c.o
/Users/fz/Downloads/onion/src/onion/request.c:442:22: warning: implicitly declaring library function 'strcasecmp' with type 'int (const char *, const char *)'
                if (!connection || strcasecmp(connection,"Close")!=0) // Other side wants keep alive
                                   ^
/Users/fz/Downloads/onion/src/onion/request.c:442:22: note: include the header <strings.h> or explicitly provide a declaration for 'strcasecmp'
1 warning generated.
[  3%] Building C object src/onion/CMakeFiles/onion.dir/response.c.o
[  4%] Building C object src/onion/CMakeFiles/onion.dir/handler.c.o
[  5%] Building C object src/onion/CMakeFiles/onion.dir/log.c.o
/Users/fz/Downloads/onion/src/onion/log.c:188:2: warning: implicit declaration of function 'vsyslog' is invalid in C99 [-Wimplicit-function-declaration]
        vsyslog(pri[level], fmt, ap);
        ^
1 warning generated.
[  5%] Building C object src/onion/CMakeFiles/onion.dir/sessions.c.o
[  6%] Building C object src/onion/CMakeFiles/onion.dir/sessions_mem.c.o
[  7%] Building C object src/onion/CMakeFiles/onion.dir/shortcuts.c.o
[  7%] Building C object src/onion/CMakeFiles/onion.dir/block.c.o
[  8%] Building C object src/onion/CMakeFiles/onion.dir/mime.c.o
[  8%] Building C object src/onion/CMakeFiles/onion.dir/url.c.o
[  9%] Building C object src/onion/CMakeFiles/onion.dir/listen_point.c.o
[ 10%] Building C object src/onion/CMakeFiles/onion.dir/request_parser.c.o
[ 10%] Building C object src/onion/CMakeFiles/onion.dir/http.c.o
[ 11%] Building C object src/onion/CMakeFiles/onion.dir/websocket.c.o
/Users/fz/Downloads/onion/src/onion/websocket.c:79:18: warning: implicitly declaring library function 'strcasecmp' with type 'int (const char *, const char *)'
        if (!upgrade || strcasecmp(upgrade,"websocket")!=0)
                        ^
/Users/fz/Downloads/onion/src/onion/websocket.c:79:18: note: include the header <strings.h> or explicitly provide a declaration for 'strcasecmp'
/Users/fz/Downloads/onion/src/onion/websocket.c:98:12: warning: implicitly declaring library function 'alloca' with type 'void *(unsigned long)'
        char *tmp=alloca(length+websocket_magic_13_length+1);
                  ^
/Users/fz/Downloads/onion/src/onion/websocket.c:98:12: note: include the header <stdlib.h> or explicitly provide a declaration for 'alloca'
2 warnings generated.
[ 12%] Building C object src/onion/CMakeFiles/onion.dir/ptr_list.c.o
[ 12%] Building C object src/onion/CMakeFiles/onion.dir/handlers/static.c.o
[ 13%] Building C object src/onion/CMakeFiles/onion.dir/handlers/exportlocal.c.o
/Users/fz/Downloads/onion/src/onion/handlers/exportlocal.c:182:73: warning: format specifies type 'long' but the argument has type 'off_t' (aka 'long long') [-Wformat]
                        onion_response_printf(res, "  ['%s/',%ld,'%s','dir'],\n",fi->d_name, st.st_size, pwd ? pwd->pw_name : "???");
                                                             ~~~                             ^~~~~~~~~~
                                                             %lld
/Users/fz/Downloads/onion/src/onion/handlers/exportlocal.c:184:73: warning: format specifies type 'long' but the argument has type 'off_t' (aka 'long long') [-Wformat]
                        onion_response_printf(res, "  ['%s',%ld,'%s','file'],\n",fi->d_name, st.st_size, pwd ? pwd->pw_name : "???");
                                                            ~~~                              ^~~~~~~~~~
                                                            %lld
2 warnings generated.
[ 13%] Building C object src/onion/CMakeFiles/onion.dir/handlers/opack.c.o
[ 14%] Building C object src/onion/CMakeFiles/onion.dir/handlers/path.c.o
[ 15%] Building C object src/onion/CMakeFiles/onion.dir/handlers/internal_status.c.o
[ 15%] Building C object src/onion/CMakeFiles/onion.dir/sessions_sqlite3.c.o
[ 16%] Building C object src/onion/CMakeFiles/onion.dir/random-default.c.o
[ 17%] Building C object src/onion/CMakeFiles/onion.dir/handlers/webdav.c.o
/Users/fz/Downloads/onion/src/onion/handlers/webdav.c:521:11: warning: implicitly declaring library function 'alloca' with type 'void *(unsigned long)'
        basepath=alloca(pathlen+1);
                 ^
/Users/fz/Downloads/onion/src/onion/handlers/webdav.c:521:11: note: include the header <stdlib.h> or explicitly provide a declaration for 'alloca'
1 warning generated.
[ 17%] Building C object src/onion/CMakeFiles/onion.dir/poller_libev.c.o
/Users/fz/Downloads/onion/src/onion/poller_libev.c:51:25: warning: implicit declaration of function 'onion_low_calloc' is invalid in C99 [-Wimplicit-function-declaration]
        onion_poller_slot *ret=onion_low_calloc(1, sizeof(onion_poller_slot));
                               ^
/Users/fz/Downloads/onion/src/onion/poller_libev.c:51:21: warning: incompatible integer to pointer conversion initializing 'onion_poller_slot *' (aka 'struct onion_poller_slot_t *') with an expression of type 'int' [-Wint-conversion]
        onion_poller_slot *ret=onion_low_calloc(1, sizeof(onion_poller_slot));
                           ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/fz/Downloads/onion/src/onion/poller_libev.c:87:16: warning: incompatible integer to pointer conversion initializing 'onion_poller *' (aka 'struct onion_poller_t *') with an expression of type 'int' [-Wint-conversion]
        onion_poller *ret=onion_low_calloc(1,sizeof(onion_poller));
                      ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/fz/Downloads/onion/src/onion/poller_libev.c:89:2: warning: 'sem_init' is deprecated [-Wdeprecated-declarations]
        sem_init(&ret->sem, 0, 1);
        ^
/usr/include/sys/semaphore.h:55:5: note: 'sem_init' has been explicitly marked deprecated here
int sem_init(sem_t *, int, unsigned int) __deprecated;
    ^
/Users/fz/Downloads/onion/src/onion/poller_libev.c:95:2: warning: implicit declaration of function 'onion_low_free' is invalid in C99 [-Wimplicit-function-declaration]
        onion_low_free(p);
        ^
5 warnings generated.
Linking C shared library libonion.dylib
[ 17%] Built target onion
Scanning dependencies of target onion_static
[ 18%] Building C object src/onion/CMakeFiles/onion_static.dir/onion.c.o
[ 19%] Building C object src/onion/CMakeFiles/onion_static.dir/codecs.c.o
[ 19%] Building C object src/onion/CMakeFiles/onion_static.dir/dict.c.o
/Users/fz/Downloads/onion/src/onion/dict.c:85:15: warning: implicitly declaring library function 'strcasecmp' with type 'int (const char *, const char *)'
    dict->cmp=strcasecmp;
              ^
/Users/fz/Downloads/onion/src/onion/dict.c:85:15: note: include the header <strings.h> or explicitly provide a declaration for 'strcasecmp'
1 warning generated.
[ 20%] Building C object src/onion/CMakeFiles/onion_static.dir/low.c.o
[ 21%] Building C object src/onion/CMakeFiles/onion_static.dir/request.c.o
/Users/fz/Downloads/onion/src/onion/request.c:442:22: warning: implicitly declaring library function 'strcasecmp' with type 'int (const char *, const char *)'
                if (!connection || strcasecmp(connection,"Close")!=0) // Other side wants keep alive
                                   ^
/Users/fz/Downloads/onion/src/onion/request.c:442:22: note: include the header <strings.h> or explicitly provide a declaration for 'strcasecmp'
1 warning generated.
[ 21%] Building C object src/onion/CMakeFiles/onion_static.dir/response.c.o
[ 22%] Building C object src/onion/CMakeFiles/onion_static.dir/handler.c.o
[ 22%] Building C object src/onion/CMakeFiles/onion_static.dir/log.c.o
/Users/fz/Downloads/onion/src/onion/log.c:188:2: warning: implicit declaration of function 'vsyslog' is invalid in C99 [-Wimplicit-function-declaration]
        vsyslog(pri[level], fmt, ap);
        ^
1 warning generated.
[ 23%] Building C object src/onion/CMakeFiles/onion_static.dir/sessions.c.o
[ 24%] Building C object src/onion/CMakeFiles/onion_static.dir/sessions_mem.c.o
[ 24%] Building C object src/onion/CMakeFiles/onion_static.dir/shortcuts.c.o
[ 25%] Building C object src/onion/CMakeFiles/onion_static.dir/block.c.o
[ 26%] Building C object src/onion/CMakeFiles/onion_static.dir/mime.c.o
[ 26%] Building C object src/onion/CMakeFiles/onion_static.dir/url.c.o
[ 27%] Building C object src/onion/CMakeFiles/onion_static.dir/listen_point.c.o
[ 27%] Building C object src/onion/CMakeFiles/onion_static.dir/request_parser.c.o
[ 28%] Building C object src/onion/CMakeFiles/onion_static.dir/http.c.o
[ 29%] Building C object src/onion/CMakeFiles/onion_static.dir/websocket.c.o
/Users/fz/Downloads/onion/src/onion/websocket.c:79:18: warning: implicitly declaring library function 'strcasecmp' with type 'int (const char *, const char *)'
        if (!upgrade || strcasecmp(upgrade,"websocket")!=0)
                        ^
/Users/fz/Downloads/onion/src/onion/websocket.c:79:18: note: include the header <strings.h> or explicitly provide a declaration for 'strcasecmp'
/Users/fz/Downloads/onion/src/onion/websocket.c:98:12: warning: implicitly declaring library function 'alloca' with type 'void *(unsigned long)'
        char *tmp=alloca(length+websocket_magic_13_length+1);
                  ^
/Users/fz/Downloads/onion/src/onion/websocket.c:98:12: note: include the header <stdlib.h> or explicitly provide a declaration for 'alloca'
2 warnings generated.
[ 29%] Building C object src/onion/CMakeFiles/onion_static.dir/ptr_list.c.o
[ 30%] Building C object src/onion/CMakeFiles/onion_static.dir/handlers/static.c.o
[ 31%] Building C object src/onion/CMakeFiles/onion_static.dir/handlers/exportlocal.c.o
/Users/fz/Downloads/onion/src/onion/handlers/exportlocal.c:182:73: warning: format specifies type 'long' but the argument has type 'off_t' (aka 'long long') [-Wformat]
                        onion_response_printf(res, "  ['%s/',%ld,'%s','dir'],\n",fi->d_name, st.st_size, pwd ? pwd->pw_name : "???");
                                                             ~~~                             ^~~~~~~~~~
                                                             %lld
/Users/fz/Downloads/onion/src/onion/handlers/exportlocal.c:184:73: warning: format specifies type 'long' but the argument has type 'off_t' (aka 'long long') [-Wformat]
                        onion_response_printf(res, "  ['%s',%ld,'%s','file'],\n",fi->d_name, st.st_size, pwd ? pwd->pw_name : "???");
                                                            ~~~                              ^~~~~~~~~~
                                                            %lld
2 warnings generated.
[ 31%] Building C object src/onion/CMakeFiles/onion_static.dir/handlers/opack.c.o
[ 32%] Building C object src/onion/CMakeFiles/onion_static.dir/handlers/path.c.o
[ 32%] Building C object src/onion/CMakeFiles/onion_static.dir/handlers/internal_status.c.o
[ 33%] Building C object src/onion/CMakeFiles/onion_static.dir/sessions_sqlite3.c.o
[ 34%] Building C object src/onion/CMakeFiles/onion_static.dir/random-default.c.o
[ 34%] Building C object src/onion/CMakeFiles/onion_static.dir/handlers/webdav.c.o
/Users/fz/Downloads/onion/src/onion/handlers/webdav.c:521:11: warning: implicitly declaring library function 'alloca' with type 'void *(unsigned long)'
        basepath=alloca(pathlen+1);
                 ^
/Users/fz/Downloads/onion/src/onion/handlers/webdav.c:521:11: note: include the header <stdlib.h> or explicitly provide a declaration for 'alloca'
1 warning generated.
[ 35%] Building C object src/onion/CMakeFiles/onion_static.dir/poller_libev.c.o
/Users/fz/Downloads/onion/src/onion/poller_libev.c:51:25: warning: implicit declaration of function 'onion_low_calloc' is invalid in C99 [-Wimplicit-function-declaration]
        onion_poller_slot *ret=onion_low_calloc(1, sizeof(onion_poller_slot));
                               ^
/Users/fz/Downloads/onion/src/onion/poller_libev.c:51:21: warning: incompatible integer to pointer conversion initializing 'onion_poller_slot *' (aka 'struct onion_poller_slot_t *') with an expression of type 'int' [-Wint-conversion]
        onion_poller_slot *ret=onion_low_calloc(1, sizeof(onion_poller_slot));
                           ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/fz/Downloads/onion/src/onion/poller_libev.c:87:16: warning: incompatible integer to pointer conversion initializing 'onion_poller *' (aka 'struct onion_poller_t *') with an expression of type 'int' [-Wint-conversion]
        onion_poller *ret=onion_low_calloc(1,sizeof(onion_poller));
                      ^   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/fz/Downloads/onion/src/onion/poller_libev.c:89:2: warning: 'sem_init' is deprecated [-Wdeprecated-declarations]
        sem_init(&ret->sem, 0, 1);
        ^
/usr/include/sys/semaphore.h:55:5: note: 'sem_init' has been explicitly marked deprecated here
int sem_init(sem_t *, int, unsigned int) __deprecated;
    ^
/Users/fz/Downloads/onion/src/onion/poller_libev.c:95:2: warning: implicit declaration of function 'onion_low_free' is invalid in C99 [-Wimplicit-function-declaration]
        onion_low_free(p);
        ^
5 warnings generated.
Linking C static library libonion_static.a
[ 35%] Built target onion_static
Scanning dependencies of target onion_extras
[ 36%] Building C object src/onion/extras/CMakeFiles/onion_extras.dir/png.c.o
[ 36%] Building C object src/onion/extras/CMakeFiles/onion_extras.dir/jpeg.c.o
Linking C static library libonion_extras.a
[ 36%] Built target onion_extras
Scanning dependencies of target onioncpp
[ 37%] Building CXX object src/bindings/cpp/CMakeFiles/onioncpp.dir/dict.cpp.o
[ 37%] Building CXX object src/bindings/cpp/CMakeFiles/onioncpp.dir/handler.cpp.o
[ 38%] Building CXX object src/bindings/cpp/CMakeFiles/onioncpp.dir/extrahandlers.cpp.o
[ 38%] Building CXX object src/bindings/cpp/CMakeFiles/onioncpp.dir/url.cpp.o
[ 39%] Building CXX object src/bindings/cpp/CMakeFiles/onioncpp.dir/shortcuts.cpp.o
[ 40%] Building CXX object src/bindings/cpp/CMakeFiles/onioncpp.dir/exceptions.cpp.o
Linking CXX shared library libonioncpp.dylib
Undefined symbols for architecture x86_64:
  "_onion_dict_dup", referenced from:
      Onion::render_to_response(std::__1::function<void (onion_dict_t*, onion_response_t*)>, Onion::Dict const&, Onion::Response&) in shortcuts.cpp.o
  "_onion_dict_preorder", referenced from:
      Onion::Dict::operator std::__1::map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::less<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > >() in dict.cpp.o
  "_onion_handler_export_local_new", referenced from:
      Onion::ExportLocal(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in shortcuts.cpp.o
  "_onion_handler_free", referenced from:
      Onion::HandlerCBridge::~HandlerCBridge() in handler.cpp.o
      Onion::HandlerCBridge::~HandlerCBridge() in handler.cpp.o
  "_onion_handler_handle", referenced from:
      Onion::HandlerCBridge::operator()(Onion::Request&, Onion::Response&) in handler.cpp.o
      Onion::Url::operator()(Onion::Request&, Onion::Response&) in url.cpp.o
  "_onion_handler_new", referenced from:
      Onion::onion_handler_cpp_to_c(Onion::Handler) in handler.cpp.o
  "_onion_log", referenced from:
      onion_handler_call_operator(void*, onion_request_t*, onion_response_t*) in handler.cpp.o
  "_onion_response_write", referenced from:
      Onion::Response::ResponseBuf::xsputn(char const*, long) in handler.cpp.o
      Onion::Response::ResponseBuf::overflow(int) in handler.cpp.o
  "_onion_shortcut_internal_redirect", referenced from:
      std::__1::__function::__func<Onion::Shortcuts::internal_redirect(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_1, std::__1::allocator<Onion::Shortcuts::internal_redirect(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_1>, onion_connection_status_e (Onion::Request&, Onion::Response&)>::operator()(Onion::Request&, Onion::Response&) in extrahandlers.cpp.o
  "_onion_shortcut_redirect", referenced from:
      std::__1::__function::__func<Onion::Shortcuts::redirect(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_2, std::__1::allocator<Onion::Shortcuts::redirect(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_2>, onion_connection_status_e (Onion::Request&, Onion::Response&)>::operator()(Onion::Request&, Onion::Response&) in extrahandlers.cpp.o
      Onion::redirect(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, Onion::Request&, Onion::Response&) in shortcuts.cpp.o
      Onion::HttpRedirect::handle(Onion::Request&, Onion::Response&) in exceptions.cpp.o
  "_onion_shortcut_response", referenced from:
      Onion::HttpException::handle(Onion::Request&, Onion::Response&) in exceptions.cpp.o
  "_onion_shortcut_response_file", referenced from:
      std::__1::__function::__func<Onion::Shortcuts::static_file(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0, std::__1::allocator<Onion::Shortcuts::static_file(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)::$_0>, onion_connection_status_e (Onion::Request&, Onion::Response&)>::operator()(Onion::Request&, Onion::Response&) in extrahandlers.cpp.o
  "_onion_url_to_handler", referenced from:
      Onion::Url::operator()(Onion::Request&, Onion::Response&) in url.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [src/bindings/cpp/libonioncpp.0.7.git170.c812b.dirty.dylib] Error 1
make[1]: *** [src/bindings/cpp/CMakeFiles/onioncpp.dir/all] Error 2
make: *** [all] Error 2
davidmoreno commented 9 years ago

Hi,

Can you send me a pull request with the first fix? It looks you have it located and fixed.

For the second part it looks that it needs the strings.h at src/onion/dict.c and src/onion/websocket.c . for the rest I need to look more closely, but looks the same, some header that slightly diferent on Linux and OSX.

I have to access to OSX (and I dont know of any online service to try it, do you know any?), so its very dificult for me to try to fix. I would greatly appreciate a pull request if you manage to solve this problems.

Regards, David.

loggerhead commented 9 years ago

@davidmoreno Sorry, there still remain some little problems even after I fix the first one. Those little things make it diffcult to compatible with OSX, like DT_DIR and RTLD_NODELETE undifined problem, and I can't find any alternative for some of they, so I give up...

anuragagarwal561994 commented 8 years ago

The solution by @loggerhead will remove the PAM support form the build on MacOSX. I looked out for an alternative solution of first finding pam_misc.h, if not found we can go with openpam.h.

I am working on resolving all these errors.

For the

DT_DIR and RTLD_NODELETE undifined problem

There are alternative which will worked in the pull request #191 For DT_DIR, we can using stat and check for IS_DIR and for RTLD_NODELETE we need to define __DARWIN_C_SOURCE