lunarmodules / luasocket

Network support for the Lua language
http://lunarmodules.github.io/luasocket/
MIT License
1.85k stars 629 forks source link

compilation problem with 2.0.2 (not git-clone) #82

Closed vschiavoni closed 9 years ago

vschiavoni commented 10 years ago

Hello, trying to compile 2.0.2 (latest released archive) on Mac OSX 10.9 on MBP Core i7, I get the following error:

make
cd src; /Applications/Xcode.app/Contents/Developer/usr/bin/make all
gcc  -DLUASOCKET_DEBUG  -pedantic -Wall -O2 -fpic   -c -o luasocket.o luasocket.c
gcc  -DLUASOCKET_DEBUG  -pedantic -Wall -O2 -fpic   -c -o timeout.o timeout.c
gcc  -DLUASOCKET_DEBUG  -pedantic -Wall -O2 -fpic   -c -o buffer.o buffer.c
gcc  -DLUASOCKET_DEBUG  -pedantic -Wall -O2 -fpic   -c -o io.o io.c
gcc  -DLUASOCKET_DEBUG  -pedantic -Wall -O2 -fpic   -c -o auxiliar.o auxiliar.c
gcc  -DLUASOCKET_DEBUG  -pedantic -Wall -O2 -fpic   -c -o options.o options.c
gcc  -DLUASOCKET_DEBUG  -pedantic -Wall -O2 -fpic   -c -o inet.o inet.c
gcc  -DLUASOCKET_DEBUG  -pedantic -Wall -O2 -fpic   -c -o tcp.o tcp.c
gcc  -DLUASOCKET_DEBUG  -pedantic -Wall -O2 -fpic   -c -o udp.o udp.c
gcc  -DLUASOCKET_DEBUG  -pedantic -Wall -O2 -fpic   -c -o except.o except.c
gcc  -DLUASOCKET_DEBUG  -pedantic -Wall -O2 -fpic   -c -o select.o select.c
gcc  -DLUASOCKET_DEBUG  -pedantic -Wall -O2 -fpic   -c -o usocket.o usocket.c
gcc  -O -shared -fpic -o socket.so.2.0.2 luasocket.o timeout.o buffer.o io.o auxiliar.o options.o inet.o tcp.o udp.o except.o select.o usocket.o 
Undefined symbols for architecture x86_64:
  "_luaL_addlstring", referenced from:
      _buffer_meth_receive in buffer.o
  "_luaL_argerror", referenced from:
      _timeout_meth_settimeout in timeout.o
      _buffer_meth_receive in buffer.o
      _auxiliar_checkclass in auxiliar.o
      _auxiliar_checkgroup in auxiliar.o
      _opt_setmembership.constprop.2 in options.o
      _opt_meth_setoption in options.o
      _opt_linger in options.o
      ...
  "_luaL_buffinit", referenced from:
      _buffer_meth_receive in buffer.o
  "_luaL_checkinteger", referenced from:
      _global_skip in luasocket.o
  "_luaL_checklstring", referenced from:
      _buffer_meth_send in buffer.o
      _opt_meth_setoption in options.o
      _inet_global_tohostname in inet.o
      _inet_global_toip in inet.o
      _meth_connect in tcp.o
      _meth_bind in tcp.o
      _meth_setsockname in udp.o
      ...
  "_luaL_checknumber", referenced from:
      _timeout_lua_sleep in timeout.o
      _opt_ip_multicast_ttl in options.o
      _meth_setfd in tcp.o
      _meth_connect in tcp.o
      _meth_bind in tcp.o
      _meth_setfd in udp.o
      _meth_setsockname in udp.o
      ...
  "_luaL_checkudata", referenced from:
      _auxiliar_checkclass in auxiliar.o
      _auxiliar_getclassudata in auxiliar.o
  "_luaL_newmetatable", referenced from:
      _auxiliar_newclass in auxiliar.o
  "_luaL_openlib", referenced from:
      _luaopen_socket_core in luasocket.o
      _timeout_open in timeout.o
      _inet_open in inet.o
      _tcp_open in tcp.o
      _udp_open in udp.o
      _except_open in except.o
      _select_open in select.o
      ...
  "_luaL_optlstring", referenced from:
      _timeout_meth_settimeout in timeout.o
      _buffer_meth_receive in buffer.o
      _meth_shutdown in tcp.o
  "_luaL_optnumber", referenced from:
      _timeout_meth_settimeout in timeout.o
      _buffer_meth_setstats in buffer.o
      _buffer_meth_send in buffer.o
      _meth_listen in tcp.o
      _meth_setpeername in udp.o
      _meth_receivefrom in udp.o
      _meth_receive in udp.o
      ...
  "_luaL_prepbuffer", referenced from:
      _buffer_meth_receive in buffer.o
  "_luaL_pushresult", referenced from:
      _buffer_meth_receive in buffer.o
  "_luaL_typerror", referenced from:
      _auxiliar_checkboolean in auxiliar.o
      _opt_setmembership.constprop.2 in options.o
      _opt_linger in options.o
  "_lua_call", referenced from:
      _getfd in select.o
      _global_select in select.o
  "_lua_createtable", referenced from:
      _auxiliar_newclass in auxiliar.o
      _inet_pushresolved in inet.o
      _inet_open in inet.o
      _finalize in except.o
      _make_assoc in select.o
      _global_select in select.o
  "_lua_error", referenced from:
      _luaopen_socket_core in luasocket.o
      _auxiliar_tostring in auxiliar.o
      _protected_ in except.o
      _finalize in except.o
  "_lua_getfield", referenced from:
      _auxiliar_add2group in auxiliar.o
      _auxiliar_setclass in auxiliar.o
  "_lua_getmetatable", referenced from:
      _auxiliar_tostring in auxiliar.o
      _auxiliar_getgroupudata in auxiliar.o
  "_lua_gettable", referenced from:
      _auxiliar_tostring in auxiliar.o
      _opt_setmembership.constprop.2 in options.o
      _opt_linger in options.o
      _protected_ in except.o
      _return_fd in select.o
      _make_assoc in select.o
      _getfd in select.o
      ...
  "_lua_gettop", referenced from:
      _global_skip in luasocket.o
      _buffer_meth_send in buffer.o
      _buffer_meth_receive in buffer.o
      _inet_pushresolved in inet.o
      _protected_ in except.o
      _finalize in except.o
      _make_assoc in select.o
      ...
  "_lua_insert", referenced from:
      _protected_ in except.o
      _finalize in except.o
  "_lua_isnumber", referenced from:
      _buffer_meth_setstats in buffer.o
      _buffer_meth_receive in buffer.o
      _opt_linger in options.o
      _getfd in select.o
  "_lua_isstring", referenced from:
      _auxiliar_tostring in auxiliar.o
      _opt_setmembership.constprop.2 in options.o
  "_lua_newuserdata", referenced from:
      _global_create in tcp.o
      _meth_accept in tcp.o
      _global_create in udp.o
  "_lua_pcall", referenced from:
      _protected_ in except.o
      _finalize in except.o
  "_lua_pushboolean", referenced from:
      _luaopen_socket_core in luasocket.o
      _auxiliar_add2group in auxiliar.o
      _meth_dirty in tcp.o
      _meth_dirty in udp.o
  "_lua_pushcclosure", referenced from:
      _auxiliar_newclass in auxiliar.o
      _global_protect in except.o
      _global_newtry in except.o
  "_lua_pushfstring", referenced from:
      _auxiliar_tostring in auxiliar.o
  "_lua_pushlstring", referenced from:
      _meth_receivefrom in udp.o
      _meth_receive in udp.o
  "_lua_pushnil", referenced from:
      _buffer_meth_send in buffer.o
      _buffer_meth_receive in buffer.o
      _opt_set.isra.0 in options.o
      _inet_global_tohostname in inet.o
      _inet_global_toip in inet.o
      _inet_global_gethostname in inet.o
      _inet_meth_getpeername in inet.o
      ...
  "_lua_pushnumber", referenced from:
      _timeout_lua_gettime in timeout.o
      _timeout_meth_settimeout in timeout.o
      _buffer_meth_getstats in buffer.o
      _buffer_meth_setstats in buffer.o
      _buffer_meth_send in buffer.o
      _buffer_meth_receive in buffer.o
      _opt_set.isra.0 in options.o
      ...
  "_lua_pushstring", referenced from:
      _luaopen_socket_core in luasocket.o
      _buffer_meth_send in buffer.o
      _buffer_meth_receive in buffer.o
      _auxiliar_newclass in auxiliar.o
      _auxiliar_tostring in auxiliar.o
      _auxiliar_add2group in auxiliar.o
      _auxiliar_getgroupudata in auxiliar.o
      ...
  "_lua_pushvalue", referenced from:
      _buffer_meth_receive in buffer.o
      _protected_ in except.o
      _finalize in except.o
      _make_assoc in select.o
      _getfd in select.o
      _collect_fd.part.0 in select.o
      _global_select in select.o
      ...
  "_lua_rawget", referenced from:
      _auxiliar_getgroupudata in auxiliar.o
  "_lua_rawset", referenced from:
      _luaopen_socket_core in luasocket.o
      _auxiliar_newclass in auxiliar.o
      _auxiliar_add2group in auxiliar.o
  "_lua_replace", referenced from:
      _buffer_meth_receive in buffer.o
  "_lua_setmetatable", referenced from:
      _auxiliar_setclass in auxiliar.o
  "_lua_settable", referenced from:
      _inet_pushresolved in inet.o
      _inet_open in inet.o
      _finalize in except.o
      _return_fd in select.o
      _make_assoc in select.o
      _collect_fd.part.0 in select.o
      _global_select in select.o
      ...
  "_lua_settop", referenced from:
      _auxiliar_newclass in auxiliar.o
      _auxiliar_add2group in auxiliar.o
      _auxiliar_getgroupudata in auxiliar.o
      _global_newtry in except.o
      _finalize in except.o
      _make_assoc in select.o
      _getfd in select.o
      ...
  "_lua_toboolean", referenced from:
      _auxiliar_checkboolean in auxiliar.o
      _opt_linger in options.o
      _finalize in except.o
      _global_select in select.o
  "_lua_tolstring", referenced from:
      _auxiliar_tostring in auxiliar.o
      _opt_setmembership.constprop.2 in options.o
  "_lua_tonumber", referenced from:
      _buffer_meth_setstats in buffer.o
      _buffer_meth_receive in buffer.o
      _opt_linger in options.o
      _getfd in select.o
  "_lua_touserdata", referenced from:
      _auxiliar_tostring in auxiliar.o
      _auxiliar_getgroupudata in auxiliar.o
  "_lua_type", referenced from:
      _auxiliar_tostring in auxiliar.o
      _auxiliar_checkboolean in auxiliar.o
      _auxiliar_getgroupudata in auxiliar.o
      _opt_setmembership.constprop.2 in options.o
      _opt_linger in options.o
      _global_newtry in except.o
      _protected_ in except.o
      ...
  "_lua_typename", referenced from:
      _auxiliar_checkboolean in auxiliar.o
      _opt_setmembership.constprop.2 in options.o
      _opt_linger in options.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make[1]: *** [socket.so.2.0.2] Error 1
