0

I have seen Passing "-no-undefined" to Libtool LDFLAG ; and I tried everything there, and unfortunately I cannot get it to work.

Here is my problem: I'm trying to build liblo under Cygwin64. All I did was:

wget http://downloads.sourceforge.net/liblo/liblo-0.31.tar.gz
tar xzvf liblo-0.31.tar.gz
cd liblo-0.31
./configure
make

Compile passes without a problem, then the linking stage comes, and I get:

  CCLD     liblo.la
libtool:   error: can't build x86_64-unknown-cygwin shared library unless -no-undefined is specified
make[3]: *** [Makefile:728: liblo.la] Error 1

Here is the Makefile.am; I've tried inserting there:

AM_LIBTOOLFLAGS = -no-undefined
AM_LDFLAGS = -no-undefined

... and then running:

automake
./configure
make

... but that does not help, I get the same error.

Note that there could be extra confusion here: as per stunnel build chokes on -no-undefined - Cygwin-apps mailing list:

There is the GNU ld flag --no-undefined (two dashes), and there's the libtool flag -no-undefined (one dash). They are not the same, and spelling out -no-undefined does not make libtool feed --no-undefined to the linker. Nor does libtool look for -Wl,--no-undefined. -Wl,-no-undefined seems to be some confused hybrid.

So, how/where do I add this -no-undefined switch in this project?

sdbbs
  • 4,270
  • 5
  • 32
  • 87

2 Answers2

0

Eh, so I looked in the Makefile, tried to look up all possible *FLAGS and set them, finally I noticed there is an LDFLAGS = line in it - and I simply tried:

make LDFLAGS=-no-undefined

... and linking passed - which I find strange, because I see this as a direct contradiction of the quote posted in the OP ?!

Well, anyways - if anyone has a more straightforward technique for how this should be handled, feel free to post - this was just trial and error ...

sdbbs
  • 4,270
  • 5
  • 32
  • 87
  • The behavior you describe does not conflict with the quote in the question. Libtool will see the flags expressed in `LDFLAGS`, which is what was needed, and the quotatoin does not say anything to the contrary. I'm glad you managed to get it to work! – John Bollinger Oct 02 '21 at 01:57
0

The diagnostic you present is from Libtool, asking you to pass it its -no-undefined option. So how does one do that?

In a build involving Libtool, the libtool executable is run at multiple stages of the build, including, but not limited to, both compiling and linking. When it is invoked, it gets the full set of flags for that build stage, and it chooses from among those the flags that are meaningful specifically to it. Although Automake also provides LIBTOOLFLAGS and AM_LIBTOOLFLAGS, these are for so-called generic options, as opposed to mode-specific options. This is discussed in the Automake manual.

So, how/where do I add this -no-undefined switch in this project?

Since Libtool's -no-undefined is a link-mode option, one of the LDFLAGS variables is the right way to convey it. If you are just trying to build the project, not maintain its build system, then LDFLAGS is the one among them designated as a user variable. The autotooling should not be adding any flags to it, as its whole purpose to serve as a vehicle for the builder to convey extra linker flags, which is exactly what you want to do.

And specifying a value for that variable on the configure or make command line is the right way to do that. I haven't enough details to determine why the other things you tried were unsuccessful, but you ended up coming down in exactly the right place with

make LDFLAGS=-no-undefined

From your self-answer, that seems to have come as a surprise to you. I guess that arises from a misunderstanding about the meaning and implications of the comments you quoted. Yes, the --no-undefined option to ld and the -no-undefined option to libtool are separate, independent options. Yes, the latter does not imply the former. So what? The latter is the one you want, so you just specify it. And if you wanted the former, then you would specify that. The point of the quoted remarks is that you need to take care to use the correct spelling for the one you want, or to give both if you want both. That has nothing to do with which Automake variable is appropriate for conveying those flags.

John Bollinger
  • 160,171
  • 8
  • 81
  • 157