首页 > Web开发 > 详细

vc2010 编译 qrencode

时间:2015-03-26 13:03:50      阅读:310      评论:0      收藏:0      [点我收藏+]

qrencode 是一个生成QR 二维码的开源库,用法很简单,但是没有提供在vs 系统下编译的项目文件,所以在win下使用不太方便。为此,我研究了一下,搞定了用 VC 2010 编译生成静态库的方法。

 

建立一个 win32 项目,选择生成静态库,不使用预编译头。

将 qrencode 的源文件(.c 和 .h)全部拷到vc 的项目目录中,除了 qrenc.c 。

 

编译 qrencode 时还需要有个 config.h 文件,这个文件是 configure 时自动生成的,可以用我下面提供的这个。

 

/* config.h.  Generated from config.h.in by configure.  */
/* config.h.in.  Generated from configure.ac by autoheader.  */

/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1

/* Define to 1 if using pthread is enabled. */
#undef HAVE_LIBPTHREAD

/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1

/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1

/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1

/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1

/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1

/* Define to 1 if you have the `strdup' function. */
#define HAVE_STRDUP 1

/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1

/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1

/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1


/* Major version number */
#define MAJOR_VERSION 3

/* Micro version number */
#define MICRO_VERSION 4

/* Minor version number */
#define MINOR_VERSION 4

/* Name of package */
#define PACKAGE "qrencode"

/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""

/* Define to the full name of this package. */
#define PACKAGE_NAME "QRencode"

/* Define to the full name and version of this package. */
#define PACKAGE_STRING "QRencode 3.4.4"

/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "qrencode"

/* Define to the home page for this package. */
#define PACKAGE_URL ""

/* Define to the version of this package. */
#define PACKAGE_VERSION "3.4.4"

/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1

/* Version number of package */
#define VERSION "3.4.4"

#define inline

/* Define to 'static' if no test programs will be compiled. */
#define __STATIC static
/* #undef WITH_TESTS */
   


然后在项目属性中添加预处理定义:HAVE_CONFIG_H

 技术分享

这里有一点需要解释一下,config.h 中有一行:

#define inline

 

之所以要这么写是因为rscode.c 文件中有个modnn的定义如下:

 

static inline int modnn(RS *rs, int x){
	while (x >= rs->nn) {
		x -= rs->nn;
		x = (x >> rs->mm) + (x & rs->nn);
	}
	return x;
}

 

这个代码在vc2010中无法编译通过,去掉 inline 就可以顺利编译通过了。

所以才要写:

#define inline


然后编译就可以生成 qrencode.lib 了。

vc2010 编译 qrencode

原文:http://blog.csdn.net/liyuanbhu/article/details/44647139

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!