How can I fix this error when making vim on Fedora 23

2.2k Views Asked by At

I am trying to build vim with the following options on my Fedora 23

I want +python +python3 +perl +lua +ruby +gui +conceal +gui for some plugins.

I could not find a version with all those built in (so I do it myself)

The journey started by following Valloric

sudo yum install -y ruby ruby-devel lua lua-devel luajit \
    luajit-devel ctags git python python-devel \
    python3 python3-devel tcl-devel \
    perl perl-devel perl-ExtUtils-ParseXS \
    perl-ExtUtils-XSpp perl-ExtUtils-CBuilder \
    perl-ExtUtils-Embed

I also have ncurses (raw,devel,static,...)

Then

$ cd $HOME/Sources
$ git clone https://github.com/vim/vim.git
$ cd vim
$ ./configure --with-tlib=ncurses \
              --with-features=huge \
              --enable-fail-if-missing \
              --enable-luainterp=yes \
              --enable-mzschemeinterp \
              --enable-perlinterp \
              --enable-pythoninterp=yes \
              --with-python-config-dir=/usr/lib64/python2.7/config \
              --enable-python3interp=yes \
              --enable-tclinterp=yes \
              --enable-rubyinterp=yes \
              --enable-cscope \
              --enable-multibyte \
              --enable-gui=auto \
              --prefix=$HOME/Build/vim \
              --with-compiledby=statquant | tee configure.log

The following is printed on screen:

/home/statquant/Sources/vim/src/config-PyMake3137:1478: warning: overriding recipe for target 'Modules/_math.o'
/home/statquant/Sources/vim/src/config-PyMake3137:1475: warning: ignoring old recipe for target 'Modules/_math.o'
/home/statquant/Sources/vim/src/config-PyMake3137:1517: warning: overriding recipe for target 'Modules/timemodule.o'
/home/statquant/Sources/vim/src/config-PyMake3137:1482: warning: ignoring old recipe for target 'Modules/timemodule.o'
configure: error: NOT FOUND!
      You need to install a terminal library; for example ncurses.
      Or specify the name of the library with --with-tlib.

Then I

make | tee make.log

I realized that it actually built vim in $HOME/Sources/vim/src instead of $HOME/Build/vim (maybe I was wrong to expect that)

When I run :version on ./vim -g (vim has been build with GUI support) there is NO python NO python3 .... enter image description here

configure.log is there, make.log is there

EDIT1: the following works, I now only miss +perl +ruby

./configure --with-features=huge \
       --enable-tclinterp=yes \
       --enable-luainterp=yes \
       --enable-pythoninterp=yes \
       --enable-python3interp=yes \
       --with-compiledby=statquant \
       --prefix=$HOME/Build/vim \

make install # and yes it installs in $HOME/Build/vim  

enter image description here

EDIT2 Here is what happen when I try to add

  1. +perl

I can run

./configure --with-features=huge \
            --enable-tclinterp=yes \
            --enable-luainterp=yes \
            --enable-pythoninterp=yes \
            --enable-python3interp=yes \
            --enable-perlinterp=yes \
            --prefix=$HOME/Build/vim \
            --with-compiledby=statquant | tee configure.log

It appears to work (no error) : configure.log

make | tee make.log
[...]
cc1: error: -Wformat-security ignored without -Wformat [-Werror=format-security]
<command-line>:0:0: warning: "_FORTIFY_SOURCE" redefined
<command-line>:0:0: note: this is the location of the previous definition
cc1: some warnings being treated as errors
make[1]: *** [objects/option.o] Error 1
Makefile:2907: recipe for target 'objects/option.o' failed
make[1]: Leaving directory '/home/statquant/Sources/vim/src'
make: *** [first] Error 2
Makefile:26: recipe for target 'first' failed

I get no vim built in /home/statquant/Sources/vim/src : make.log

  1. +ruby

    ./configure --with-features=huge \ --enable-tclinterp=yes \ --enable-luainterp=yes \ --enable-pythoninterp=yes \ --enable-python3interp=yes \ --enable-rubyinterp=yes \ --prefix=$HOME/Build/vim \ --with-compiledby=statquant | tee configure.log

It does not even run configure

checking --with-tlib argument... empty: automatic terminal library selection
checking for tgetent in -ltinfo... no
checking for tgetent in -lncurses... no
checking for tgetent in -ltermlib... no
checking for tgetent in -ltermcap... no
checking for tgetent in -lcurses... no
no terminal library found
checking for tgetent()... configure: error: NOT FOUND!
      You need to install a terminal library; for example ncurses.
      Or specify the name of the library with --with-tlib.