make: *** [all] Error 2

This is my gcc:

%gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/local/libexec/gcc/x86_64-apple-darwin12/4.6.3/lto-wrapper
Target: x86_64-apple-darwin12
Configured with: ../gcc-4.6.3/configure --prefix=/opt/local --build=x86_64-apple-darwin12 --enable-languages=c,c++,objc,obj-c++,lto,fortran --libdir=/opt/local/lib/gcc46 --includedir=/opt/local/include/gcc46 --infodir=/opt/local/share/info --mandir=/opt/local/share/man --datarootdir=/opt/local/share/gcc-4.6 --with-local-prefix=/opt/local --with-libiconv-prefix=/opt/local --with-system-zlib --disable-nls --program-suffix=-mp-4.6 --with-gxx-include-dir=/opt/local/include/gcc46/c++/ --with-gmp=/opt/local --with-mpfr=/opt/local --with-mpc=/opt/local --with-ppl=/opt/local --with-cloog=/opt/local --enable-cloog-backend=isl --disable-cloog-version-check --enable-stage1-checking --disable-multilib --enable-lto --enable-libstdcxx-time --with-as=/opt/local/bin/as --with-ld=/opt/local/bin/ld --with-ar=/opt/local/bin/ar --with-bugurl=https://trac.macports.org/newticket --disable-ppl-version-check --with-pkgversion='MacPorts gcc46 4.6.3_9'
Thread model: posix
gcc version 4.6.3 (MacPorts gcc46 4.6.3_9)
vschiavoni commented 10 years ago

I've found the problem. The default configuration in the included config file assumes Linux. By modifying lines 43-47 of the makefile, it compiles just fine.

vschiavoni commented 10 years ago

The remaining problem remains related to these warnings:

buffer.c: In function 'buffer_meth_send':
buffer.c:83:15: warning: unused variable 'tm' [-Wunused-variable]
buffer.c: In function 'buffer_meth_receive':
buffer.c:114:15: warning: unused variable 'tm' [-Wunused-variable]