【问题标题】:How do you compile libtasn1 with Visual Studio?如何使用 Visual Studio 编译 libtasn1?
【发布时间】:2015-01-12 10:02:37
【问题描述】:

我是 libtasn1 的新用户(尝试将此库与 google 的 protobuf 进行基准测试)....实际上是在尝试成为新用户....

我无法让这个库在 Windows 下编译(使用 Visual Studio 2010)。

从这里下载最新版本(4.2):http://ftp.gnu.org/gnu/libtasn1/ 然后,我从 Visual Studio 2010 命令提示符运行 configure(必须先安装 Cygwin 才能拥有 sh.exe、ar.exe....)。这显然有效并输出:

  version:          4.2 shared 9:2:3
  Host type:        i686-pc-cygwin
  Install prefix:   /usr/local
  Compiler:         gcc -std=gnu99
  Warning flags:    errors:  warnings:
  Library types:    Shared=yes, Static=yes
  Valgrind:
  Version script:   yes

现在,我无法继续构建。这是我尝试过的:

打开 zip 中提供的 libtasn1.sln。第一个错误报告 config.h 未找到(+ 其他头文件)。更新包含路径后,我在编译 ASN1.c 时在一些头文件语句中出现了更多重大错误,例如 inline static 上的 C2054(这是 C 和 inline static 在 C 中无效......)。

我放弃了这里并尝试通过键入“nmake”直接从 Visual 命令提示符进行编译。很短,马上就出错了:

Microsoft (R) Program Maintenance Utility Version 10.00.30319.01
Copyright (C) Microsoft Corporation. Tous droits réservés.

makefile(269) : fatal error U1001: erreur de syntaxe : caractère non conforme '{' dans la macro
Stop.

最后,我尝试使用 MinGW 进行编译(使用 mingw32-make.exe)。同样的事情,马上就出错了:

process_begin: CreateProcess(NULL, /usr/bin/sed -n s/^\(sc_[a-zA-Z0-9_-]*\):.*/\
1/p ./maint.mk ./cfg.mk, ...) failed.
'test' n'est pas reconnu en tant que commande interne
ou externe, un programme exécutable ou un fichier de commandes.
make  all-recursive
process_begin: CreateProcess(NULL, make all-recursive, ...) failed.
make (e=2): Le fichier spécifié est introuvable.
Makefile:928: recipe for target 'all' failed
mingw32-make.exe: *** [all] Error 2

libtasn1 网站说:

该代码应适用于所有 Unix 操作系统和 Windows。

好的,但是如何构建它?我在网站上找不到任何信息,在 INSTALL 文件中也找不到...

【问题讨论】:

    标签: c++ c visual-studio-2010 compilation asn.1


    【解决方案1】:

    你试过windows子目录下的.sln文件吗?

    这显然有效

    这里的关键词是“显然”。当您运行configure 时,它会检查构建环境并创建一个适合该环境的makefile。由于您使用 Cygwin 的 sh.exe 运行配置,因此它为 Cygwin 环境创建了一个生成文件(请参阅主机类型:和编译器:值)。因此,即使 configure 创建了缺失的 config.h,内容也适合带有 GCC 的 Cygwin,而不适合带有 MSVC 的 Windows。

    configure 创建 GNU make 和许多其他 Unix-y make 程序可以理解的 makefile。微软的 nmake(当我最后一次看到它时)理解一种更加有限且不兼容的语言。您不能将configure 创建的makefile 与nmake 一起使用。

    对于 MinGW,您是否尝试过使用 windows/libtasn14win.mk ?

    注意:在 libtasn1 的 GNU FTP 站点上,最新的 Windows 二进制文件适用于 3.3 版 :(

    您可能希望在 help-libtasn1 邮件列表中获取有关如何创建 Windows 二进制文件的提示。很明显,Windows 构建受到的关注少于 libtasn1 的其余部分。

    【讨论】:

      【解决方案2】:

      我正在运行 ubuntu linux 14.04

      我使用您的链接下载了最新的 ...gz 文件

      我使用了一个实用程序将文件解压缩到../Downloads/libtasn1/,它生成了几十个子目录和文件

      我打开了一个普通的命令窗口 cd 到主目录:../Downloads/libtasn1/libtasn1-4.2 然后我读取了该目录中的几个文件。 其中一个文件表明我应该输入: ./configure && make && make install

      我按照指示做了。结果是某些受保护的目录不允许插入新文件

      我打开了一个根命令窗口 cd 到主目录:../Downloads/libtasn1/libtasn1-4.2 然后输入: ./configure && make && make install

      几分钟后,一切顺利执行

      【讨论】:

      • 你在 Windows 或 Ubuntu 下试过吗?
      猜你喜欢
      • 1970-01-01
      • 2017-04-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多