Pete Darrow
Pete Darrow

Reputation: 455

Linking against a specific library version with LDFLAGS

I need to cross compile a program using ncursesw5 and ncursesw6 separately. I'm in Debian Buster which comes with ncursesw6. So I ran apt install libncursesw5:i386 libncursesw5-dev:i386.

Then I attempted to run

./configure --host=i686-linux-gnu "CFLAGS=-m32" "CXXFLAGS=-m32" "LDFLAGS=-m32 /usr/lib/i386-linux-gnu/libncursesw.so.5"

However, when I run ldd ./program I get both libraries.

linux-gate.so.1 (0xf7f8c000)
libncursesw.so.5 => /lib/i386-linux-gnu/libncursesw.so.5 (0xf7e91000)
libncurses.so.6 => /lib/i386-linux-gnu/libncurses.so.6 (0xf7e49000)
libtinfo.so.6 => /lib/i386-linux-gnu/libtinfo.so.6 (0xf7e20000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7c21000)
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xf7c1b000)
libtinfo.so.5 => /lib/i386-linux-gnu/libtinfo.so.5 (0xf7bf6000)
/lib/ld-linux.so.2 (0xf7f8e000)

This is what dpkg sees:

$ dpkg -l | grep curses

ii  libncurses-dev:amd64          6.1+20181013-2+deb10u2      amd64        developer's libraries for ncurses
ii  libncurses-dev:i386           6.1+20181013-2+deb10u2      i386         developer's libraries for ncurses
ii  libncurses5:i386              6.1+20181013-2+deb10u2      i386         shared libraries for terminal handling (legacy version)
ii  libncurses6:amd64             6.1+20181013-2+deb10u2      amd64        shared libraries for terminal handling
ii  libncurses6:i386              6.1+20181013-2+deb10u2      i386         shared libraries for terminal handling
ii  libncursesw5:i386             6.1+20181013-2+deb10u2      i386         shared libraries for terminal handling (wide character legacy version)
ii  libncursesw5-dev:amd64        6.1+20181013-2+deb10u2      amd64        transitional package for libncurses-dev
ii  libncursesw5-dev:i386         6.1+20181013-2+deb10u2      i386         transitional package for libncurses-dev
ii  libncursesw6:amd64            6.1+20181013-2+deb10u2      amd64        shared libraries for terminal handling (wide character support)
ii  libncursesw6:i386             6.1+20181013-2+deb10u2      i386         shared libraries for terminal handling (wide character support)
ii  ncurses-base                  6.1+20181013-2+deb10u2      all          basic terminal type definitions
ii  ncurses-bin                   6.1+20181013-2+deb10u2      amd64        terminal-related programs and man pages
ii  ncurses-term                  6.1+20181013-2+deb10u2      all          additional terminal type definitions

I only can find one set of includes:

$ ls /usr/include/ncurses
ncurses_dll.h  ncurses.h      ncursesw/

Any clues? Thanks

Upvotes: 0

Views: 1302

Answers (1)

Mark
Mark

Reputation: 187

Run ./configure --help as there may be an option for overriding library versions.

If that doesn't yield anything, have a look at Makefile.in, which gets processed into a Makefile by configure. Look for anything related to ncurses. My bet is that there is some variable like NCURSESLIB that you can modify on the command-line when you execute configure, like you did with CFLAGS (ie. ./configure NCURSESLIB=-lncursesw.so.5).

You can also just edit the final Makefile directly. If you search the file for ncursesw you should find something like -lncursesw somewhere. There may be some variable substitution obscuring it (ie. -l$(NCURSES) or NCURSESLIB=-lncursesw), but it will be there somewhere. You will want to change it so that you ultimately get -lncursesw.so.5.

Also, when cross-compiling, one usually should specify the --build parameter as well as --host. The value of --build will be set to the architecture of the workstation doing the compilation. I don't think that has anything to do with your problem though.

Upvotes: 1

Related Questions