0

I am trying to build and install the OpenFst library on windows10 using MINGW64 with Msys but i got the following error during the building with make. I first used this command:

 ./configure --enable-grm --enable-far --enable-ngram-fsts MAKE="mingw32-make"

some of the checking results from this command generates no:

checking whether we are cross compiling... no
checking for sysroot... no
checking for a working dd... ./configure: line 7016: cmp: command not found
./configure: line 7016: cmp: command not found
checking for mt... no
checking if : is a manifest tool... no
checking for unistd.h... no
checking if gcc supports -fno-rtti -fno-exceptions... ./configure: line 8930: diff: command `not found`
checking whether to build static libraries... no

The other checking results are ok and yes. Then I used the make command:

mingw32-make

it works for some files then terminated by that error:

libtool:   error: can't build x86_64-w64-mingw32 shared library unless -no-undefined is 
specified

It is my first time to build with MinGW. So, I do not know what the error means and if the resulting "no" checking from the configuration responsible for it.

Mai Daly
  • 73
  • 6
  • Does `diff` command work? You might need to install it. Also, you should be using `make` instead of `mingw32-make`. – HolyBlackCat Sep 16 '21 at 19:54
  • @HolyBlackCat No, diff not working. and also make not working but "mingw32-make" make the same job. what is the difference between them? – Mai Daly Sep 16 '21 at 20:06
  • `make` is a full-fledged Make (uses MSYS2's Cygwin fork). `mingw32-make` is an attempt to port Make to Windows without Cygwin, it uses `cmd` instead of `sh` as the shell, and since most makefiles don't expect it, not all of them work with it. Last time I tried it, it was also fairly buggy. – HolyBlackCat Sep 16 '21 at 20:11
  • *"diff not working. and also make not working"* You need to install both. – HolyBlackCat Sep 16 '21 at 20:12
  • @HolyBlackCat I installed both of them and used make instead of `mingw32-make` but the error still appears. – Mai Daly Sep 16 '21 at 20:18
  • `cmp` also seems to be missing. Are there any other errors when running `./configure`? – HolyBlackCat Sep 16 '21 at 20:20
  • @HolyBlackCat no, no errors issued during the `./configure` – Mai Daly Sep 16 '21 at 20:30
  • To confirm, it doesn't say "not found" about any other commands? What happens if you re-run `./configure` after installing `cmp`? – HolyBlackCat Sep 16 '21 at 20:32

1 Answers1

4

This is normal.

MinGW does not allow building shared libraries (DLLs) when there are still unresolved symbols, because on Windows each symbol referenced from a DLL must point to something that exists. On other platforms this is not always required.

So you should pass to -Wl,-no-undefined to gcc when linking.

For projects using autoconf's configure this is normally already done if it was a recent enough version of autoconf. Otherwise you may need to add LDFLAGS="-Wl,-no-undefined" to the configure line. If that doesn't help you can try to change it in the libtool file generated by configure.

So specicially you can try this in MSYS/MSYS2 shell:

./configure LDFLAGS="-Wl,-no-undefined"

and if that doesn't work you can also try this (after the configure command and before running make):

sed -i.bak -e "s/\(allow_undefined=\)yes/\1no/" libtool

Other build tools like cmake, meson or scons already know how to build Windows DLLs and need no special treatment.

Brecht Sanders
  • 6,215
  • 1
  • 16
  • 40