Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
mattetti opened this issue Dec 26, 2012 · 16 comments
Closed

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

mattetti opened this issue Dec 26, 2012 · 16 comments

Comments

@mattetti
Copy link

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
Copy link
Contributor

Readme is updated. Pls try again, Matt. Thanks

@mattetti
Copy link
Author

$ 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
Copy link
Contributor

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

@darccio
Copy link

darccio commented Jan 26, 2013

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

@acron0
Copy link

acron0 commented Jun 4, 2013

This also occurs on Windows

@mdayaram
Copy link
Contributor

mdayaram commented Jun 4, 2013

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

@acron0
Copy link

acron0 commented Jun 4, 2013

No, it remained unfixed :(

@mdayaram
Copy link
Contributor

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

@vampirewalk
Copy link

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

@elviejo79
Copy link

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
Copy link
Contributor

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

@allochi
Copy link

allochi commented Dec 6, 2013

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
Copy link

lacco commented Jan 15, 2014

@allochi 's tip solved the problem, thx!

@damomurf
Copy link

damomurf commented Oct 8, 2014

@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,
...

@chuckhutchinson2
Copy link

fyi - I had this problem to and needed to brew install pkg-config

See https://github.com/lestrrat/go-libxml2/issues/23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

12 participants