---
title: "static building lxml"
author: "mathgl"
date: "2014-08-13T19:15:36Z"
tags: []
categories: ["编程语言"]
slug: "static-building-lxml"
draft: false
lastmod: "2014-08-13T19:16:21Z"
id: 2103658
url: "https://mathgl.iteye.com/blog/2103658"
---

well  it is not really straightforward..

 

when building with static deps like python setup.py build --static\_deps

 

you may see two possible errors

 

1: when you saw crc iconv.xx error, you can modify buildlibxml.py

 

check def download\_libiconv and change 

version\_re = re.compile(r'^libiconv-(\[0-9.]+\[0-9]).tar.gz$')

as

version\_re = re.compile(r'^libiconv-(1.14).tar.gz$')

 

2: importing lxml.etree sometimes may experience "undefined symbol clock\_gettime"

 

the reason is some gcc version (4.6.x) may fail to link librt properly, so you can edit 

setupinfo.py

find 

def libraries()

add rt like:

libs = \['z', 'm', 'rt']

 

it can solve the problem.