C コードで C++ ライブラリ Gloox を使用したい (openwrt の easycwmp パッケージ)。
Gloox をパッケージとして openwrt toolschain でコンパイルします。
cpp ファイル Gloox.cpp は次のとおりです。
#include "gloox.h"
namespace gloox
{
const std::string XMPP_STREAM_VERSION_MAJOR = "1";
const std::string XMPP_STREAM_VERSION_MINOR = "0";
const std::string GLOOX_VERSION = "1.0.11";
const std::string GLOOX_CAPS_NODE = "http://camaya.net/gloox";
}
extern "C" const char* gloox_version()
{
return gloox::GLOOX_VERSION.c_str();
}
ヘッダファイル Gloox.h :
#ifndef GLOOX_H__
#define GLOOX_H__
#include "macros.h"
extern "C" //--> error: expected identifier or '(' before string constant
{
GLOOX_API const char* gloox_version();
}
#endif // GLOOX_H__
easycwmp パッケージの C コードに gloox.h をインクルードすると、gloox パッケージのコンパイルは問題ありません。次のエラーが表示されます。
staging_dir/target-i386_uClibc-0.9.33.2/usr/include/gloox.h:12:8: エラー: 文字列定数の前に識別子または '(' が必要です!!
コマンドでlibglooxをコンパイルします:
make package/libgloox/compile
そして、cmd を使用して easycwmp パッケージをコンパイルします。
make package/easycwmp/compile
どんな助けでも大歓迎です