PoonLab / Kaphi

Kernel-embedded ABC-SMC for phylodynamic inference
GNU Affero General Public License v3.0
4 stars 2 forks source link

Generate newick_parser.h from .y and .l files #9

Closed ArtPoon closed 7 years ago

ArtPoon commented 7 years ago

Okay, if we're going to go the route of passing Newick tree strings from R into C, then we're going to have to get bison and flex working. Specifically, we need to be able to compile newick_parser.h from newick_parser.y and newick_lexer.l. So far I haven't been able to get this to work on a Mac; see rmcclosk/thesis#37.

ArtPoon commented 7 years ago

Running bison 3.0.4:

bison -d newick_parser.y

produced newick_parser.tab.c and newick_parser.tab.h. Running flex 2.5.35 Apple(flex-31):

flex newick_lexer.l

produced lex.yy.c Running cc -o newick_parser newick_parser.tab.c lex.yy.c -lfl resulted in the following error:

newick_parser.y:12:10: fatal error: '../igraph/include/igraph.h' file not found
#include "../igraph/include/igraph.h"
         ^
1 error generated.
newick_lexer.l:4:10: fatal error: '../igraph/include/igraph.h' file not found
#include "../igraph/include/igraph.h"

because I forgot to update the relative paths in the respective files. However, switching these back raised another error:

In file included from newick_parser.y:12:
./igraph/include/igraph.h:31:10: fatal error: 'igraph_version.h' file not found
#include "igraph_version.h"
         ^
1 error generated.
In file included from newick_lexer.l:4:
./igraph/include/igraph.h:31:10: fatal error: 'igraph_version.h' file not found
#include "igraph_version.h"
ArtPoon commented 7 years ago

This error came up because I haven't built igraph_version.h from the interface file igraph_version.h.in. Calling configure and make raised a now familiar exception:

/Users/art/git/Kaphi/pkg/src/igraph/build-aux/missing: line 81: aclocal-1.14: command not found
WARNING: 'aclocal-1.14' is missing on your system.
         You should only need it if you modified 'acinclude.m4' or
         'configure.ac' or m4 files included by 'configure.ac'.

because of a version discordance between my copy of aclocal and the one that Rosemary used to generate the configure file. I'm running bootstrap.sh to start over from scratch, and re-running configure and make seems to be working.

ArtPoon commented 7 years ago

Hmm. Ran into a bunch of error messages like this:

/opt/local/bin/ranlib: file: .libs/libigraph.a(libigraph_la-amd_dump.o) has no symbols
/opt/local/bin/ranlib: file: .libs/libigraph.a(libglpk_la-amd_dump.o) has no symbols
libtool: link: ranlib .libs/libigraph.a
ranlib: file: .libs/libigraph.a(libigraph_la-drl_parse.o) has no symbols
ranlib: file: .libs/libigraph.a(libigraph_la-gengraph_random.o) has no symbols

but igraph_version.h now appears in the include directory... I'd better check on the compile flags I've set in Makevars.

ArtPoon commented 7 years ago

Updated Makevars to use igraph submodule. Call:

cc -o newick_parser newick_parser.tab.c lex.yy.c -lfl -Iigraph/include

Note addition of -I argument to point the compiler to include files in submodule. Still getting this error:

newick_lexer.l:7:10: fatal error: 'newick_parser.h' file not found
#include "newick_parser.h"

Isn't this rather circular?!?

ArtPoon commented 7 years ago

Working through netabc again to try to generate this header file within that package before attempting to duplicate in Kaphi. Following the installation instructions, I ran ./autogen.sh and then ./configure --enable-tls. Hit the following error:

checking for yaml_parser_initialize in -lyaml... no
configure: error: libyaml is required

libyaml is installed on this machine at /opt/local/lib/libyaml-0.2.dylib. Trying to figure out how the configure script is failing to find this dynamic library.

ArtPoon commented 7 years ago

Fixed by entering this first: export LIBS='-L/opt/local/lib/' Now missing check, the C unit testing framework.

ArtPoon commented 7 years ago

Installed check via MacPorts. Ran ./configure --enable-tls without incident. Success! Now we have to get this to work for Kaphi, and compile when invoked from R...