在用cocos2d-x3.2 + protobuf编译Android项目的时候,protobuf出现了两个问题:

1. 首先是config.h找不到,查阅自后说是通过命令或工具生成的,里面的内容根据不同平台是不一样的(引用一些用到的库,例如hash_map,hash_set等,和部分宏定义),那么就要在自己手动生成,或者自己创建一个空的config,自己把一些引用到的库加进去,为了能快速编译通过,我就自己创建了一个config.h,没有引用任何库。

#ifndef _LINUX_CONFIG_H
#define _LINUX_CONFIG_H #endif

然后找不到config.h的问题解决了。

2.  然后是error "No suitable threading library available."

定位到common.cc文件中

#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN // We only need minimal includes
#include <windows.h>
#define snprintf _snprintf // see comment in strutil.cc
#elif defined(HAVE_PTHREAD)
#include <pthread.h>
#else
#error "No suitable threading library available."
#endif

发现是找不到HAVE_PTHREAD宏定义,导致没有引用pthread库,直接用#include <pthread.h>替换#error "No suitable threading library available."这句代码,又会导致其他文件找不到;那么可能其它地方也引用了HAVE_PTHREAD宏,那这个宏是protobuf库根据不同平台定义的呢,还是该我们自己加呢,如果是自己加又应该加在哪里呢?

联想到config文件找不到的问题,猜到可能是config文件中缺少一些代码,看来不能用空的config,那么就直接在config.h中加上 #define HAVE_PTHREAD 即可。

#ifndef _LINUX_CONFIG_H
#define _LINUX_CONFIG_H #define HAVE_PTHREAD #endif

之后编译通过。。。

如果是有完美强迫症的、或者要求高效率(使用hash_map/unordered_map等),那么就在linux上用configure生成一个config.h吧,下面附上一个完整生成的:

/* config.h.  Generated from config.h.in by configure.  */
/* config.h.in. Generated from configure.ac by autoheader. */ /* the name of <hash_map> */
#define HASH_MAP_CLASS hash_map /* the location of <unordered_map> or <hash_map> */
#define HASH_MAP_H <ext/hash_map> /* the namespace of hash_map/hash_set */
#define HASH_NAMESPACE std::tr1 /* the name of <hash_set> */
#define HASH_SET_CLASS hash_set /* the location of <unordered_set> or <hash_set> */
#define HASH_SET_H <ext/hash_set> /* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1 /* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1 /* Define to 1 if you have the `ftruncate' function. */
#define HAVE_FTRUNCATE 1 /* define if the compiler has hash_map */
#define HAVE_HASH_MAP 1 /* define if the compiler has hash_set */
#define HAVE_HASH_SET 1 /* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1 /* Define to 1 if you have the <limits.h> header file. */
#define HAVE_LIMITS_H 1 /* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1 /* Define to 1 if you have the `memset' function. */
#define HAVE_MEMSET 1 /* Define to 1 if you have the `mkdir' function. */
#define HAVE_MKDIR 1 /* Define if you have POSIX threads libraries and header files. */
#define HAVE_PTHREAD 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 `strchr' function. */
#define HAVE_STRCHR 1 /* Define to 1 if you have the `strerror' function. */
#define HAVE_STRERROR 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 `strtol' function. */
#define HAVE_STRTOL 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 /* Enable classes using zlib compression. */
/* #undef HAVE_ZLIB */ /* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#define LT_OBJDIR ".libs/" /* Name of package */
#define PACKAGE "protobuf" /* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "protobuf@googlegroups.com" /* Define to the full name of this package. */
#define PACKAGE_NAME "Protocol Buffers" /* Define to the full name and version of this package. */
#define PACKAGE_STRING "Protocol Buffers 2.5.0" /* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "protobuf" /* Define to the home page for this package. */
#define PACKAGE_URL "" /* Define to the version of this package. */
#define PACKAGE_VERSION "2.5.0" /* Define to necessary symbol if this constant uses a non-standard name on
your system. */
/* #undef PTHREAD_CREATE_JOINABLE */ /* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1 /* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# define _ALL_SOURCE 1
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# define _GNU_SOURCE 1
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# define _POSIX_PTHREAD_SEMANTICS 1
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# define _TANDEM_SOURCE 1
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# define __EXTENSIONS__ 1
#endif /* Version number of package */
#define VERSION "2.5.0" /* Define to 1 if on MINIX. */
/* #undef _MINIX */ /* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
/* #undef _POSIX_1_SOURCE */ /* Define to 1 if you need to in order for `stat' and other things to work. */
/* #undef _POSIX_SOURCE */

  

