C++ 如何使用Visual Studio编译libtasn1?

C++ 如何使用Visual Studio编译libtasn1?,c++,c,visual-studio-2010,compilation,asn.1,C++,C,Visual Studio 2010,Compilation,Asn.1,我是libtasn1的新用户(试图根据谷歌的protobuf对这个库进行基准测试)……实际上,我正在尝试成为一个新用户 我无法使此库在Windows下编译(使用Visual Studio 2010) 从以下位置下载最新版本(4.2): 然后,我从VisualStudio2010命令提示符运行了configure(必须先安装Cygwin才能拥有sh.exe、ar.exe…)。这显然起到了作用并输出了: version: 4.2 shared 9:2:3 Host type

我是libtasn1的新用户(试图根据谷歌的protobuf对这个库进行基准测试)……实际上,我正在尝试成为一个新用户

我无法使此库在Windows下编译(使用Visual Studio 2010)

从以下位置下载最新版本(4.2): 然后,我从VisualStudio2010命令提示符运行了
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(+其他头文件)。更新include path后,我在编译ASN1.c时,在一些头文件语句中出现了更严重的错误,如
inline static
上的C2054(这是c,而
inline static
在c中无效)

我放弃了这里,试图通过键入“nmake”直接从可视命令提示符编译。它很短,立即出现错误:

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.
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
最后,我尝试使用MinGW(使用mingw32 make.exe)进行编译。同样的事情,马上就出现了一个错误:

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


好的,但是如何构建它呢?我在网站上或安装文件中找不到任何信息…

我正在运行ubuntu linux 14.04

我用你的链接下载了最新的…gz文件

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

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

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

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


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

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

这显然奏效了

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

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

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

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


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

您在windows或Ubuntu下尝试过吗?