Build Fail on OS X Lion

I'm having some difficulties building the latest Bro 2.0beta on OS X Lion.

Bro = v 2.0-beta-47
OS = OS X 10.7.2
Gcc = v i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
Cmake = 2.8.6

It fails when building netflow_pac.cc.o . Log snippet below. I can provide the full screen output/log if necessary.

Any ideas/recommendations are welcome. :slight_smile:

#### Log ####
<SNIP>
====================| Bro Build Summary |=====================

Install prefix: /usr/local/bro.git
Bro Script Path: /usr/local/bro.git/share/bro
Debug mode: false

CFLAGS: -Wall -Wno-unused -O2 -g
CXX: /usr/bin/c++
CXXFLAGS: -Wall -Wno-unused -O2 -g
CPP: /usr/bin/c++

Broccoli: true
Broctl: true
Aux. Tools: true

GeoIP: false
Google perftools: false

I'm having some difficulties building the latest Bro 2.0beta on OS X Lion.

What are your versions of "flex" and "bison" ?

I've built frequently on a similar setup and my versions are flex 2.5.35 and bison (GNU Bison) 2.3. Both are Apple-provided.

It fails when building netflow_pac.cc.o . Log snippet below. I can provide the full screen output/log if necessary.

That's a file generated by BinPAC which depends on flex and bison, maybe there's a clue in those netflow_pac.cc and netflow_pac.h files if you could send them.

Also, was this working from a git repository or a source distribution? If the former, the output of `git submodule` may help.

+Jon

Responses in-line:

I'm having some difficulties building the latest Bro 2.0beta on OS X Lion.

What are your versions of "flex" and "bison" ?

I've built frequently on a similar setup and my versions are flex 2.5.35 and bison (GNU Bison) 2.3. Both are Apple-provided.

I am using the apple provided flex and bison as well. Flex=v2.5.25, Bison=v2.3.

It fails when building netflow_pac.cc.o . Log snippet below. I can provide the full screen output/log if necessary.

That's a file generated by BinPAC which depends on flex and bison, maybe there's a clue in those netflow_pac.cc and netflow_pac.h files if you could send them.

Attached.

Also, was this working from a git repository or a source distribution? If the former, the output of `git submodule` may help.

I am working from the git repo (ver/build 2.0-beta-47)

+Jon

Thanks again!

-Chuck

netflow_pac.cc (20.3 KB)

netflow_pac.h (8.49 KB)

[ 29%] Building CXX object src/CMakeFiles/bro.dir/netflow_pac.cc.o
In file included from /DG/BUILD/bro/build/src/netflow_pac.cc:3:
/DG/BUILD/bro/build/src/netflow_pac.h:13: error: expected initializer before ‘*’ token
/DG/BUILD/bro/build/src/netflow_pac.cc: In member function ‘bool binpac::NetFlow::NetFlow_Flow::deliver_v5_header(binpac::uint16, binpac::uint32, binpac::uint32, binpac::uint32, binpac::uint32, binpac::uint8, binpac::uint8, binpac::uint16)’:
/DG/BUILD/bro/build/src/netflow_pac.cc:158: error: ‘mgr’ was not declared in this scope
/DG/BUILD/bro/build/src/netflow_pac.cc: In member function ‘bool binpac::NetFlow::NetFlow_Flow::deliver_v5_record(binpac::uint32, binpac::uint32, binpac::uint32, binpac::uint16, binpac::uint16, binpac::uint32, binpac::uint32, binpac::uint32, binpac::uint32, binpac::uint16, binpac::uint16, binpac::uint8, binpac::uint8, binpac::uint8, binpac::uint16, binpac::uint16, binpac::uint8, binpac::uint8)’:
/DG/BUILD/bro/build/src/netflow_pac.cc:225: error: ‘mgr’ was not declared in this scope

So I didn't notice anything different about your netflow_pac.cc/netflow_pac.h from mine that seemed suspect, but now I'm thinking the errors might be legit (not sure what differs in your environment, though). What happens if you edit your src/netflow.pac to have an %extern block that looks like:

%extern{
#include "net_util.h"
#include "Event.h"
#include "Type.h"
extern EventMgr mgr;
extern RecordType* conn_id;
%}

+Jon

Here's the build log snippet after adding the code you suggested:

