vc2010 编译 qrencode
来源:互联网 发布:买家怎么修改淘宝评价 编辑:程序博客网 时间:2024/05/22 13:35
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 了。
这里补充说明几点:
qrencode 本身是不依赖于 libpng 库的。所以不存在什么缺少 png.h 的问题。按照本文介绍的方法按部就班的做就能生成静态库,不存在任何问题。
编译时一定要排除 qrenc.c 这个文件。这个文件是 qrencode 的一个使用例子,与这个库本身无关。
缺少 png.h 或者 缺少 getopt.h 都是在编译 qrenc.c 时才会遇到的问题。与编译 qrencode 无关。如果真的需要编译 qrenc.c,那就先编译 libpng , getopt.h 不是C 标准的头文件,vs 里是没有的,但是网上也可以找到解决办法,随便百度一下就能找到。
- vc2010 编译 qrencode
- VS2010 编译生成 qrencode
- QRencode编译Makefile
- qrencode交叉编译
- VC2010编译boost
- VC2010编译 thrift compiler
- vc2010编译openssl
- vc2010编译boost1.63.0
- qrencode-libqrecode的安装移植和应用-qrencode的交叉编译
- sqlite3.7.9 VC2010编译说明
- sqlite3.7.9 VC2010编译说明
- 编译 boost 1.46 with vc2010
- vc2010编译opencv2.4.6 【1】
- vc2010编译opencv2.4.6 【2】
- vc2010异常编译条件解析
- VC2010 + speex-1.2rc1 编译
- vc2010设置为静态编译
- 在 WINDOWS 下使用 VS2010 编译QRENCODE为lib
- IOS类库
- 补码的原理
- MyEclipse中SVN用户名密码的切换
- Struts2工作原理
- Objective-C:nonatomic关键字(修饰变量,可以提高访问速率)
- vc2010 编译 qrencode
- SQL获取上个月第一天和最后一天的时间写法
- 在MVC4中采用UEditer(百度编辑器)脚本。报错,显示从客户端(<p>2323</p>)中检测到有潜在危险的Request.Form 值的处理办法
- 辛星浅析Linux中的进程基本知识以及fork的简单理解
- c# params
- 深入浅出之C# 串行化与反串行化
- wind7 安装Oracle客户端和pl/sql developer 无法成功连接数据库
- 微信支付之get_brand_wcpay_request:fail_invalid appid
- SSH框架面试题