libmemcached - A C and C++ client library for memcached

how to compile a project

Asked by Panin Sergey on 2012-03-05

Simple project:

#include <string.h>
#include <libmemcached/memcached.h>

int main( void )
{
 return 0;
}

Compile line:
g++ -Wall -o mc mc.cpp -lmemcached -I/usr/include/libmemcached/

Errors:
    In file included from /usr/include/c++/4.5/cstring:45:0,
                     from mc.cpp:1:
    /usr/include/libmemcached/string.h:29:9: error: ‘memcached_st’ does not name a type
    /usr/include/libmemcached/string.h:40:1: error: ‘LIBMEMCACHED_LOCAL’ does not name a type
    /usr/include/libmemcached/string.h:44:1: error: ‘LIBMEMCACHED_LOCAL’ does not name a type
    /usr/include/libmemcached/string.h:47:1: error: ‘LIBMEMCACHED_LOCAL’ does not name a type
    /usr/include/libmemcached/string.h:50:1: error: ‘LIBMEMCACHED_LOCAL’ does not name a type
    /usr/include/libmemcached/string.h:53:1: error: ‘LIBMEMCACHED_LOCAL’ does not name a type
    /usr/include/libmemcached/string.h:56:1: error: ‘LIBMEMCACHED_LOCAL’ does not name a type
    /usr/include/libmemcached/string.h:59:1: error: ‘LIBMEMCACHED_LOCAL’ does not name a type
    /usr/include/libmemcached/string.h:62:1: error: ‘LIBMEMCACHED_LOCAL’ does not name a type
    /usr/include/libmemcached/string.h:65:1: error: ‘LIBMEMCACHED_LOCAL’ does not name a type
    /usr/include/libmemcached/string.h:68:1: error: ‘LIBMEMCACHED_LOCAL’ does not name a type
    /usr/include/libmemcached/string.h:71:1: error: ‘LIBMEMCACHED_LOCAL’ does not name a type
    /usr/include/libmemcached/string.h:74:1: error: ‘LIBMEMCACHED_LOCAL’ does not name a type
    In file included from mc.cpp:1:0:
    /usr/include/c++/4.5/cstring:76:11: error: ‘::memchr’ has not been declared
    /usr/include/c++/4.5/cstring:77:11: error: ‘::memcmp’ has not been declared
    /usr/include/c++/4.5/cstring:78:11: error: ‘::memcpy’ has not been declared
    /usr/include/c++/4.5/cstring:79:11: error: ‘::memmove’ has not been declared
    /usr/include/c++/4.5/cstring:80:11: error: ‘::memset’ has not been declared
    /usr/include/c++/4.5/cstring:81:11: error: ‘::strcat’ has not been declared
    /usr/include/c++/4.5/cstring:82:11: error: ‘::strcmp’ has not been declared
    /usr/include/c++/4.5/cstring:83:11: error: ‘::strcoll’ has not been declared
    /usr/include/c++/4.5/cstring:84:11: error: ‘::strcpy’ has not been declared
    /usr/include/c++/4.5/cstring:85:11: error: ‘::strcspn’ has not been declared
    /usr/include/c++/4.5/cstring:86:11: error: ‘::strerror’ has not been declared
    /usr/include/c++/4.5/cstring:87:11: error: ‘::strlen’ has not been declared
    /usr/include/c++/4.5/cstring:88:11: error: ‘::strncat’ has not been declared
    /usr/include/c++/4.5/cstring:89:11: error: ‘::strncmp’ has not been declared
    /usr/include/c++/4.5/cstring:90:11: error: ‘::strncpy’ has not been declared
    /usr/include/c++/4.5/cstring:91:11: error: ‘::strspn’ has not been declared
    /usr/include/c++/4.5/cstring:92:11: error: ‘::strtok’ has not been declared
    /usr/include/c++/4.5/cstring:93:11: error: ‘::strxfrm’ has not been declared
    /usr/include/c++/4.5/cstring:94:11: error: ‘::strchr’ has not been declared
    /usr/include/c++/4.5/cstring:95:11: error: ‘::strpbrk’ has not been declared
    /usr/include/c++/4.5/cstring:96:11: error: ‘::strrchr’ has not been declared
    /usr/include/c++/4.5/cstring:97:11: error: ‘::strstr’ has not been declared

