Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

can't seem to easily build on OS X #14

Closed
mattetti opened this Issue · 15 comments
@mattetti

The README is obviously outdated since the makefile is gone, but I still didn't manage to build/install on Mountain Lion:

https://gist.github.com/4383203

I installed libxml2 from homebrew, updated the xpath import statement to reflect the path of the brew files.
Tried to build and go some error.

An updated readme would be very appreciated since this lib seems very useful.

Thanks,

  • Matt
@zhigangc

Readme is updated. Pls try again, Matt. Thanks

@mattetti
$ go get github.com/moovweb/gokogiri
# pkg-config --cflags libxml-2.0 libxml-2.0
Package libxml-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libxml-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libxml-2.0' found
Package libxml-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libxml-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libxml-2.0' found
exit status 1

I have the system libxml installed as well as the homebrew version. I tried to set PKG_CONFIG_PATH but didn't manage to get passed this issue.

@zhigangc

Yes, thanks for the reminder. Neither the system nor the brew version supports pkg-config. And it creates even more issues to give the absolute path in the source code.

You can use this repo: https://github.com/zhigangc/libxml2-2.7.8

This is 2.7.8 with a few minor changes: add pkg-config support and comment out some unnecessary checks.

Or you can add pkg-config manually to your existing installation as follows:

You should use the brew version of libxml2, and should NOT use the system version.

  1. You need to verify that your pkg-config is in your local bin as

/usr/local/bin/pkg-config

  1. Usually libxml2 is installed at

/usr/local/Cellar/libxml2/2.7.8

You need to create a dir

/usr/local/Cellar/libxml2/2.7.8/lib/pkgconfig

  1. In the pkgconfig dir, you should have the file: libxml-2.0.pc, and its content as

prefix=/usr/local/Cellar/libxml2/2.7.8
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include
modules=1

Name: libXML
Version: 2.7.8
Description: libXML library version2.
Requires:
Libs: -L${libdir} -lxml2
Libs.private: -lpthread -lz -liconv -lm
Cflags: -I${includedir}/libxml2

Note if your installation is not at /usr/local/Cellar/libxml2/2.7.8, you need to change the prefix properly.

  1. Then you need to create a symbolic link

sudo ln -s /usr/local/Cellar/libxml2/2.7.8/lib/pkgconfig/libxml-2.0.pc /usr/local/lib/pkgconfig/libxml-2.0.pc

  1. At last, verify if you have it with pkg-config

pkg-config --libs libxml-2.0

You should have something like

-L/usr/local/Cellar/libxml2/2.7.8/lib -lxml2

@imdario

Homebrew's libxml-2.0 2.8.0 has pkgconfig support. For anyone coming here for answers, you only need to do the final steps:

  1. Create symbolic link.

    sudo ln -s /usr/local/Cellar/libxml2/2.8.0/lib/pkgconfig/libxml-2.0.pc \
    /usr/local/lib/pkgconfig/libxml-2.0.pc
  2. Check with pkg-config:

    pkg-config --cflags libxml-2.0 libxml-2.0

I got this as result: -I/usr/local/Cellar/libxml2/2.8.0/include/libxml2

@zhigangc zhigangc closed this
@acron0

This also occurs on Windows

@mdayaram

Did the steps outlined above help fix the issues in windows?

@acron0

No, it remained unfixed :(

@mdayaram

@acron0 could you open a new github issue describing the trouble you're having when building on windows?

@vampirewalk

This issue happened on my linux mint, too. After installing libxml2-dev, issue solved.

@chomsky

Solved using imdario strategy on OSX (though libxml2 is now version 2.91)

@elviejo79

As @vampirewalk said installing libxml2-dev solves the issue:

$ sudo apt-get install libxml2-dev
$ go get github.com/moovweb/gokogiri

on ubuntu 12.04

@mdayaram

Yup, I'll make note of it in the readme.

@allochi

Ok, after really long suffer, and trying everything on the internet I finally successfully compiled everything on OS X 10.9 Mavericks this way

brew install apple-gcc42 
export CC=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2
brew install libxml2
sudo ln -s /usr/local/Cellar/libxml2/2.9.1/lib/pkgconfig/libxml-2.0.pc /usr/local/lib/pkgconfig/libxml-2.0.pc
go get github.com/moovweb/gokogiri

AHHHHH! sorry, I have been trying this the whole day!

Thanks for everyone who shared their hints.

@lacco

@allochi 's tip solved the problem, thx!

@damomurf

@allochi 's process doesn't work for me in Mavericks 10.9.5, I get the following errors:

# github.com/moovweb/gokogiri/help
In file included from /private/tmp/src/github.com/moovweb/gokogiri/help/help.go:6:
/usr/local/Cellar/libxml2/2.9.1/include/libxml2/libxml/tree.h:15:19: error: stdio.h: No such file or directory
In file included from /usr/local/Cellar/libxml2/2.9.1/include/libxml2/libxml/tree.h:16,
                 from /private/tmp/src/github.com/moovweb/gokogiri/help/help.go:6:
/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/../lib/gcc/i686-apple-darwin11/4.2.1/include/limits.h:10:25: error: limits.h: No such file or directory
In file included from /usr/local/Cellar/libxml2/2.9.1/include/libxml2/libxml/parser.h:810,
                 from /usr/local/Cellar/libxml2/2.9.1/include/libxml2/libxml/globals.h:18,
                 from /usr/local/Cellar/libxml2/2.9.1/include/libxml2/libxml/threads.h:35,
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.