Here is the log: configure.log

5

There are 5 best solutions below

5
On BEST ANSWER

Ok... so here's the thing. VIM is one of those programs that has a huge amount of patches, Fedora enforces some security checks at GCC level that won't allow you to build it (easily) from source code, my advice: rebuild the source rpm, is not that hard:

Install required dependencies to rebuild VIM

These packages are required for you to build VIM within F23

sudo dnf install gtk2-devel ncurses-devel lua-devel perl-devel perl-ExtUtils-Embed perl-ExtUtils-ParseXS perl-ExtUtils-XSpp perl-ExtUtils-CBuilder python-devel python3-devel tcl-devel ruby-devel 

Install racket repository

I see you are passing the --enable-mzschemeinterp flag which requires racket, which is not included on the official repos.

cat >/etc/yum.repos.d/rpm-sphere.repo <<EOF
[rpm-sphere]
name=RPM Sphere
baseurl=http://download.opensuse.org/repositories/home:/zhonghuaren/Fedora_23/
gpgkey=http://download.opensuse.org/repositories/home:/zhonghuaren/Fedora_23/repodata/repomd.xml.key
enabled=1
gpgcheck=1
EOF

Install RPM developer tools:

These are required to install the tools to build/rebuild rpms

sudo dnf install @development-tools
sudo dnf install fedora-packager
sudo dnf install rpmdevtools

Setup your RPM build root

Create a file on your home folder called rpmmacros like so:

vim ~/.rpmmacros

Add the following contents to it:

%_topdir    /home/statquant/Src/rpm

Then create the folder /home/statquant/Src/rpm

Create RPM build necessary folders

You need to have these folders so the source code and spec files are stored when you install the source rpm:

mkdir -p ~/Src/rpm
cd ~/Src/rpm
mkdir BUILD RPMS SOURCES SPECS SRPMS
mkdir RPMS/{noarch,x86,x86_64}

Download VIM source RPM:

dnf dnl --source vim

This will download the source rpm to the current folder, say vim-7.4.1718-1.fc23.src.rpm

Once it has been downloaded, install it:

rpm -ivh vim-7.4.1718-1.fc23.src.rpm

Once installed the RPM should have created the file /home/statquant/Src/rpm/SPECS/vim.spec open this file.

Modify configure options

You'll see that the SPEC file has the configure options and the make commands to build the actual thing. This file is huge and it has a lot of patches. You can go ahead and modify the areas where the configure command is, there are 3:

  • One for vim minimal
  • One for vim enhanced
  • One for the GUI version of vim

Make sure you modify accordingly. I did a test build with your options. You can download my SPEC file here, and vim, vim-enhanced and gvim worked just fine.

Rebuild the RPM

Once you modified (or copied from my template) the spec file you want to build the RPM based of that spec, go to /home/statquant/Src/rpm and then:

rpmbuild -ba SPECS/vim.spec

It will take a while, after that, you should see some ouput saying that the packages were built successfully, in my case:

Checking for unpackaged file(s): /usr/lib/rpm/check-files /home/gustavo/Src/rpm/BUILDROOT/vim-7.4.1718-1.fc23.x86_64
Wrote: /home/gustavo/Src/rpm/SRPMS/vim-7.4.1718-1.fc23.src.rpm
Wrote: /home/gustavo/Src/rpm/RPMS/x86_64/vim-common-7.4.1718-1.fc23.x86_64.rpm
Wrote: /home/gustavo/Src/rpm/RPMS/x86_64/vim-minimal-7.4.1718-1.fc23.x86_64.rpm
Wrote: /home/gustavo/Src/rpm/RPMS/x86_64/vim-enhanced-7.4.1718-1.fc23.x86_64.rpm
Wrote: /home/gustavo/Src/rpm/RPMS/x86_64/vim-filesystem-7.4.1718-1.fc23.x86_64.rpm
Wrote: /home/gustavo/Src/rpm/RPMS/x86_64/vim-X11-7.4.1718-1.fc23.x86_64.rpm
Wrote: /home/gustavo/Src/rpm/RPMS/x86_64/vim-debuginfo-7.4.1718-1.fc23.x86_64.rpm
Executing(%clean): /bin/sh -e /var/tmp/rpm-tmp.tNsBuH
+ umask 022
+ cd /home/gustavo/Src/rpm/BUILD
+ cd vim74
+ rm -rf /home/gustavo/Src/rpm/BUILDROOT/vim-7.4.1718-1.fc23.x86_64
+ exit 0