Question information

Language:
English Edit question
Status:
Solved
For:
libmemcached Edit question
Assignee:
No assignee Edit question
Solved by:
Panin Sergey
Solved:
2012-03-06
Last query:
2012-03-06
Last reply:
Panin Sergey (dix75) said : #1

Example 2

#include <libmemcached/memcached.h>
#include <string.h>
#include <cstring>

int main( void )
{
 char *key = "key";
 char *value = "value";
 uint32_t flags = 0;
 size_t length = 0;
 char *value2 = NULL;
 memcached_return rc;

 memcached_st *memc = memcached_create(NULL);
 memcached_server_add(memc,"localhost",11211);
 rc = memcached_set(memc, key, strlen(key), value, strlen(value)+1, (time_t)0, flags);
 memcached_free(memc);
 return 0;
}

Error:
`In file included from mc.cpp:3:0:
/usr/include/c++/4.5/cstring:76:11: error: ‘::memchr’ has not been declared
/usr/include/c++/4.5/cstring:77:11: error: ‘::memcmp’ has not been declared
/usr/include/c++/4.5/cstring:78:11: error: ‘::memcpy’ has not been declared
/usr/include/c++/4.5/cstring:79:11: error: ‘::memmove’ has not been declared
/usr/include/c++/4.5/cstring:80:11: error: ‘::memset’ has not been declared
/usr/include/c++/4.5/cstring:81:11: error: ‘::strcat’ has not been declared
/usr/include/c++/4.5/cstring:82:11: error: ‘::strcmp’ has not been declared
/usr/include/c++/4.5/cstring:83:11: error: ‘::strcoll’ has not been declared
/usr/include/c++/4.5/cstring:84:11: error: ‘::strcpy’ has not been declared
/usr/include/c++/4.5/cstring:85:11: error: ‘::strcspn’ has not been declared
/usr/include/c++/4.5/cstring:86:11: error: ‘::strerror’ has not been declared
/usr/include/c++/4.5/cstring:87:11: error: ‘::strlen’ has not been declared
/usr/include/c++/4.5/cstring:88:11: error: ‘::strncat’ has not been declared
/usr/include/c++/4.5/cstring:89:11: error: ‘::strncmp’ has not been declared
/usr/include/c++/4.5/cstring:90:11: error: ‘::strncpy’ has not been declared
/usr/include/c++/4.5/cstring:91:11: error: ‘::strspn’ has not been declared
/usr/include/c++/4.5/cstring:92:11: error: ‘::strtok’ has not been declared
/usr/include/c++/4.5/cstring:93:11: error: ‘::strxfrm’ has not been declared
/usr/include/c++/4.5/cstring:94:11: error: ‘::strchr’ has not been declared
/usr/include/c++/4.5/cstring:95:11: error: ‘::strpbrk’ has not been declared
/usr/include/c++/4.5/cstring:96:11: error: ‘::strrchr’ has not been declared
/usr/include/c++/4.5/cstring:97:11: error: ‘::strstr’ has not been declared
mc.cpp: In function ‘int main()’:
mc.cpp:7:14: warning: deprecated conversion from string constant to ‘char*’
mc.cpp:8:16: warning: deprecated conversion from string constant to ‘char*’
mc.cpp:16:42: error: ‘strlen’ was not declared in this scope
mc.cpp:10:9: warning: unused variable ‘length’
mc.cpp:11:8: warning: unused variable ‘value2’

Panin Sergey (dix75) said : #2

neet to compile:

g++ -Wall -o mc mc.cpp -lmemcached -I/usr/include/