Skip to content

Instantly share code, notes, and snippets.

@marceloneppel
Forked from anjesh/readme.md
Created April 7, 2024 12:42
Show Gist options
  • Save marceloneppel/81ce18c6d1a4c3f8b98b4a8f6f6956a7 to your computer and use it in GitHub Desktop.
Save marceloneppel/81ce18c6d1a4c3f8b98b4a8f6f6956a7 to your computer and use it in GitHub Desktop.
mysql source compiling
  • Download mysql source

  • Ran the following cmake command based on the documentation

cmake \
  -DCMAKE_INSTALL_PREFIX=/usr/local/mac-dev-env/mysql-5.7.18 \
  -DCMAKE_CXX_FLAGS="-stdlib=libstdc++" \
  -DDEFAULT_CHARSET=utf8 \
  -DDEFAULT_COLLATION=utf8_general_ci \
  -DDOWNLOAD_BOOST=ON \
  -DWITH_BOOST=/usr/local/src/boost \
  ..
cmake \
  -DCMAKE_INSTALL_PREFIX=./mysql-5.7.18 \
  -DCMAKE_CXX_FLAGS="-stdlib=libstdc++" \
  -DDEFAULT_CHARSET=utf8 \
  -DDEFAULT_COLLATION=utf8_general_ci \
  -DDOWNLOAD_BOOST=1 \
  ..
  • gives the following error
CMake Error at cmake/boost.cmake:81 (MESSAGE):
You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>
./configure.cmake --without-server --enable-thread-safe-client \
    --with-client-ldflags=-all-static --prefix=./mybuild \
    --without-debug  --without-docs --with-big-tables
  • this didn't work

Building boost

download boost and untar

mkdir mybuild
./bootstrap.sh --prefix=mybuild/
./b2
  • building taking time

  • create folder mybuild inside mysql source folder so that cmake files are in that folder and it's easy to delete the tmp files. Also put the entire src in git to see if the original src folder gets new files.

cmake \
  -DCMAKE_INSTALL_PREFIX= ./mysql-5.7.18\
  -DCMAKE_CXX_FLAGS="-stdlib=libstdc++" \
  -DDEFAULT_CHARSET=utf8 \
  -DDEFAULT_COLLATION=utf8_general_ci \
  -DDOWNLOAD_BOOST=ON \
  -DWITH_BOOST=../../boost_1_65_0.tar.gz \
  ..
  • gives error -- MySQL currently requires boost_1_59_0
cmake \
  -DCMAKE_INSTALL_PREFIX= ./mysql-5.7.18\
  -DCMAKE_CXX_FLAGS="-stdlib=libstdc++" \
  -DDEFAULT_CHARSET=utf8 \
  -DDEFAULT_COLLATION=utf8_general_ci \
  -DDOWNLOAD_BOOST=ON \
  -DWITH_BOOST=../../ \
  ..
  • this tried to download boost but later got timeout error

  • downloaded boost package wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz

cmake \
  -DCMAKE_INSTALL_PREFIX= ./mysql-5.7.18\
  -DCMAKE_CXX_FLAGS="-stdlib=libstdc++" \
  -DDEFAULT_CHARSET=utf8 \
  -DDEFAULT_COLLATION=utf8_general_ci \
  -DDOWNLOAD_BOOST=ON \
  -DWITH_BOOST=../../ \
  ..
  • the cmake is running ok

  • make to build the exe

  • got this error /Users/anjesh/Dev/source/mysql-5.7.19/mysys/charset.c:403:22: error: use of undeclared identifier 'DEFAULT_CHARSET_HOME'

  • Found the bug reported here https://bugs.mysql.com/bug.php?id=78214

  • not sure how to fix

  • looks like this error might be due to space after PREFIX= , something that's mentioned in above command

cmake \
  -DCMAKE_INSTALL_PREFIX=./mysql-5.7.18 \
  -DCMAKE_CXX_FLAGS="-stdlib=libstdc++" \
  -DDEFAULT_CHARSET=utf8 \
  -DDEFAULT_COLLATION=utf8_general_ci \
  -DDOWNLOAD_BOOST=ON \
  -DWITH_BOOST=../../ \
  ..

make

  • still cann't compile Mysql-python becauase of some .h file folder issues.

  • again runnnig cmake and make with some change in the prefix

cmake \
  -DCMAKE_INSTALL_PREFIX=./ \
  -DCMAKE_CXX_FLAGS="-stdlib=libstdc++" \
  -DDEFAULT_CHARSET=utf8 \
  -DDEFAULT_COLLATION=utf8_general_ci \
  -DDOWNLOAD_BOOST=ON \
  -DWITH_BOOST=../../ \
  ..

make

make install without sudo and the necessary files are installed in the same folder

Now i was able to install MySQL-Python after configuring mysql_config, i put mysql_config in ~/bin and the installation worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment