简体   繁体   English

在OSX上编译Z3

[英]Compiling Z3 on a OSX

I am trying to compile Z3 version 4.1.2. 我正在尝试编译Z3版本4.1.2。 AFter a successful configuration, when you do "make", I get the following error: 在成功配置后,当您执行“make”时,我收到以下错误:

Makefile:151: lib.srcs: No such file or directory
Makefile:152: shell.srcs: No such file or directory
Makefile:153: test.srcs: No such file or directory
Making test.srcs...
/usr/local/bin/dos2unix takes only stdin and stdout
make: *** [test.srcs] Error 1

I think the problem is that all textual files in z3-src-4.1.2.zip use "carriage return" (cr) and "line feed" (lf) for encoding line termination. 我认为问题是z3-src-4.1.2.zip中的所有文本文件z3-src-4.1.2.zip使用“回车”(cr)和“换行”(lf)来编码行终止。 The zip was created on a Windows machine. 该zip是在Windows机器上创建的。 Another problem is the "dos2unix" application. 另一个问题是“dos2unix”应用程序。 It is an application that converts windows/dos textual files into unix/linux/osx textual files. 它是一个将windows / dos文本文件转换为unix / linux / osx文本文件的应用程序。 It is a very simple application. 这是一个非常简单的应用程序。 It just replaces cr/lf with a lf. 它只是用一个lf替换cr / lf。 On Linux, this application takes a single argument: the file name to be modified. 在Linux上,此应用程序采用单个参数:要修改的文件名。

I'm currently working on a new build system that avoids this issues. 我目前正在开发一个新的构建系统,可以避免这个问题。 In the meantime, here a some workarounds. 与此同时,这里有一些解决方法。

1) Use git to retrieve the source. 1)使用git检索源。 git will take care of the cr/lf vs lf issue. git将负责cr / lf vs lf问题。 Here is the command for retrieving Z3: 这是检索Z3的命令:

git clone https://git01.codeplex.com/z3 git clone https://git01.codeplex.com/z3

If you do that, you don't need to use dos2unix. 如果这样做,则不需要使用dos2unix。 So, you can remove the lines @$(DOS2UNIX) in Makefile.in. 因此,您可以在Makefile.in中删除@ $(DOS2UNIX)行。 Another option is to replace DOS2UNIX=@D2U@ with DOS2UNIX=touch in the beginning of Makefile.in 另一种选择是在Makefile.in的开头用DOS2UNIX = touch替换DOS2UNIX = @ D2U @

After these changes, you should be able to compile it on OSX. 完成这些更改后,您应该能够在OSX上编译它。 I successfully compiled it on OSX 10.7. 我在OSX 10.7上成功编译了它。

2) Get the "unstable" branch. 2)获得“不稳定”分支。

http://z3.codeplex.com/SourceControl/changeset/view/946a06cddbe4 http://z3.codeplex.com/SourceControl/changeset/view/946a06cddbe4

This is the current "working branch". 这是目前的“工作分支”。 It contains the new build system. 它包含新的构建系统。 It is not ready, but it is good enough to generate the Z3 executable. 它没有准备好,但它足以生成Z3可执行文件。 Here are the instructions to build Z3 using this branch 以下是使用此分支构建Z3的说明

Download the code from the page above. 从上面的页面下载代码。 Or use git to retrieve the "unstable" branch. 或者使用git来检索“不稳定”分支。 Then, execute 然后,执行

   autoconf
   ./configure
   python scripts/mk_make.py
   cd build
   make

I managed to compile it on OSX 10.7 last Friday. 我上周五设法在OSX 10.7上编译它。

3) Keep the .zip, but convert all textual files. 3)保留.zip,但转换所有文本文件。 I'm using the following python script to convert all files in the new build system. 我正在使用以下python脚本来转换新构建系统中的所有文件。 If you execute this python script in the Z3 root directory, it will convert all files. 如果在Z3根目录中执行此python脚本,它将转换所有文件。

import os
import glob
import re
import getopt
import sys
import shutil

def is_cr_lf(fname):
    # Check whether text files use cr/lf
    f = open(fname, 'r')
    line = f.readline()
    sz = len(line)
    return sz >= 2 and line[sz-2] == '\r' and line[sz-1] == '\n'

# dos2unix in python
#    cr/lf --> lf
def dos2unix(fname):
    if is_cr_lf(fname):
        fin  = open(fname, 'r')
        fname_new = '%s.new' % fname
        fout = open(fname_new, 'w')
        for line in fin:
            line = line.rstrip('\r\n')
            fout.write(line)
            fout.write('\n')
        fin.close()
        fout.close()
        shutil.move(fname_new, fname)
        if is_verbose():
            print "dos2unix '%s'" % fname

def dos2unix_tree_core(pattern, dir, files):
    for filename in files:
        if fnmatch(filename, pattern):
            fname = os.path.join(dir, filename)
            if not os.path.isdir(fname):
                dos2unix(fname)

def dos2unix_tree():
    os.path.walk('.', dos2unix_tree_core, '*')

dos2unix_tree()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM