Bug #76089 Out of tree builds don't work (can't find PCRE)
Submitted: 2 Mar 2015 8:32 Modified: 5 Mar 2015 19:30
Reporter: Justin Swanhart Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: JSON User-defined function ( UDF ) Severity:S3 (Non-critical)
Version:0.3.3 OS:Any
Assigned to: CPU Architecture:Any

[2 Mar 2015 8:32] Justin Swanhart
Description:
I don't like to build things in-tree.  cmake projects normally support out-of-tree builds.

How to repeat:
cd mysql-json-udf-0.3.3-labs-json-udfs-src
mkdir build/
cd build
cmake .. 
[snip]
make

In file included from /home/justin/mysql-json-udfs-0.3.3-labs-json-udfs-src/JParser.cc:16:0:
/home/justin/mysql-json-udfs-0.3.3-labs-json-udfs-src/JParser.h:36:18: fatal error: pcre.h: No such file or directory
 #include "pcre.h"
                  ^
compilation terminated.
make[2]: *** [CMakeFiles/my_json.dir/JParser.cc.o] Error 1
make[1]: *** [CMakeFiles/my_json.dir/all] Error 2
make: *** [all] Error 2

Suggested fix:
Make -n shows that the include directory isn't properly passed in.
You are using cmake differently than I am, as I never user the COMMAND function to build anything.  Take a look at the CMakeLists.txt for one of the UDF I'm developing.  

I use add_library() to compile the sources:

cmake_minimum_required(VERSION 2.6)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-literal-sufix -Wno-write-strings")
SET(presto_LIB_SRCS
  php.cpp
  presto.cpp
  rewrite.cpp
  presto.h
)

#-- automatically sets mysql include directory and library directory
#-- but the library isn't needed for UDF
find_package(MySQL REQUIRED)

add_library(presto SHARED ${presto_LIB_SRCS})
set_target_properties(PROPERTIES VERSION 1.0.0 SOVERSION 1)

install(TARGETS presto DESTINATION ${PROJECT_SOURCE_DIR}/lib)
[2 Mar 2015 9:00] Umesh Shastry
Hello Justin Swanhart,

Thank you for the report.

Thanks,
Umesh
[2 Mar 2015 9:01] Umesh Shastry
// On a new testbox

[root@cluster-repo server]# wget http://downloads.mysql.com/snapshots/pb/mysql-json-udfs-0.3.3/mysql-json-udfs-0.3.3-labs-j...
..

100%[========================================================================================================================================================>] 2,154,647    437K/s   in 8.5s

2015-03-04 16:00:02 (249 KB/s) - “mysql-json-udfs-0.3.3-labs-json-udfs-src.tar.gz” saved [2154647/2154647]

[root@cluster-repo server]# tar -zxvf mysql-json-udfs-0.3.3-labs-json-udfs-src.tar.gz
[root@cluster-repo server]# cd mysql-json-udfs-0.3.3-labs-json-udfs-src
[root@cluster-repo mysql-json-udfs-0.3.3-labs-json-udfs-src]# pwd
/data/ushastry/server/mysql-json-udfs-0.3.3-labs-json-udfs-src
[root@cluster-repo mysql-json-udfs-0.3.3-labs-json-udfs-src]# mkdir build
[root@cluster-repo mysql-json-udfs-0.3.3-labs-json-udfs-src]# cd build/
[root@cluster-repo build]# cmake ..
-- The C compiler identification is GNU 4.4.7
-- The CXX compiler identification is GNU 4.4.7
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
CMake Warning at CMakeLists.txt:34 (MESSAGE):
  Path to MySQL directory was not specified.  If something goes wrong re-run
  with option -DMYSQL_DIR

