Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Mac osX build #48

Closed
Fab-z4qx opened this issue Jun 17, 2019 · 8 comments
Closed

Mac osX build #48

Fab-z4qx opened this issue Jun 17, 2019 · 8 comments

Comments

@Fab-z4qx
Copy link

Fab-z4qx commented Jun 17, 2019

Hello,

I'm not able to build on macox 10.14.5. There is some strange error with boost 1.0.69.
MacBook:build $
cmake .. -DDATE_INCLUDE_DIR=../../date-2.4.1/include/ -DSQLPP11_INCLUDE_DIR=../../sqlpp11-0.58/include/ -DUSE_MARIADB=1

Apple XCode does not have thread_local, thus we need to wrap that via boost thread
-- Boost version: 1.69.0
-- Found the following Boost libraries:
-- thread
-- system
-- chrono
-- date_time
-- atomic
-- Using /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ (compiler id: AppleClang)
including date from /Users/m4gyars/Project/core2/setup/date-2.4.1/include
including sqlpp11 from /Users/m4gyars/Project/core2/setup/sqlpp11-0.58/include
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/m4gyars/Project/core2/setup/sqlpp11-connector-mysql-0.25/build

MacBook:build$ make && sudo make install
Scanning dependencies of target sqlpp-mysql
[ 4%] Building CXX object src/CMakeFiles/sqlpp-mysql.dir/connection.cpp.o
/Users/m4gyars/Project/core2/setup/sqlpp11-connector-mysql-0.25/src/connection.cpp:30:10: fatal error: 'boost/thread/tss.hpp' file not found
#include <boost/thread/tss.hpp> // libc++ does not have thread_local yet.
^~~~~~~~~~~~~~~~~~~~~~

1 error generated.
make[2]: *** [src/CMakeFiles/sqlpp-mysql.dir/connection.cpp.o] Error 1
make[1]: *** [src/CMakeFiles/sqlpp-mysql.dir/all] Error 2
make: *** [all] Error 2

Any idea to solve this ?

Thanks

@Fab-z4qx
Copy link
Author

Update :

If found a way to build by add theses lines into the CMakeList.txt :

INCLUDE_DIRECTORIES( ${Boost_INCLUDE_DIR} )
FIND_PACKAGE(Boost 1.69 COMPONENTS system random thread REQUIRED)

Is this an issue ?

@rbock
Copy link
Owner

rbock commented Jun 17, 2019

Thanks for posting both, issue and solution :-)

Can you prepare a pull request?

@Fab-z4qx
Copy link
Author

Fab-z4qx commented Jun 17, 2019

Hello, I dont think, I understand nothing about Cmake :D I think it need a better review to understand the problem.

Other question, how do you link the lib into your executable ?
I tried to add this line into my CMakeLists.txt :
FIND_PACKAGE(sqlpp11 REQUIRED)
target_link_libraries(${TARGET} PUBLIC sqlpp11)

On macOS, I got this error :
[build] Undefined symbols for architecture x86_64:
[build] "sqlpp::mysql::connection::connection(std::__1::shared_ptrsqlpp::mysql::connection_config const&)", referenced from:
[build] Mysql::Connect() in libBSql.a(Mysql.cc.o)
[build] "sqlpp::mysql::connection::~connection()", referenced from:
[build] Mysql::Connect() in libBSql.a(Mysql.cc.o)
[build] ld: symbol(s) not found for architecture x86_64

And on linux ubuntu :
CMake Error at src/mysql/CMakeLists.txt:22 (FIND_PACKAGE):
By not providing "Findsqlpp11.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "sqlpp11", but
CMake did not find one.

Could not find a package configuration file provided by "sqlpp11" with any
of the following names:

sqlpp11Config.cmake
sqlpp11-config.cmake

Add the installation prefix of "sqlpp11" to CMAKE_PREFIX_PATH or set
"sqlpp11_DIR" to a directory containing one of the above files. If
"sqlpp11" provides a separate development package or SDK, be sure it has
been installed.

@rbock
Copy link
Owner

rbock commented Jun 19, 2019

Not being a CMake master myself, and not having a Mac at hand, this is going to take some time, I am afraid :-)

But first off: In order to link the mysql connector into your program, you need to link the connector library. This is done for the sqlpp11-connector-mysql/tests, for instance.

@Toxe
Copy link
Contributor

Toxe commented Mar 11, 2020

Hello @z4qx, I made a PR (#58) that would remove the reliance on Boost.Thread on macOS because nowadays this isn't necessary anymore.

@xtuyaowu
Copy link

-- Using /Library/Developer/CommandLineTools/usr/bin/c++ (compiler id: AppleClang)
CMake Error at src/CMakeLists.txt:15 (find_package):
By not providing "Finddate.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "date", but
CMake did not find one.

Could not find a package configuration file provided by "date" with any of
the following names:

dateConfig.cmake
date-config.cmake

Add the installation prefix of "date" to CMAKE_PREFIX_PATH or set
"date_DIR" to a directory containing one of the above files. If "date"
provides a separate development package or SDK, be sure it has been
installed.

-- Configuring incomplete, errors occurred!
See also "/Users/admin/Documents/study/workspace/trade-test/third_party/sqlpp11-connector-mysql/build/CMakeFiles/CMakeOutput.log".

@rbock
Copy link
Owner

rbock commented Aug 22, 2021

Maybe @kovdan01 can help with that last item?

@kovdan01
Copy link
Contributor

@xtuyaowu Hello. Looks like that you do not have date library by Howard Hinnant installed – see requirements section in readme.
It is installed with sqlpp11 by default (if you do not use option USE_SYSTEM_DATE), so highly likely that you don't have sqlpp11 installed too.

I can build the library on macOS using these commands:

git clone https://github.com/rbock/sqlpp11-connector-mysql.git
cmake -S . -B build -D CMAKE_INSTALL_PREFIX=`pwd`/prefix -D CMAKE_PREFIX_PATH=/path/to/sqlpp11/prefix/
cmake --build . --target install

If you have sqlpp11 installed but are still unable to build the connector, please provide:

  • cmake command that you use
  • path to sqlpp11 installation prefix (directory where lib/cmake/Sqlpp11/Sqlpp11Config.cmake and lib/cmake/date/dateConfig.cmake are located)

@rbock rbock closed this as completed Dec 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants