Skip to content

library not found for -lX11

19 messages · Brian Ripley, Jakson A. Aquino, Berend Hasselman +3 more

#
Hi,

I submitted a package to CRAN:
http://cran.r-project.org/web/packages/vimcom/index.html

It builds on Linux without warnings, but there is the following error
on Mac OS X:

    ld: library not found for -lX11
    collect2: ld returned 1 exit status
    make: *** [vimcom.so] Error 1
    ERROR: compilation failed for package 'vimcom'

The complete log is here:
http://www.r-project.org/nosvn/R.check/r-release-macosx-ix86/vimcom-00install.html

I know that I have to edit the src/Makevars file, but I don't know
what I should put there and I don't have access to any machine running
Mac OS X to make tests. Any help will be appreciated.

Thanks,
#
On Wed, Nov 28, 2012 at 9:38 PM, Jakson Alves de Aquino
<jalvesaq at gmail.com> wrote:
I've found this:
http://stackoverflow.com/questions/5841008/problem-in-linking-x11-in-mac-os-x

So, it seems that a Makevars file with the following content would
solve the problem:

PKG_LIBS=-L/usr/X11/lib -lX11

I would be grateful if someone could try to build the package with the
above change in the src/Makevars since, as I have said, I can't make
tests.

Thanks,
#
Works for me after additionally setting PKG_CPPFLAGS to point to the headers in Makevars

PKG_LIBS=-L/usr/X11/lib -lX11 
PKG_CPPFLAGS=-I/usr/X11/include
On Nov 29, 2012, at 12:18 , Jakson Alves de Aquino <jalvesaq at gmail.com> wrote:

            
#
On Thu, Nov 29, 2012 at 8:43 AM, jochen laubrock
<jochen.laubrock at gmail.com> wrote:
I added PKG_CFLAGS because the code is in C.

I'm grateful to Jochen Laubrock for finding the solution and for
Federico Calboli for doing additional tests. The updated code is
available at:

https://github.com/jalvesaq/VimCom

Best regards,
#
But those paths should not be used unconditionally (as you have).  They 
are not right for most x86_64 Linux, Solaris, ... and they might not 
even be right on Mac OS X (depending on the X installation).

And PKG_CPPFLAGS was correct: that means flags for cpp, the C 
pre-processor, not for C++ (which is macro PKG_CXXFLAGS).  See 'Writing 
R Extensions'.
On 29/11/2012 12:39, Jakson Alves de Aquino wrote:

  
    
#
On Thu, Nov 29, 2012 at 10:05 AM, Prof Brian Ripley
<ripley at stats.ox.ac.uk> wrote:
Sorry, but I don't known how to find the correct path at compile time.
Thanks for the information. I'll fix it.
#
On 29/11/2012 13:23, Jakson Alves de Aquino wrote:
Use a configure script: see 'Writing R Extensions' (and see how R itself 
does it).

  
    
#
On Thu, Nov 29, 2012 at 10:26 AM, Prof Brian Ripley
<ripley at stats.ox.ac.uk> wrote:
Thanks for the suggestion! I adapted the code from cairoDevice
package. It was just a matter of replacing gtk with x11 and I hope
that now it will build on any unix that have X installed.

    https://github.com/jalvesaq/VimCom/

Best regards,
#
On 29-11-2012, at 17:16, Jakson Alves de Aquino wrote:

            
Using Mac OS X 10.6.8 and R version 2.15.2 (2012-10-26)

Experiment 1
----------------
[.../vimcom]: R CMD check vimcom-master
* using log directory '/Users/berendhasselman/Documents/Programming/R/pkgsrc/vimcom/vimcom-master.Rcheck'
* using R version 2.15.2 (2012-10-26)
* using platform: x86_64-apple-darwin9.8.0 (64-bit)
* using session charset: UTF-8
* checking for file 'vimcom-master/DESCRIPTION' ... OK
* this is package 'vimcom' version '0.9-5'
* checking package namespace information ... OK
* checking package dependencies ... ERROR
Package suggested but not available: 'knitr'

The suggested packages are required for a complete check.
Checking can be attempted without them by setting the environment
variable _R_CHECK_FORCE_SUGGESTS_ to a false value.

Experiment 2
----------------
[.../vimcom]: export _R_CHECK_FORCE_SUGGESTS_=0
[.../vimcom]: R CMD check vimcom-master
* using log directory '/Users/berendhasselman/Documents/Programming/R/pkgsrc/vimcom/vimcom-master.Rcheck'
* using R version 2.15.2 (2012-10-26)
* using platform: x86_64-apple-darwin9.8.0 (64-bit)
* using session charset: UTF-8
* checking for file 'vimcom-master/DESCRIPTION' ... OK
* this is package 'vimcom' version '0.9-5'
* checking package namespace information ... OK
* checking package dependencies ... NOTE
Package suggested but not available for checking: 'knitr'
* checking if this is a source package ... OK
* checking if there is a namespace ... OK
* checking for executable files ... OK
* checking whether package 'vimcom' can be installed ... ERROR
Installation failed.
See '/Users/berendhasselman/Documents/Programming/R/pkgsrc/vimcom/vimcom-master.Rcheck/00install.out' for details.

Contents .../00install.out

* installing *source* package 'vimcom' ...
checking for pkg-config... no
ERROR: Cannot find pkg-config.
ERROR: configuration failed for package 'vimcom'
* removing '/Users/berendhasselman/Documents/Programming/R/pkgsrc/vimcom/vimcom-master.Rcheck/vimcom'


Install experiment
-------------------------
[.../vimcom]: R CMD INSTALL vimcom-master
* installing to library '/Users/berendhasselman/Library/R/2.15/library'
* installing *source* package 'vimcom' ...
checking for pkg-config... no
ERROR: Cannot find pkg-config.
ERROR: configuration failed for package 'vimcom'
* removing '/Users/berendhasselman/Library/R/2.15/library/vimcom'

pkg-config is not available standard on Mac OS X.
It is probably available on the Mac binary package machine.

I don't think you may assume that an X11 installation on Mac OS X has been registered with pkg-config or how you call that.

Your method is not foolproof.
Experts will have to enlighten you.

Berend
#
On 29 Nov 2012, at 16:49, Berend Hasselman <bhh at xs4all.nl> wrote:

            
well I do have pkg-config (from MacPorts):

$ which pkg-config
/opt/local/bin/pkg-config

which is in my $PATH

$ echo $PATH
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/julia:/usr/local/MacGPG/bin:/usr/texbin

additionally 

$ pkg-config --exists x11

exits without saying/doing anything, which I presume means all is ok, as by Unix tradition.  Unfortunately I do have the same issue:

* installing *source* package ?vimcom? ...
checking for pkg-config... no
ERROR: Cannot find pkg-config.
ERROR: configuration failed for package ?vimcom?

I am not clear why pkg-config should not be successfully called by the build.

BW

F



--
Federico C. F. Calboli
Neuroepidemiology and Ageing Research
Imperial College, St. Mary's Campus
Norfolk Place, London W2 1PG

Tel +44 (0)20 75941602   Fax +44 (0)20 75943193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] gmail.com
#
On Thu, Nov 29, 2012 at 1:49 PM, Berend Hasselman <bhh at xs4all.nl> wrote:
You can also install the 'knitr' package.
pkg-config is an application that knows what should be the values of
CPPFLAGS and LIBS. Sorry, but I don't know how you can get it
correctly installed on Mac OS X.
You are right, and I'm waiting for the experts advice!

Thanks for testing!
#
Just a guess, but maybe XCode and its command line tools need to be installed?


Am 29.11.2012 um 18:09 schrieb Jakson Alves de Aquino <jalvesaq at gmail.com>:
#
On 29 Nov 2012, at 17:29, Jochen <jochen.laubrock at gmail.com> wrote:

            
I don't know for third parties, but I do have the latest XCode + command line tools installed (and I would need them for MacPorts in the first place).  As by my previous email that's obviously not enough.