[ 29%] Building CXX object src/CMakeFiles/bro.dir/netflow_pac.cc.o
In file included from /DG/BUILD/bro/build/src/netflow_pac.cc:3:
/DG/BUILD/bro/build/src/netflow_pac.h:13: error: expected initializer before ‘*’ token
In file included from /DG/BUILD/bro/build/src/netflow_pac.cc:3:
/DG/BUILD/bro/build/src/netflow_pac.h:19: error: ‘EventMgr’ does not name a type
/DG/BUILD/bro/build/src/netflow_pac.cc: In member function ‘bool binpac::NetFlow::NetFlow_Flow::deliver_v5_header(binpac::uint16, binpac::uint32, binpac::uint32, binpac::uint32, binpac::uint32, binpac::uint8, binpac::uint8, binpac::uint16)’:
/DG/BUILD/bro/build/src/netflow_pac.cc:158: error: ‘mgr’ was not declared in this scope
/DG/BUILD/bro/build/src/netflow_pac.cc: In member function ‘bool binpac::NetFlow::NetFlow_Flow::deliver_v5_record(binpac::uint32, binpac::uint32, binpac::uint32, binpac::uint16, binpac::uint16, binpac::uint32, binpac::uint32, binpac::uint32, binpac::uint32, binpac::uint16, binpac::uint16, binpac::uint8, binpac::uint8, binpac::uint8, binpac::uint16, binpac::uint16, binpac::uint8, binpac::uint8)’:
/DG/BUILD/bro/build/src/netflow_pac.cc:225: error: ‘mgr’ was not declared in this scope
make[3]: *** [src/CMakeFiles/bro.dir/netflow_pac.cc.o] Error 1
make[2]: *** [src/CMakeFiles/bro.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2

Here's the build log snippet after adding the code you suggested:

The errors look even funkier now -- when you added code to net_flow.pac, was it just the two new lines in the %extern block or did you add a whole other block? I meant the former (a single %extern block that looks like what I showed).

Also, can you send your build/CMakeCache.txt so I can check the environment?

+Jon

My bad. I had created another Extern struct. I changed it to your recommendations. Log snippet follows:

Scanning dependencies of target bro
[ 25%] Building C object src/CMakeFiles/bro.dir/version.c.o
[ 26%] Building CXX object src/CMakeFiles/bro.dir/binpac-lib_pac.cc.o
[ 26%] Building CXX object src/CMakeFiles/bro.dir/binpac_bro-lib_pac.cc.o
[ 26%] Building CXX object src/CMakeFiles/bro.dir/bittorrent_pac.cc.o
[ 26%] Building CXX object src/CMakeFiles/bro.dir/dce_rpc_pac.cc.o
[ 27%] Building CXX object src/CMakeFiles/bro.dir/dce_rpc_simple_pac.cc.o
[ 27%] Building CXX object src/CMakeFiles/bro.dir/dhcp_pac.cc.o
[ 27%] Building CXX object src/CMakeFiles/bro.dir/dns_pac.cc.o
[ 27%] Building CXX object src/CMakeFiles/bro.dir/dns_tcp_pac.cc.o
[ 27%] Building CXX object src/CMakeFiles/bro.dir/http_pac.cc.o
[ 29%] Building CXX object src/CMakeFiles/bro.dir/ncp_pac.cc.o
[ 29%] Building CXX object src/CMakeFiles/bro.dir/netflow_pac.cc.o
In file included from /DG/BUILD/bro/build/src/netflow_pac.cc:3:
/DG/BUILD/bro/build/src/netflow_pac.h:14: error: ‘EventMgr’ does not name a type
/DG/BUILD/bro/build/src/netflow_pac.cc: In member function ‘bool binpac::NetFlow::NetFlow_Flow::deliver_v5_header(binpac::uint16, binpac::uint32, binpac::uint32, binpac::uint32, binpac::uint32, binpac::uint8, binpac::uint8, binpac::uint16)’:
/DG/BUILD/bro/build/src/netflow_pac.cc:158: error: ‘mgr’ was not declared in this scope
/DG/BUILD/bro/build/src/netflow_pac.cc: In member function ‘bool binpac::NetFlow::NetFlow_Flow::deliver_v5_record(binpac::uint32, binpac::uint32, binpac::uint32, binpac::uint16, binpac::uint16, binpac::uint32, binpac::uint32, binpac::uint32, binpac::uint32, binpac::uint16, binpac::uint16, binpac::uint8, binpac::uint8, binpac::uint8, binpac::uint16, binpac::uint16, binpac::uint8, binpac::uint8)’:
/DG/BUILD/bro/build/src/netflow_pac.cc:225: error: ‘mgr’ was not declared in this scope
make[3]: *** [src/CMakeFiles/bro.dir/netflow_pac.cc.o] Error 1
make[2]: *** [src/CMakeFiles/bro.dir/all] Error 2
make[1]: *** [all] Error 2
make: *** [all] Error 2

/DG/BUILD/bro/build/src/netflow_pac.h:14: error: ‘EventMgr’ does not name a type

Ok, I think header files are getting overshadowed somewhere (if you do `make VERBOSE=1`, you can see the order of -I options given to the compiler and look in those directories for Event.h, Type.h, etc.). I'd like to try another change; at the top of src/CMakeLists.txt there's:

include_directories(${CMAKE_CURRENT_SOURCE_DIR}
                    ${CMAKE_CURRENT_BINARY_DIR}
)

Change it to be the following ("BEFORE" is the only difference):

include_directories(BEFORE
                    ${CMAKE_CURRENT_SOURCE_DIR}
                    ${CMAKE_CURRENT_BINARY_DIR}
)

+Jon

That change (BEFORE in src/CMakeLists.txt) did the trick. The build completed successfully.

To be sure, I made a fresh clone of the bro git repo, tried to build without changing src/CMakeLists.txt, and the build failed. Then I made the change to src/CMakeLists.txt, and the build succeeded. No mod to netflow.pac in either build attempt.

I still wonder what is out of the ordinary on my system. I'll check into it further when I get the chance.

Thanks for your help Jon!

To be sure, I made a fresh clone of the bro git repo, tried to build without changing src/CMakeLists.txt, and the build failed. Then I made the change to src/CMakeLists.txt, and the build succeeded. No mod to netflow.pac in either build attempt.

Thanks for confirming that. I'm going to get that change into the git repo since that's a "righter" way to order the include directories anyway.

I still wonder what is out of the ordinary on my system. I'll check into it further when I get the chance.

I'm guessing you had built/installed some software locally (/usr/local, /opt/local, or /sw) that provided headers of the same name as what Bro needed (Event.h, Type.h) and so the compiler picked up those. Not that it's "wrong", just different.

+Jon