Install the new version

So now you have the packages built following fedora recommendations and patches, you can just go ahead and reinstall them (in case you already have the default fedora vim version which is probably true) like so:

cd /home/statquant/Src/rpm/RPMS/x86_64/
sudo dnf reinstall ./vim-common-7.4.1718-1.fc23.x86_64.rpm
sudo dnf reinstall ./vim-enhanced-7.4.1718-1.fc23.x86_64.rpm
etc...

Please note the dot and slash meaning that dnf is trying to install a local package instead of searching through its database which would download the versions you already have.

Notes

Out of security concern I did not uploaded my custom-built packages but if you don't mind or want to try them out ping me and I can upload them so you save yourself all this hassle... I already had all RPM build tools because I build some for me here.

You may also want to create a COPR repository so that you automate this process and if you need to format your disk, reinstall fedora, install it on a new machine etc. you can just add the repository and use dnf to install your custom package.

If you have any other questions let me know, good luck!

Update there are comments in the spec file beginning with # options for so you can jump to the actual configure options

0
On

There is now a Vim issue filed about this: https://github.com/vim/vim/issues/1081

I'm using a work-around that I mentioned in a comment to that issue: https://github.com/vim/vim/issues/1081#issuecomment-269920486

I've copied most of that comment below in case it may be helpful.

I ran into this problem on Fedora 25 (x86_64). Vim's configure script asks ruby about LDFLAGS without a corresponding query regarding CFLAGS: https://github.com/vim/vim/blob/v8.0.0134/src/auto/configure#L7174

rubyldflags=`$vi_cv_path_ruby -r rbconfig -e "print $ruby_rbconfig::CONFIG['LDFLAGS']"`

Since Fedora 23, all RPMs have been "hardened" by default: https://fedoraproject.org/wiki/Changes/Harden_All_Packages

When an RPM is built, the %configure macro used in the RPM SPEC file is automatically adjusted to provide CFLAGS, LDFLAGS, and several other environment variables using hardened settings. When using Fedora's ruby package, the above query using rbconfig returns hardened linker flags. Because Vim's configure script doesn't use a corresponding rbconfig to query ruby's CFLAGS, the compiling and linking flags are mismatched, leading to the error:

configure: error: NOT FOUND!
      You need to install a terminal library; for example ncurses.
      Or specify the name of the library with --with-tlib.

In src/auto/config.log, this mismatch of flags causes this error:

configure:11318: checking for tgetent in -lncurses
configure:11343: gcc -o conftest -g -O2  -L. -Wl,-z,relro -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector -rdynamic -Wl,-export-dynamic -Wl,--enable-new-dtags -Wl,-z,relro    -L/usr/local/lib conftest.c -lncurses   -lselinux  >&5
/usr/bin/ld: /tmp/cckpDslF.o: relocation R_X86_64_PC32 against undefined symbol `tgetent' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

I can successfully build with a work-around, but I don't know enough about autoconf to suggest a proper fix to the configure script. The work-around involves first installing some RPM-related packages:

sudo dnf install -y rpm-build redhat-rpm-config

Next, set these variables at the shell prompt via:

eval $(rpmbuild --eval '%{configure}' | egrep '^\s*[A-Z]+=')

The above uses rpmbuild --eval '%{configure}' to query the definition of the %configure macro which begins with a number of environment variable assignments. This provides the same default compilation environment that is provided in the %configure macro. Now running the below invocation succeeds:

./configure --quiet --with-features=huge --enable-rubyinterp
1
On

You have enabled -Werror=format-security. This treats any susceptible usage of format of printf or scanf currently treated as `error.

You can either fix the usage in if_perl.c, I believe this is generated file. or remove the flag -Werror=format-security

1
On

The python problem was this...

--with-python-config-dir=/usr/lib64/python2.7/config \
--enable-python3interp=yes \

Version 2 config with a version 3 interpreter.

Your missing the ncurses-devel library, I can see that you dropped it from configure.

sudo yum install ncurses-devel

configure actually worked for me even when I didn't have the perl dev packages installed ie it didn't fail asking me to install them which I found odd. Do you have all the dev packages you need installed.

sudo yum install perl-devel
sudo yum install ruby-devel
2
On

If you are missing some dev package for ruby or perl the configure script say something like : "disabling this option". Just did this with ruby. After installing the ruby-dev package the ruby option is enabled in vim. Same with libperl-dev.