BW

F
--
Federico C. F. Calboli
Neuroepidemiology and Ageing Research
Imperial College, St. Mary's Campus
Norfolk Place, London W2 1PG

Tel +44 (0)20 75941602   Fax +44 (0)20 75943193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] gmail.com
#
On 29/11/2012 17:37, Federico Calboli wrote:
Correct, pkg-config is not part of Xcode.  It is also not a good way to 
find out where X11 is.  I did suggest following R, not a randomly chosen 
package for a different piece of software (GTK+, sic).

As ever, this is covered in the R manuals, which it seems none of you 
have the courtesy to read.  Search for pkg-config in 'Writing R Extensions'.

  
    
#
On 29 Nov 2012, at 17:49, Prof Brian Ripley <ripley at stats.ox.ac.uk> wrote:

            
As I am not the package author (I just volunteered to test if it builds on OS X, and in particular on a machine that does have pkg-config installed through MacPorts) I fail to see why *I* should have to courtesy to read the manual.

BW

F
--
Federico C. F. Calboli
Neuroepidemiology and Ageing Research
Imperial College, St. Mary's Campus
Norfolk Place, London W2 1PG

Tel +44 (0)20 75941602   Fax +44 (0)20 75943193

f.calboli [.a.t] imperial.ac.uk
f.calboli [.a.t] gmail.com
#
On 29-11-2012, at 18:49, Prof Brian Ripley wrote:

            
I have read the R manuals.
I have looked at R's configure script.
I looked at the source of the cairoDevice package and the vimcom package.
And decided that what the OP had made would not work on Mac OS X.
Which I demonstrated.

The OP will have to look at the relevant sections of R's configure script. Very clever but too difficult for me.
I will happily test for the OP to see if the package will install out of the box.
And not more than that.

Berend
#
On Nov 28, 2012, at 7:38 PM, Jakson Alves de Aquino wrote:

            
The issue is not Mac specific at all. A couple points: you cannot assume X11 because R can be built with or without X11 - in fact most recent OS X comes without X11 so requiring it may limit the availability of your package. If you really require X11 you'll have to declare that in your DESCRIPTION file. Furthermore, R doesn't expose X11 flags to packages so you'll have to write a configure test to determine proper X1 flags for your package. Just adding -lX11 to Makevars doesn't work. See the autoconf documentation - there are typically tests for X11 that can be re-used (R uses them, too). This may also require special flags depending on the configuration (autoconf provides --x-libraries and --x-includes for that). I don't know what you really need - ideally, you should make any X11 code conditional on the availability of X11 --  I don't know whether that is a basic requirement for your package or not, so how to proceed from here may depend on that.

Cheers,
Simon
#
I wrote this post yesterday but for some reason it did not leave the outbox, so apologies to everyone since a mailer glitch apparently failed to prevent the waste of time of quite a few people. To follow up on the post - the autoconf macros to look for are AC_PATH_X and AC_PATH_XTRA.

Cheers,
Simon
On Nov 29, 2012, at 3:42 PM, Simon Urbanek <simon.urbanek at r-project.org> wrote:

            
#
On Thu, Nov 29, 2012 at 5:55 PM, Simon Urbanek
<simon.urbanek at r-project.org> wrote:
Thank you! I updated the package using AC_PATH_EXTRA in the
configure.ac. To make it easier for people who are helping testing
the package and who don't use git, I also put the package here:

   http://www.lepem.ufc.br/jaa/vimcom_0.9-5.tar.gz

The vimcom package allows R to send messages to Vim text editor. I
need the messages to automatically update the Object Browser.
On Unix, Vim receives the messages through X11 and it seems that this
feature is available on Mac OS X too:

   http://stackoverflow.com/questions/10231223/compile-vim-7-3-with-clientserver-feature-on-mac-os-x

Best regards,

Jakson