-- Could NOT find BZip2 (missing:  BZIP2_LIBRARIES BZIP2_INCLUDE_DIR)
-- Could NOT find ZLIB (missing:  ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
-- Could not find OPTIONAL package Readline
-- Could not find OPTIONAL package Editline
-- Looking for dirent.h
-- Looking for dirent.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for inttypes.h
-- Looking for inttypes.h - found
-- Looking for sys/stat.h
-- Looking for sys/stat.h - found
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- Looking for windows.h
-- Looking for windows.h - not found
-- Looking for C++ include type_traits.h
-- Looking for C++ include type_traits.h - not found
-- Looking for C++ include bits/type_traits.h
-- Looking for C++ include bits/type_traits.h - not found
-- Looking for bcopy
-- Looking for bcopy - found
-- Looking for memmove
-- Looking for memmove - found
-- Looking for strerror
-- Looking for strerror - found
-- Looking for strtoll
-- Looking for strtoll - found
-- Looking for strtoq
-- Looking for strtoq - found
-- Looking for _strtoi64
-- Looking for _strtoi64 - not found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of long long
-- Check size of long long - done
-- Check size of unsigned long long
-- Check size of unsigned long long - done
--
--
-- PCRE configuration summary:
--
--   Install prefix .................. : /usr/local
--   C compiler ...................... : /usr/bin/cc
--   C++ compiler .................... : /usr/bin/c++
--   C compiler flags ................ :
--   C++ compiler flags .............. :
--
--   Build 8 bit PCRE library ........ : ON
--   Build 16 bit PCRE library ....... : OFF
--   Build 32 bit PCRE library ....... : OFF
--   Build C++ library ............... : ON
--   Enable JIT compiling support .... : OFF
--   Enable UTF support .............. : OFF
--   Unicode properties .............. : OFF
--   Newline char/sequence ........... : LF
--   \R matches only ANYCRLF ......... : OFF
--   EBCDIC coding ................... : OFF
--   EBCDIC coding with NL=0x25 ...... : OFF
--   Rebuild char tables ............. : OFF
--   No stack recursion .............. : OFF
--   POSIX mem threshold ............. : 10
--   Internal link size .............. : 2
--   Parentheses nest limit .......... : 250
--   Match limit ..................... : 10000000
--   Match limit recursion ........... : MATCH_LIMIT
--   Build shared libs ............... : OFF
--   Build static libs ............... : ON
--   Build pcregrep .................. : ON
--   Enable JIT in pcregrep .......... : ON
--   Buffer size for pcregrep ........ : 20480
--   Build tests (implies pcretest  .. : ON
--                and pcregrep)
--   Link pcregrep with libz ......... : Library not found
--   Link pcregrep with libbz2 ....... : Library not found
--   Link pcretest with libeditline .. : Library not found
--   Link pcretest with libreadline .. : Library not found
--   Support Valgrind .................: OFF
--   Support coverage .................:
--
-- Configuring done
-- Generating done
-- Build files have been written to: /data/ushastry/server/mysql-json-udfs-0.3.3-labs-json-udfs-src/build
[root@cluster-repo build]# make
Scanning dependencies of target my_json
[  2%] Building CXX object CMakeFiles/my_json.dir/JParser.cc.o
In file included from /data/ushastry/server/mysql-json-udfs-0.3.3-labs-json-udfs-src/JParser.cc:16:
/data/ushastry/server/mysql-json-udfs-0.3.3-labs-json-udfs-src/JParser.h:36:18: error: pcre.h: No such file or directory
/data/ushastry/server/mysql-json-udfs-0.3.3-labs-json-udfs-src/JParser.cc: In member function ‘bool JParser::parse_num(char, int)’:
/data/ushastry/server/mysql-json-udfs-0.3.3-labs-json-udfs-src/JParser.cc:622: error: ‘pcre’ was not declared in this scope
/data/ushastry/server/mysql-json-udfs-0.3.3-labs-json-udfs-src/JParser.cc:622: error: ‘regex’ was not declared in this scope
/data/ushastry/server/mysql-json-udfs-0.3.3-labs-json-udfs-src/JParser.cc:641: error: ‘PCRE_EXTENDED’ was not declared in this scope
/data/ushastry/server/mysql-json-udfs-0.3.3-labs-json-udfs-src/JParser.cc:641: error: ‘pcre_compile’ was not declared in this scope
/data/ushastry/server/mysql-json-udfs-0.3.3-labs-json-udfs-src/JParser.cc:648: error: ‘pcre_exec’ was not declared in this scope
/data/ushastry/server/mysql-json-udfs-0.3.3-labs-json-udfs-src/JParser.cc:654: error: ‘pcre_free’ was not declared in this scope
/data/ushastry/server/mysql-json-udfs-0.3.3-labs-json-udfs-src/JParser.cc:657: error: ‘pcre_free’ was not declared in this scope
make[2]: *** [CMakeFiles/my_json.dir/JParser.cc.o] Error 1
make[1]: *** [CMakeFiles/my_json.dir/all] Error 2
make: *** [all] Error 2
[root@cluster-repo build]#

// may mysql installation path required?

README mentions - Build uses CMake. To compile, run:

cmake . -DMYSQL_DIR=/path/to/mysql/installation
make
[5 Mar 2015 19:30] Sveta Smirnova
Posted by developer:
 
Fixed in version 0.4.0