# membase 1.7.0 on amd64



## da1 (Jul 27, 2011)

Hi guys,

I have a amd64 8.2-STABLE box and I'm trying to compile membase on it (we need it at work). The "progress" can be tracked here. I've downloaded the src code from here (1.7.0) and I used gmake, gmake CC=gcc45 and gmake CC=gcc47 (note the things that needed to be modified). Also tried on Centos and I'm getting errors too but on ubuntu (apparently it's the dev's development platform of choice) it compiles. 

Basically, to get to the point I'm at, the following steps need to be followed (more or less):
**NOTE: we do not need SASL (and it's a pain in the neck anyway to compile with SASL enabled)

```
- cd memcached; ./configure --disable-sasl
- memcached/Makefile -> line 1622 (â€œmakeâ€ -> â€œgmakeâ€)
- bucket_engine/Makefile, line146/148: removed â€œ-Werrorâ€ because â€œcc1: warnings are treates as errors" and 
  â€œCONFIGURE_ARGS=--disable-warn-as-err" (in make.conf) makes no difference
- ep-engine/common.hh, comment out line 29 & 36, because â€œboost/shared_ptr.hpp: No such file or directoryâ€
- cd libmemcache && ./configure --without-memcached --disable-sasl
- cd memcachedtest && ./configure --without-memcached
- cd moxi && ./configure --without-memcached
- moxi/memcached.h (define absolute path for event.h) <- problem with include 
- moxi/work.h (define absolute path for event.h) <- problem with include 
- memcached/libevent/event.h (define absolute path for event-config.h) <- problem with include 
- memcached/libevent/evutil.h (define absolute path for event-config.h) <- problem with include 
- moxi/Makefile (remove -Werror from line 360 and 362)
```

About the include problem, I'm not a C guy so maybe someone can help me out here too.

LE: damn, just realized that maybe this should go to "Porting new software".


----------



## NewGuy (Jul 30, 2011)

I tried this too and the membase make system is a huge mess (as you've discovered). I think I got a little further. What I did was create a Port Makefile with just the bare bones to download and use gmake. Then ran

`make fetch`
`make`

The compile effort stopped at libevent. I found if I changed into the libevent folder (memcached/libevent) and added the line

```
w:
```
to the bottom of the libevent Makefile and then ran "*make*" inside that folder and then the folder above it, membase would mostly compile.

So basically I had to compile libevent and memcached manually, edit the libevent Makefile to include a "w:" target and then go back to the top-level directory and run "make" again. It's a terrible mess and it's a wonder it compiles on any platform.

By the way, the "boost" errors you were getting early on can probably be fixed by installing the "boost" port. It's under /usr/ports/devel/. This is probably a better idea than commenting out parts of the membase code.

Best of luck!


----------



## da1 (Jul 31, 2011)

Hi,

Thx for the hint. I went the same way, created a port Makefile with the basic stuff (the only different thing I did was add 
	
	



```
LIB_DEPENDS=    libevent-1.4.so.4:${PORTSDIR}/devel/libevent
```
 then did the manual make in libevent and memcached but I ended up at the same point as before:


```
cc -std=gnu99 -DHAVE_CONFIG_H   -DCONFLATE_DB_PATH=\"/usr/ports/www/membase-server/work/membase-server_src/install/var/lib/moxi\" 
-I. -I. -ggdb3  -I/usr/ports/www/membase-server/work/membase-server_src/libmemcached -
I/usr/ports/www/membase-server/work/membase-server_src/libvbucket/include 
-I/usr/ports/www/membase-server/work/membase-server_src/install/include  
-D_THREAD_SAFE -pthread -pipe  -O3 -Werror -pedantic -Wall -Wundef -Wshadow  
-fdiagnostics-show-option -fvisibility=hidden -Wformat -fno-strict-aliasing 
-Wno-strict-aliasing -Wextra -Wstrict-prototypes -Wmissing-prototypes 
-Wredundant-decls -Wmissing-declarations -Wcast-align     -Wno-error -O2 -pipe 
-fno-strict-aliasing -MT moxi-memcached.o -MD -MP -MF .deps/moxi-memcached.Tpo -c -o 
moxi-memcached.o `test -f 'memcached.c' || echo './'`memcached.c
In file included from config_static.h:65,
                 from config.h:396,
                 from memcached.h:9,
                 from memcached.c:16:
/usr/include/netinet/tcp.h:40: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'tcp_seq'
/usr/include/netinet/tcp.h:50: error: expected specifier-qualifier-list before 'u_short'
/usr/include/netinet/tcp.h:175: error: expected specifier-qualifier-list before 'u_int8_t'
In file included from memcached.c:16:
memcached.h:15:19: error: event.h: No such file or directory
In file included from memcached.h:20,
                 from memcached.c:16:
work.h:35: error: field 'event' has incomplete type
In file included from memcached.c:16:
memcached.h:361: error: field 'notify_event' has incomplete type
memcached.h:398: error: field 'event' has incomplete type
In file included from memcached.c:41:
cproxy.h:423: error: field 'timeout_event' has incomplete type
cproxy.h:488: error: field 'timeout_event' has incomplete type
memcached.c: In function 'conn_new':
memcached.c:456: warning: implicit declaration of function 'event_set'
memcached.c:457: warning: implicit declaration of function 'event_base_set'
memcached.c:460: warning: implicit declaration of function 'event_add'
memcached.c:461: warning: implicit declaration of function 'event_del'
memcached.c: In function 'do_accept_new_conns':
memcached.c:3352: error: 'EV_READ' undeclared (first use in this function)
memcached.c:3352: error: (Each undeclared identifier is reported only once
memcached.c:3352: error: for each function it appears in.)
memcached.c:3352: error: 'EV_PERSIST' undeclared (first use in this function)
memcached.c: In function 'transmit':
memcached.c:3421: error: 'EV_WRITE' undeclared (first use in this function)
memcached.c:3421: error: 'EV_PERSIST' undeclared (first use in this function)
memcached.c: In function 'drive_machine':
memcached.c:3485: error: 'EV_READ' undeclared (first use in this function)
memcached.c:3485: error: 'EV_PERSIST' undeclared (first use in this function)
memcached.c:3561: error: 'EV_WRITE' undeclared (first use in this function)
memcached.c: In function 'server_socket':
memcached.c:3974: error: 'EV_READ' undeclared (first use in this function)
memcached.c:3974: error: 'EV_PERSIST' undeclared (first use in this function)
memcached.c: In function 'server_socket_unix':
memcached.c:4067: error: 'EV_READ' undeclared (first use in this function)
memcached.c:4067: error: 'EV_PERSIST' undeclared (first use in this function)
memcached.c: In function 'clock_handler':
memcached.c:4107: warning: implicit declaration of function 'evtimer_del'
memcached.c:4112: warning: implicit declaration of function 'evtimer_set'
memcached.c:4114: warning: implicit declaration of function 'evtimer_add'
memcached.c: In function 'main':
memcached.c:4903: warning: implicit declaration of function 'event_init'
memcached.c:4903: warning: assignment makes pointer from integer without a cast
memcached.c:5061: warning: implicit declaration of function 'event_base_loop'
gmake[3]: *** [moxi-memcached.o] Error 1
gmake[3]: Leaving directory `/usr/ports/www/membase-server/work/membase-server_src/moxi'
gmake[2]: *** [install-recursive] Error 1
gmake[2]: Leaving directory `/usr/ports/www/membase-server/work/membase-server_src/moxi'
gmake[1]: *** [install] Error 2
gmake[1]: Leaving directory `/usr/ports/www/membase-server/work/membase-server_src/moxi'
gmake: *** [make-install-moxi] Error 2
```

Here is the Makefile:

```
# New ports collection makefile for:	membase-server_src
# Date created:				Jun 31, 2011
# Whom:					Claudiu Vasadi <claudiu.vasadi@gmail.com>
#

PORTNAME=	membase-server_src
PORTVERSION=	1.7.1
CATEGORIES=	www
MASTER_SITES=	http://files.couchbase.com/source/

MAINTAINER=	claudiu.vasadi@gmail.com
COMMENT=	memcache cluster software

LIB_DEPENDS=    libevent-1.4.so.4:${PORTSDIR}/devel/libevent

USE_GMAKE=	yes

WRKSRC=		${WRKDIR}/${PORTNAME}
.include <bsd.port.mk>
```


----------



## da1 (Aug 1, 2011)

I noticed that changing "make" to "gmake" in memcached/Makefile.in (line 1622) and memcached/Makefile.am (line 111) facilitates the automatic make of libevent and memcached (does not need to be done manually anymore).

Unfortunately, this is where I had to stop last time too:

```
gmake[3]: Entering directory `/usr/ports/www/membase-server/work/membase-server_src/moxi'
cc -std=gnu99 -DHAVE_CONFIG_H   -DCONFLATE_DB_PATH=\"/usr/ports/www/membase-server/work/membase-server_src/install/var/lib/moxi\" -I. -I.
 -ggdb3  -I/usr/ports/www/membase-server/work/membase-server_src/libmemcached -I/usr/ports/www/membase-server/work/membase-
server_src/libvbucket/include -I/usr/ports/www/membase-server/work/membase-server_src/install/include  -D_THREAD_SAFE -pthread -pipe  -O3
 -Werror -pedantic -Wall -Wundef -Wshadow  -fdiagnostics-show-option -fvisibility=hidden -Wformat -fno-strict-aliasing -Wno-strict-aliasing
 -Wextra -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wmissing-declarations -Wcast-align     -Wno-error -O2 -pipe -fno-strict-
aliasing -MT moxi-memcached.o -MD -MP -MF .deps/moxi-memcached.Tpo -c -o moxi-memcached.o `test -f 'memcached.c' || echo './'`memcached.c
In file included from config_static.h:65,
                 from config.h:396,
                 from memcached.h:9,
                 from memcached.c:16:
/usr/include/netinet/tcp.h:40: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'tcp_seq'
/usr/include/netinet/tcp.h:50: error: expected specifier-qualifier-list before 'u_short'
/usr/include/netinet/tcp.h:175: error: expected specifier-qualifier-list before 'u_int8_t'
In file included from memcached.c:16:
memcached.h:15:19: error: event.h: No such file or directory
In file included from memcached.h:20,
                 from memcached.c:16:
work.h:35: error: field 'event' has incomplete type
In file included from memcached.c:16:
memcached.h:361: error: field 'notify_event' has incomplete type
memcached.h:398: error: field 'event' has incomplete type
In file included from memcached.c:41:
cproxy.h:423: error: field 'timeout_event' has incomplete type
cproxy.h:488: error: field 'timeout_event' has incomplete type
memcached.c: In function 'conn_new':
memcached.c:456: warning: implicit declaration of function 'event_set'
memcached.c:457: warning: implicit declaration of function 'event_base_set'
memcached.c:460: warning: implicit declaration of function 'event_add'
memcached.c:461: warning: implicit declaration of function 'event_del'
memcached.c: In function 'do_accept_new_conns':
memcached.c:3352: error: 'EV_READ' undeclared (first use in this function)
memcached.c:3352: error: (Each undeclared identifier is reported only once
memcached.c:3352: error: for each function it appears in.)
memcached.c:3352: error: 'EV_PERSIST' undeclared (first use in this function)
memcached.c: In function 'transmit':
memcached.c:3421: error: 'EV_WRITE' undeclared (first use in this function)
memcached.c:3421: error: 'EV_PERSIST' undeclared (first use in this function)
memcached.c: In function 'drive_machine':
memcached.c:3485: error: 'EV_READ' undeclared (first use in this function)
memcached.c:3485: error: 'EV_PERSIST' undeclared (first use in this function)
memcached.c:3561: error: 'EV_WRITE' undeclared (first use in this function)
memcached.c: In function 'server_socket':
memcached.c:3974: error: 'EV_READ' undeclared (first use in this function)
memcached.c:3974: error: 'EV_PERSIST' undeclared (first use in this function)
memcached.c: In function 'server_socket_unix':
memcached.c:4067: error: 'EV_READ' undeclared (first use in this function)
memcached.c:4067: error: 'EV_PERSIST' undeclared (first use in this function)
memcached.c: In function 'clock_handler':
memcached.c:4107: warning: implicit declaration of function 'evtimer_del'
memcached.c:4112: warning: implicit declaration of function 'evtimer_set'
memcached.c:4114: warning: implicit declaration of function 'evtimer_add'
memcached.c: In function 'main':
memcached.c:4903: warning: implicit declaration of function 'event_init'
memcached.c:4903: warning: assignment makes pointer from integer without a cast
memcached.c:5061: warning: implicit declaration of function 'event_base_loop'
gmake[3]: *** [moxi-memcached.o] Error 1
gmake[3]: Leaving directory `/usr/ports/www/membase-server/work/membase-server_src/moxi'
gmake[2]: *** [install-recursive] Error 1
gmake[2]: Leaving directory `/usr/ports/www/membase-server/work/membase-server_src/moxi'
gmake[1]: *** [install] Error 2
gmake[1]: Leaving directory `/usr/ports/www/membase-server/work/membase-server_src/moxi'
gmake: *** [make-install-moxi] Error 2
*** Error code 1

Stop in /usr/ports/www/membase-server.
```

UPDATE: replaced RUN_DEPENDS with 
	
	



```
LIB_DEPENDS=    libevent-1.4.so.4:${PORTSDIR}/devel/libevent
```
 and updated the previous posts.


----------

