Open pushkar2017 opened 5 years ago
Created PR to fix this. https://github.com/jbeder/yaml-cpp/pull/666
Without this fix, the correct way to detect yaml-cpp is this (which is quite hard frankly for most people):
# Detect if yaml-cpp is available, needed to build the cookie_remap plugin AC_SUBST(use_yamlcpp, 0) AC_LANG_PUSH([C++]) AC_CHECK_HEADERS([yaml-cpp/yaml.h], [has_yamlcpp=1],[has_yamlcpp=0]) AS_IF([test "x$has_yamlcpp" = "x1"], [ SAVE_LIBS="$LIBS" LIBS="-lyaml-cpp" AC_LANG_PUSH([C++]) AC_MSG_CHECKING([for yaml-cpp linking]) AC_LINK_IFELSE([ AC_LANG_PROGRAM([#include "yaml-cpp/yaml.h"],[YAML::LoadFile("doesnotexist");])],[ has_yamlcpplib=1 AC_SUBST([YAMLCPP_CFLAGS]) AC_SUBST([YAMLCPP_LIBS]) AC_MSG_RESULT([yes]) AC_SUBST(use_yamlcpp, 1) ], [ AC_MSG_RESULT([no]) AC_MSG_WARN([yaml-cpp not linkable]) AC_SUBST([YAMLCPP_CFLAGS],[""]) AC_SUBST([YAMLCPP_LIBS],[""]) ]) AC_LANG_POP() LIBS="$SAVE_LIBS" ], [ AC_MSG_WARN([yaml-cpp not found]) AC_SUBST([YAMLCPP_CFLAGS],[""]) AC_SUBST([YAMLCPP_LIBS],[""]) ]) AC_LANG_POP() AM_CONDITIONAL([HAS_YAMLCPP], [ test "x${use_yamlcpp}" = "x1" ])
I personally don't think, that
which is quite hard frankly for most people
is sufficient reasoning to add any functionality to the library. You could add detection script part to the documentation, for example.
Why don't use pkg-config MACRO PKG_CHECK_MODULES?
PKG_CHECK_MODULES(YAML_CPP, yaml-cpp >= 0.6.0)
MY_CPPFLAGS=${YAML_CPP_CPPFLAGS}
MY_LDFLAGS=${YAML_CPP_LDFLAGS}
How does one easily detect yaml-cpp in configure scripts? I am finding it hard to test for the library in Apache TrafficServer's configure script. Can we add a dummy C function that is not enclosed in a namespace to make this easier. I can create a PR for that.
This is what I have:
AC_LANG_PUSH([C++]) AC_CHECK_HEADERS([yaml-cpp/yaml.h], [has_yamlcpp=1],[has_yamlcpp=0]) AC_CHECK_LIB([yaml-cpp],[YAML::LoadFile],[AC_SUBST([LIB_YAMLCPP],["-lyaml-cpp"])],[has_yamlcpp=0]) AC_SUBST(has_yamlcpp) AM_CONDITIONAL([HAS_YAMLCPP], [ test "x${has_yamlcpp}" = "x1" ]) AC_LANG_POP
configure:33552: checking for YAML::LoadFile in -lyaml-cpp configure:33587: /opt/rh/devtoolset-7/root/usr/bin/g++ -o conftest -g -O0 -I/home/ppradhan/yaml-cpp/include/ -D_GNU_SOURCE -DOPENSSL_NO_SSL_INTERN -L/home/ppradhan/yaml-cpp/ conftest.cpp -lyaml-cpp -lpthread -ldl -lrt -lrt >&5 conftest.cpp:91:6: error: 'YAML' has not been declared char YAML::LoadFile (); ^~~~ conftest.cpp: In function 'int main()': conftest.cpp:95:8: error: 'YAML' has not been declared return YAML::LoadFile (); ^~~~ configure:33594: $? = 1