cocos2d-x, protobuf, no config.h, #error "No suitable threading library available."的更多相关文章

  1. React Native 'config.h' file not found 问题、 'glog/logging.h' file not found 问题、configure: error: C compiler cannot create executables问题解决过程记录

    1.在github 上面 git clone 一个RN 项目代码,npm install (yarn)后,准备运行iOS工程,发现'config.h' file not found ,恶心!!! 百度 ...

  2. mwc config.h 中文注释

    #ifndef CONFIG_H_ #define CONFIG_H_ /*************************************************************** ...

  3. 'config.h' file not found 解决过程

    最近将ReactNative业务集成进现有APP项目中,出现了几个具有代表性的问题,下面记录一下 问题1. [!] CocoaPods could not find compatible versio ...

  4. [/usr/local/openssl//.openssl/include/openssl/ssl.h] Error 127

    /bin/sh: line 2: ./config: No such file or directorymake[1]: *** [/usr/local/ssl/.openssl/include/op ...

  5. [pjsip]Pjlib中配置文件config.h解析

    config_site.h 这个头文件包含在config.h中,用于引入平台?(site)/用户特定的配置以控制PJLIB的特性,用户需要自己生成这个文件. 譬如说我们要把PJLIB编译成DLL,那么 ...

  6. Linux Makefile自动生成--config.h

    Linux Makefile自动生成--config.h http://blog.csdn.net/spch2008/article/details/12510805

  7. 微信报错 config:fail.Error:invalid signature

    config:fail.Error:invalid signature 微信公众号报这个错,appid等各项都配置好,经过一番折腾,发现原来ip白明单设置了不是该服务器的ID,重新设置后就可以了

  8. u-boot 2011.09 使用自己的board 以及config.h

    一个新的方案,用的UBOOT 可能和上一个方案是同一个,但是配置有可能不一样,今天记录一下通过修改配置文件使用新的 board 文件以及 config.h 进入 u-boot 2011.09 // 打 ...

  9. 在新版linux上编译老版本的kernel出现kernel/timeconst.h] Error 255

    在使用ubuntu16.4编译Linux-2.6.31内核时出现这样的错误 可以修改timeconst.pl的内容后正常编译. 以下是编译错误提示的内容: Can't use 'defined(@ar ...

随机推荐

  1. CentOS搭建LAMP环境

    最近准备安装roundcube,需要先搭建一个 LAMP 运行环境,从网上搜索了一下,有不少资料.自己也按部就班安装了一遍,把过程整理了下来. LAMP 是Linux, Apache, MySQL, ...

  2. Tip提示框另类写法

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  3. 《Genesis-3D开源游戏引擎完整实例教程-2D射击游戏篇08:弹幕系统》本系列完结

    8.弹幕系统 弹幕系统概述: 弹幕系统的设计体现了射击游戏的基本要素,玩家要在敌人放出的大量子弹(弹幕)的细小空隙间闪避,能在玩家闪躲弹幕的时候给玩家带来快感,接近满屏的子弹,增加了对玩家的视觉冲击力 ...

  4. Codevs No.1245 最小的N个和

    2016-05-31 18:52:15 题目链接: 最小的N个和 Codevs No.1245 题目大意: 给两个等长数列,各取一个数求和,找到最小的N组 解法: 堆优化的大暴力 直接枚举所有可能在最 ...

  5. Apache Spark Streaming的简介

    Spark Streaming通过将流数据按指定时间片累积为RDD,然后将每个RDD进行批处理,进而实现大规模的流数据处理.其吞吐量能够超越现有主流流处理框架Storm,并提供丰富的API用于流数据计 ...

  6. Linux服务器集群系统(一)(转)

    add by zhj:虽然是2002年的文章,但读来还是收益良多.在 章文嵩:谈LVS及阿里开源背后的精彩故事 中LVS发起人及主要贡献者谈了LVS的开发过程及阿里开源的一些故事 原文:http:// ...

  7. 利用phantomjs模拟QQ自动登录

    之前为了抓取兴趣部落里的数据,研究了下QQ自动登录. 当时搜索了一番,发现大部分方法都已经失效了,于是准备自己开搞. 第一个想到的就是参考网上已有方案的做法,梳理登陆js的实现,通过其他语言重写.考虑 ...

  8. Struts2零碎点整理

    1. 关于 Struts2 请求的扩展名问题 1). org.apache.struts2 包下的 default.properties 中配置了 Struts2 应用的一些常量 2). struts ...

  9. Android实例-获取程序版本号(XE10+小米2)

    相关资料: 383675978群号 实例源码: unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, Sy ...

  10. 使用 DllImport 属性

    本主题说明 DllImport 属性的常见用法.第一节讨论使用 DllImport 从托管应用程序调用本机代码的优点.第二节集中讨论封送处理和 DllImport 属性的各个方面. 从托管应用程序调用 ...