如何使用Visual Studio编译libtasn1?

时间:2015-01-12 10:02:38

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

我是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(C和inline static在C ....中无效时)的几个头文件语句中,inline static上的C2054会出现更多重大错误。 / p>

我放弃了这里,并尝试通过输入“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文件中找到...

2 个答案:

答案 0 :(得分:0)

我正在运行ubuntu linux 14.04

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

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

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

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

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

几分钟后,一切都成功执行了

答案 1 :(得分:0)

您是否尝试过windows子目录中的.sln文件?

  

这显然有用

这里的关键词是“显然”。运行configure时,它会检查构建环境并创建适合该环境的makefile。由于您使用Cygwin的sh.exe运行configure,因此它为Cygwin环境创建了一个makefile(请参阅Host type:和Compiler:values)。因此即使configure创建了缺失的config.h,内容也适用于使用GCC的Cygwin,而不是具有MSVC的Windows。

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

对于MinGW,你尝试过使用windows / libtasn14win.mk吗?

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

您可能希望在help-libtasn1邮件列表中找到有关如何创建Windows二进制文件的提示。很明显,Windows构建比其他libtasn1受到的关注更少。