New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: can't build i686-pc-cygwin shared library unless -no-undefined is specified #243

macjabeth opened this Issue Mar 10, 2016 · 2 comments


None yet
3 participants

macjabeth commented Mar 10, 2016

Hello. I'm trying to build luaposix on my WIndows machine using the Babun terminal (which uses cygwin). When it gets to the make file, it fails with the above error. I uploaded the entire log to Pastebin... Any ideas?


This comment has been minimized.


gvvaughan commented Mar 10, 2016

Hi Jonathan,

Yes. From

Some platforms, such as Windows, do not even allow you this flexibility. In order to build a shared library, it must be entirely self-contained or it must have dependencies known at link time (that is, have references only to symbols that are found in the .lo files or the specified ‘-l’ libraries), and you need to specify the -no-undefined flag. By default, libtool builds only static libraries on these kinds of platforms.

You'll also hit this issue from

This option should be used if the package has been ported to build clean dlls on win32 platforms. Usually this means that any library data items are exported with __declspec(dllexport) and imported with __declspec(dllimport). If this macro is not used, libtool will assume that the package libraries are not dll clean and will build only static libraries on win32 hosts.

Provision must be made to pass -no-undefined to libtool in link mode from the package Makefile. Naturally, if you pass -no-undefined, you must ensure that all the library symbols really are defined at link time!

You can try running ./configure as normal and then running make LDFLAGS=-no-undefined to pass that flag to libtool link-mode, however the Makefile is designed for Unix style linkers where it's possible to make a shared module that has references to symbols from the shared lua library that are not resolved at compile time, but by the dynamic loader as the application loads libraries. I expect passing -no-undefined will complain that all the liblua symbols are undefined. You might be try to add -llua too, though I have no idea whether that will work (it might, but the binary format and DLL rules on Windows are weird and confusing, so it might not). Some people create stub libraries to satisfy the missing symbols, where the stub functions will look up the real symbol in the target DLL at runtime and call that. I understand there might also be some magic you can perform with linker scripts.

Another, easier, way is to proceed is to statically link a custom lua binary with luaposix sources preloaded. That will be much easier to get working, but doesn't help much if you were hoping for a runtime loadable luaposix.dll.

Once you've fought your way through that minefield, please be aware luaposix makes no attempt to patch-up missing or buggy POSIX API implementations in the host library though, so I would be (pleasantly) surprised to hear that luaposix is even approaching well behaved with cygwin if you get it all to build and run.


@gvvaughan gvvaughan closed this Mar 10, 2016

@gvvaughan gvvaughan added the won't fix label Mar 10, 2016


This comment has been minimized.

cxw42 commented Jun 20, 2017

@gvvaughan Thanks for the tip on the LDFLAGS!

Here's what worked for me, for the benefit of future readers.

Edit This was for version 33.4.0-1, which is current on as of writing. I could not get posix.ctype to work on my Cygwin install, so I switched to 34.0 from github. See below.

  1. luarocks download luaposix

  2. luarocks unpack luaposix

    You will get a message similar to:

    You may now enter directory
    and type 'luarocks make' to build.
  3. cd luaposix-33.4.0-1/luaposix-release-v33.4.0 (or whatever directory it told you)

  4. Edit the .rockspec file in that directory, e.g., luaposix-33.4.0-1.rockspec

  5. In the build section, edit the build_command string. Where it says

    ./configure <lots of stuff> && make clean install

    change that to

    ./configure <all the same stuff> && make LDFLAGS='-no-undefined -llua' clean install
  6. Run luarocks make.

  7. You should (eventually) see something like luaposix 33.4.0-1 is now installed in /usr/local (license: MIT/X11).

  8. To double-check, run luarocks show luaposix


  1. luarocks install ldoc, luarocks install luacrypto

  2. git clone this repo and cd into the top-level directory.

  3. git checkout release-v34.0

  4. in luaposix-34.0-1.rockspec, after the LIBFLAG line (line 33), add

    .. ' LIBS="-llua"'
  5. Update ext/posix/sys/socket.c per commit 9c853de. E.g., git checkout 9c853de -- ext/posix/sys/socket.c.

  6. From the top of the repo, luarocks make. (It will automatically use the rockspec in that directory.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment