-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Yes, I'll try that. Thank you. I'm still trying to get a hang of what all the macros and variables mean...I understand the basic syntax, at least. While we're on the topic, any resources out there to help someone get a handle on vars/macros? I see in the automake manual an entire index but it doesn't seem to be beginner-friendly. Thanks.
Luke Mewburn: > On Wed, May 22, 2013 at 04:46:36PM -0700, Jordan H. wrote: > | I'm using mysql in a program. Here is a snipped of my Makefile.am: > | > | project_LDADD += -lboost_thread > | project_LDADD += -lboost_regex > | project_LDADD += -lboost_system > | > | AM_LDFLAGS = -L/usr/local/lib > | AM_LDFLAGS += `mysql_config --libs_r` > | AM_LDFLAGS += `mysql_config --include` > | AM_LDFLAGS += -std=c++0x > | AM_LDFLAGS += `mysql_config --cflags` > | > | When I compile the program, automake generated: > | > | g++ -g -O2 -L/usr/local/lib `mysql_config --libs_r` `mysql_config > | --include` -std=c++0x > | `mysql_config --cflags` -o /[ ... a bunch of .o files ... ]/ > | -lboost_thread -lboost_regex > | -lboost_system > | > | As expected, since g++ needs linker flags at the end I get a bunch of > | compile errors saying the `mysql_*` functions don't exist. How do I > | specify for the linker flags to go at the end? I tried to put them in > | the project_LDADD macro but automake complained: > | > | Makefile.am:13: linker flags such as `--libs_r`' belong in > | `project_LDFLAGS > | > | Which got me back to square one. I must be doing something wrong. Any > | ideas? This has been bugging me for days. Thanks in advance. > > Hi Jordan, > > I define some automake substition variables in configure.ac as part > of the checks for MySQL: > > # Look for mysql via the presence of 'mysql_config' or 'mysql_config5' > # > AC_PATH_PROGS([TOOL_MYSQL_CONFIG], [mysql_config mysql_config5], [], > [$PATH:/opt/local/bin]) > AS_IF([test -n "$TOOL_MYSQL_CONFIG"], > [MYSQL_CFLAGS=`$TOOL_MYSQL_CONFIG --cflags` > MYSQL_LIBS=`$TOOL_MYSQL_CONFIG --libs_r` > MYSQL_VERSION=`$TOOL_MYSQL_CONFIG --version`], > [AC_MSG_ERROR([missing program 'mysql_config'; is 'mysql' or 'MySQL-devel' installed?])]) > > WANT_MYSQL_VERSION=5.1.55 > > AC_MSG_CHECKING([for mysql >= $WANT_MYSQL_VERSION]) > AS_VERSION_COMPARE([$MYSQL_VERSION], [$WANT_MYSQL_VERSION], > [AC_MSG_RESULT([no]) > AC_MSG_FAILURE([mysql $MYSQL_VERSION is too old, need $WANT_MYSQL_VERSION])]) > AC_MSG_RESULT([yes]) > > AC_SUBST([MYSQL_CFLAGS]) > AC_SUBST([MYSQL_LIBS]) > AC_PATH_PROGS([TOOL_MYSQL], [mysql mysql5], [], > [$PATH:/opt/local/bin]) > AS_IF([test -n "$TOOL_MYSQL"], > [:], > [AC_MSG_ERROR([missing program 'mysql'; is 'mysql' or 'MySQL-client-community' installed?])]) > > > I then use these in the Makefile.am as: > > prog_CPPFLAGS += $(MYSQL_CFLAGS) > prog_LDADD += $(MYSQL_LIBS) > > (As an aside, you probably don't want includes and cflags in LDFLAGS) > > I don't bother with `mysql_config --include` > > > Feel free to reuse those snippets as you like. > > > I hope that's useful. > > > Regards, > Luke. -----BEGIN PGP SIGNATURE----- iQEcBAEBCgAGBQJRniZ3AAoJEOT99oqiSuRNgrAH/1125/APKJF1pDSLN/GCJoE/ W9t9NvM/o1ZZxxPlKGjrznzvlZ1qg255Suq5ACWKzTPxYVpH4/tOvj+CNf43gYR1 43D+KB/sV3ozfkuPcGfS3Bd7zUDD7elenJJvCTwhynOhQbXG3U8LVnTCbwMEQVcP c7ovbTaBxaG5PQVesX1t3f/mbjdPA0RrjYofyzUTJ6EiojmuXZrbfkSN1loiszTz xGZEk0BODvlzlBy3/btI19NvdQVPV2D2HxHRlA2tHRi7LxoWmf/v2OCiGxYwVPXs AkW0KqAio2fEX/sdJqGHCq69grqwzPulQDsLaLtgJS4b0iD25UWdeoxR4UgkSU0= =KeN8 -----END PGP SIGNATURE-----