I'd like to test how biicode allows me to quickly create a project that uses boost. I (think I) have followed the procedure outlined in the bii docs.
After modifying the CMakeLists.txt, the configuration step does not succeed. The boost library does not seem to build to be built. I know that sometimes the configure step needs to be done twice (according to http://forum.biicode.com/t/error-could-not-find-the-following-static-boost-libraries-boost-thread/374), but this does not help.
I have pasted the exact steps I took below. I'd be very grateful if someone could show me where I went wrong.
1. Environnement : Windows 7 x64, Visual Studio 10 SP 1
PS G:\> bii --version
3.2
PS G:\> cmake --version
cmake version 3.2.2
CMake suite maintained and supported by Kitware (kitware.com/cmake).
PS G:\>
2. Start in a clean folder (G:\biitests)
3. Init the bii project
PS G:\biitests> bii init boostUsageTest -L
Successfully initialized biicode project boostUsageTest
4. Create the G:\biitests\boostUsageTest\main.cpp file with the following contents:
#include <boost/lexical_cast.hpp>
#include <boost/thread/mutex.hpp>
#include <iostream>
#include <exception>
int main (int argc, char *argv[])
{
boost::mutex uselessMutex;
auto value = boost::lexical_cast<int>(argv[0]);
std::cout << "value = " << value << std::endl;
return 0;
}
5. bii find
PS G:\biitests\boostUsageTest> bii find
INFO: Processing changes...
WARN: There are local unresolved dependencies
They will not be searched in the server
Unresolved: boost/lexical_cast.hpp
INFO: Finding missing dependencies in server
INFO: Looking for boost/thread...
WARN: Can't find block candidate for: boost/thread
INFO: No block candidates found
6. bii configure
PS G:\biitests\boostUsageTest> bii cpp:configure -G "Visual Studio 10"
INFO: Processing changes...
Running: "cmake" -G "Visual Studio 10" -Wno-dev ..\cmake
-- The C compiler identification is MSVC 16.0.40219.1
-- The CXX compiler identification is MSVC 16.0.40219.1
-- Check for working C compiler using: Visual Studio 10 2010
-- Check for working C compiler using: Visual Studio 10 2010 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 10 2010
-- Check for working CXX compiler using: Visual Studio 10 2010 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
BLOCK: user/boostUsageTest
-----------------------------------------------------------
+ LIB: user_boostUsageTest
+ EXE: user_boostUsageTest_main
-- Configuring done
-- Generating done
-- Build files have been written to: G:/biitests/boostUsageTest/bii/build
PS G:\biitests\boostUsageTest>
7. edit CMakeLists.txt in the following way
(before my changes, the only non-commented line was ADD_BII_TARGETS() )
include(biicode/boost/setup)
INIT_BIICODE_BLOCK()
# Create Targets
ADD_BII_TARGETS()
bii_find_boost(COMPONENTS thread REQUIRED)
8. run bii find again
PS G:\biitests\boostUsageTest> bii find --update
INFO: Processing changes...
WARN: There are local unresolved dependencies
They will not be searched in the server
Unresolved: boost/lexical_cast.hpp
INFO: Finding missing dependencies in server
INFO: Looking for biicode/boost...
INFO: Block candidate: biicode/biicode/boost/master
INFO: Version biicode/boost: 9 (DEV) discarded
INFO: Version biicode/boost: 8 (STABLE) valid
INFO: Version biicode/boost: 7 (STABLE) valid
INFO: Version biicode/boost: 6 (STABLE) valid
INFO: Version biicode/boost: 5 (STABLE) valid
INFO: Version biicode/boost: 4 (STABLE) valid
INFO: Version biicode/boost: 3 (STABLE) valid
INFO: Version biicode/boost: 2 (STABLE) valid
INFO: Version biicode/boost: 1 (STABLE) valid
INFO: Version biicode/boost: 0 (STABLE) valid
INFO: Looking for boost/thread...
WARN: Can't find block candidate for: boost/thread
INFO: Analyzing compatibility for found dependencies...
Find resolved new dependencies:
biicode/boost: 8
ERROR: Find could not resolve:
boost/thread/mutex.hpp
INFO: Saving files from: toeb/cmakepp
INFO: Saving files from: biicode/boost
INFO: Saving files from: boost/install
9. Run bii configure again
PS G:\biitests\boostUsageTest> bii cpp:configure -G "Visual Studio 10"
INFO: Processing changes...
Running: "cmake" -G "Visual Studio 10" -Wno-dev ..\cmake
BLOCK: user/boostUsageTest
-----------------------------------------------------------
CALLING INIT_BIICODE_BLOCK IS NO LONGER NECESSARY
+ LIB: user_boostUsageTest
+ EXE: user_boostUsageTest_main
-- No linking type specified. Assuming static linking
-- Setting up biicode Boost configuration...
-- Building Boost 1.57.0 components with toolset msvc-10.0...
Starting thread library build job...
Building Boost components, please wait [ ]
Finished building thread library
-- Boost version: 1.57.0
CMake Error at ../deps/toeb/cmakepp/cmake/core/message.cmake:94 (_message):
Unable to find the requested Boost libraries.
Boost version: 1.57.0
Boost include path: G:/Users/bgo/.biicode/boost/1.57.0
Could not find the following static Boost libraries:
boost_thread
No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the
directory containing Boost libraries or BOOST_ROOT to the location of
Boost.
Call Stack (most recent call first):
C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/FindBoost.cmake:1182 (message)
../deps/toeb/cmakepp/cmake/targets/find_package.cmake:17 (_find_package)
../deps/boost/install/install.cmake:351 (find_package)
../../CMakeLists.txt:9 (bii_find_boost)
-- Configuring incomplete, errors occurred!
See also "G:/biitests/boostUsageTest/bii/build/CMakeFiles/CMakeOutput.log".
ERROR: CMake failed
And running bii cpp:configure after that always gives the exact same output.
Thanks a lot in advance !
Benjamin
Related
I am trying to set up a QT project with CMake (and not using QT Creator).
I am currently trying to build a minimum working example, that just shows an empty window. My current code is based (more like coppied) from this tutorial from the official (?) docs and this answer by another user to a similar question.
I then run the following three commands:
cmake .
cmake --build .
.\Debug\helloworld.exe
But nothing happens (when running the program, the first two commands appear to work as intended). If I put the code from main.cpp into an existing QT Creator project it works and shows an empty window. Anyone can tell me, what I am missing?
main.cpp
#include <QApplication>
#include <QWidget>
#include <QMainWindow>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
//Option 1, like in the mentioned stackoverflow answer
//QWidget window;
//Option 2, to test If maybe the QWidget above was the problem
QMainWindow window;
window.setWindowTitle("Test");
window.show();
return app.exec();
}
CMakeList.txt
cmake_minimum_required(VERSION 3.16)
project(helloworld VERSION 1.0.0 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Without this line, cmake does not find the package
set(CMAKE_PREFIX_PATH "C:/Qt/6.3.1/msvc2019_64")
find_package(Qt6 REQUIRED COMPONENTS Widgets)
qt_standard_project_setup()
add_executable(helloworld
main.cpp
)
target_link_libraries(helloworld PRIVATE Qt6::Widgets)
set_target_properties(helloworld PROPERTIES
WIN32_EXECUTABLE ON
MACOSX_BUNDLE ON
)
EDIT:
As suggested by Aamir I created an extra build folder. The output of the three comands is as follows:
One more thing, if I replace the code in main.cpp with a simple "Hello World" programm, it works fine. I therefore assumed, that the missing/failed parts in the first cmake command are no problem. Or am I wrong about that part?
PS H:\Coding\QT_Tic_Tac_toe> mkdir build
Directory: H:\Coding\QT_Tic_Tac_toe
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 19/08/2022 10:11 build
PS H:\Coding\QT_Tic_Tac_toe> cd .\build\
PS H:\Coding\QT_Tic_Tac_toe\build> cmake ..
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19043.
-- The CXX compiler identification is MSVC 19.32.31332.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - not found
-- Found Threads: TRUE
-- Performing Test HAVE_STDATOMIC
-- Performing Test HAVE_STDATOMIC - Success
-- Found WrapAtomic: TRUE
-- Could NOT find WrapVulkanHeaders (missing: Vulkan_INCLUDE_DIR)
-- Configuring done
-- Generating done
-- Build files have been written to: H:/Coding/QT_Tic_Tac_toe/build
PS H:\Coding\QT_Tic_Tac_toe\build> cmake --build .
Microsoft (R) Build Engine version 17.2.1+52cd2da31 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.
Checking Build System
Automatic MOC and UIC for target helloworld
Building Custom Rule H:/Coding/QT_Tic_Tac_toe/CMakeLists.txt
mocs_compilation_Debug.cpp
main.cpp
Generating Code...
helloworld.vcxproj -> H:\Coding\QT_Tic_Tac_toe\build\Debug\helloworld.exe
Building Custom Rule H:/Coding/QT_Tic_Tac_toe/CMakeLists.txt
PS H:\Coding\QT_Tic_Tac_toe\build> .\Debug\helloworld.exe
PS H:\Coding\QT_Tic_Tac_toe\build>
You need to add the Qt DLL directory to the PATH environment variable either permanently or before calling the program from the console as follows:
set PATH=C:\Qt\6.3.1\msvc2019_64\bin;%PATH%
If you would have started your application from a cmd console window an error dialog would have popped up notifying you about the missing DLL. But as you were using PowerShell there is a bug pending (see here) that prevents the error dialog to be shown.
NB: You can call cmd from a PowerShell window to get the old console window.
I tried to install mingw package from vcpkg but I got an error
C:\Users\Administrator\Downloads\vcpkg>vcpkg.exe install curl:x64-mingw-static
Computing installation plan...
The following packages will be built and installed:
curl[core,non-http,schannel,ssl,sspi]:x64-mingw-static -> 7.82.0
* zlib[core]:x64-mingw-static -> 1.2.12
Additional packages (*) will be modified to complete this operation.
Detecting compiler hash for triplet x64-mingw-static...
Error: while detecting compiler information:
The log content at C:\Users\Administrator\Downloads\vcpkg\buildtrees\detect_compiler\stdout-x64-mingw-static.log is:
-- Configuring x64-mingw-static
CMake Error at scripts/cmake/vcpkg_execute_required_process.cmake:128 (message):
Command failed: ninja -v
Working Directory: C:/Users/Administrator/Downloads/vcpkg/buildtrees/detect_compiler/x64-mingw-static-rel/vcpkg-parallel-configure
Error code: 1
See logs for more information:
C:\Users\Administrator\Downloads\vcpkg\buildtrees\detect_compiler\config-x64-mingw-static-out.log
Call Stack (most recent call first):
scripts/cmake/vcpkg_configure_cmake.cmake:370 (vcpkg_execute_required_process)
scripts/detect_compiler/portfile.cmake:18 (vcpkg_configure_cmake)
scripts/ports.cmake:145 (include)
Error: vcpkg was unable to detect the active compiler's information. See above for the CMake failure output.
C:\Users\Administrator\Downloads\vcpkg>
How can I fix it? I have mingw installed on C:/mingw64 and C:/mingw32 and I'm using them in CLion without problems
Error in config-x64-mingw-static-out.log
[1/1] cmd /c "cd .. && "C:/Users/Administrator/Downloads/vcpkg/downloads/tools/cmake-3.22.2-windows/cmake-3.22.2-windows-i386/bin/cmake.exe" "C:/Users/Administrator/Downloads/vcpkg/scripts/detect_compiler" "-DCMAKE_MAKE_PROGRAM=C:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe" "-DBUILD_SHARED_LIBS=OFF" "-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=C:/Users/Administrator/Downloads/vcpkg/scripts/toolchains/windows.cmake" "-DVCPKG_TARGET_TRIPLET=x64-windows-static" "-DVCPKG_SET_CHARSET_FLAG=ON" "-DVCPKG_PLATFORM_TOOLSET=v143" "-DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON" "-DCMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY=ON" "-DCMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_SKIP=TRUE" "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DVCPKG_APPLOCAL_DEPS=OFF" "-DCMAKE_TOOLCHAIN_FILE=C:/Users/Administrator/Downloads/vcpkg/scripts/buildsystems/vcpkg.cmake" "-DCMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION=ON" "-DVCPKG_CXX_FLAGS=" "-DVCPKG_CXX_FLAGS_RELEASE=" "-DVCPKG_CXX_FLAGS_DEBUG=" "-DVCPKG_C_FLAGS=" "-DVCPKG_C_FLAGS_RELEASE=" "-DVCPKG_C_FLAGS_DEBUG=" "-DVCPKG_CRT_LINKAGE=static" "-DVCPKG_LINKER_FLAGS=" "-DVCPKG_LINKER_FLAGS_RELEASE=" "-DVCPKG_LINKER_FLAGS_DEBUG=" "-DVCPKG_TARGET_ARCHITECTURE=x64" "-DCMAKE_INSTALL_LIBDIR:STRING=lib" "-DCMAKE_INSTALL_BINDIR:STRING=bin" "-D_VCPKG_ROOT_DIR=C:/Users/Administrator/Downloads/vcpkg" "-DZ_VCPKG_ROOT_DIR=C:/Users/Administrator/Downloads/vcpkg" "-D_VCPKG_INSTALLED_DIR=C:/Users/Administrator/Downloads/vcpkg/installed" "-DVCPKG_MANIFEST_INSTALL=OFF" "-G" "Ninja" "-DCMAKE_BUILD_TYPE=Release" "-DCMAKE_INSTALL_PREFIX=C:/Users/Administrator/Downloads/vcpkg/packages/detect_compiler_x64-windows-static""
-- The C compiler identification is MSVC 19.31.31107.0
-- The CXX compiler identification is MSVC 19.31.31107.0
#COMPILER_HASH#c3649029c7e070e5f43d9ce4d317605f000f9404
#COMPILER_C_HASH#2db604846bbf78fdf1b811ea56df2670f6b33536
#COMPILER_C_VERSION#19.31.31107.0
#COMPILER_C_ID#MSVC
#COMPILER_CXX_HASH#2db604846bbf78fdf1b811ea56df2670f6b33536
#COMPILER_CXX_VERSION#19.31.31107.0
#COMPILER_CXX_ID#MSVC
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
BUILD_SHARED_LIBS
CMAKE_INSTALL_BINDIR
CMAKE_INSTALL_LIBDIR
VCPKG_TARGET_ARCHITECTURE
_VCPKG_ROOT_DIR
-- Build files have been written to: C:/Users/Administrator/Downloads/vcpkg/buildtrees/detect_compiler/x64-windows-static-rel
It looks like it detects microsoft compiler instead of mingw
The problem was not set gcc.exe in PATH, adding it resolved problem
OS: Windows 10
Compiler: Visual Studio 2019
SOCI Version: 4.0.2
PostgreSQL Version: 13
CMake VersionL 3.20.3
I'm not too familiar with CMake so bear with me if I'm doing something uninformed and incorrectly.
Steps:
Download and execute postgresql-13.3-2-windows-x64.exe
Download and execute pgadmin4-5.3-x64.exe
Download and extract SOCI 4.0.2
Create build directory in SOCI 4.0.2
Call the following from cmd in the build directory:
cmake -G "Visual Studio 16 2019" .. -DWITH_BOOST=OFF -DWITH_POSTGRESQL=ON -DPOSTGRESQL_INCLUDE_DIR:STRING="c:/Program Files/PostgreSQL/13/include" -DPOSTGRESQL_LIBRARIES:STRING="c:/Program Files/PostgreSQL/13/lib" -DSOCI_STATIC=ON -DSOCI_SHARED=OFF
I got the following output
CMake Deprecation Warning at CMakeLists.txt:13 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
-- The C compiler identification is MSVC 19.29.30037.0
-- The CXX compiler identification is MSVC 19.29.30037.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test SOCI_HAVE_VISIBILITY_SUPPORT
-- Performing Test SOCI_HAVE_VISIBILITY_SUPPORT - Failed
-- Looking for _M_AMD64
-- Looking for _M_AMD64 - found
-- Looking for _M_IX86
-- Looking for _M_IX86 - not found
-- Configuring SOCI:
-- SOCI_VERSION = 4.0.2
-- SOCI_ABI_VERSION = 4_0
-- SOCI_SHARED = OFF
-- SOCI_STATIC = ON
-- SOCI_TESTS = ON
-- SOCI_ASAN = OFF
-- SOCI_CXX11 = OFF
-- LIB_SUFFIX = 64
-- Looking for SOCI dependencies:
-- Threads:
-- CMAKE_THREAD_LIBS_INIT =
-- Boost: disabled, since WITH_BOOST=OFF
-- MySQL:
-- Performing Test HAVE_MYSQL_OPT_EMBEDDED_CONNECTION
-- Performing Test HAVE_MYSQL_OPT_EMBEDDED_CONNECTION - Failed
-- MySQL not found.
-- MySQL Embedded not found.
-- WARNING: MySQL libraries not found, some features will be disabled.
-- ODBC:
-- ODBC_INCLUDE_DIR =
-- ODBC_LIBRARIES = odbc32.lib
-- Oracle:
-- ORACLE_HOME=
CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
The package name passed to `find_package_handle_standard_args` (ORACLE)
does not match the name of the calling package (Oracle). This can lead to
problems in calling code that expects `find_package` result variables
(e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
cmake/modules/FindOracle.cmake:84 (find_package_handle_standard_args)
cmake/dependencies/Oracle.cmake:3 (find_package)
cmake/SociDependencies.cmake:79 (include)
CMakeLists.txt:129 (include)
This warning is for project developers. Use -Wno-dev to suppress it.
-- None of the supported Oracle versions (19;18;12;11;10) could be found, consider updating ORACLE_VERSIONS if the version you use is not among them.
-- WARNING: Oracle libraries not found, some features will be disabled.
-- PostgreSQL:
-- WARNING: PostgreSQL libraries not found, some features will be disabled.
-- SQLite3:
CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
The package name passed to `find_package_handle_standard_args` (SQLITE3)
does not match the name of the calling package (SQLite3). This can lead to
problems in calling code that expects `find_package` result variables
(e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
cmake/modules/FindSQLite3.cmake:57 (find_package_handle_standard_args)
cmake/dependencies/SQLite3.cmake:3 (find_package)
cmake/SociDependencies.cmake:79 (include)
CMakeLists.txt:129 (include)
This warning is for project developers. Use -Wno-dev to suppress it.
-- SQLite3 not found (SQLITE3_INCLUDE_DIR=SQLITE3_INCLUDE_DIR-NOTFOUND, SQLITE3_LIBRARY=SQLITE3_LIBRARY-NOTFOUND.
-- WARNING: SQLite3 libraries not found, some features will be disabled.
-- Firebird:
-- SOCI_FIREBIRD_EMBEDDED = OFF
-- WARNING: Firebird libraries not found, some features will be disabled.
-- DB2:
-- WARNING: DB2 libraries not found, some features will be disabled.
-- Configuring SOCI core library:
-- SOCI_CORE_TARGET = soci_core
-- SOCI_CORE_TARGET_OUTPUT_NAME = soci_core_4_0
-- SOCI_CORE_DEPS_LIBS =
-- SOCI_CORE_INCLUDE_DIRS = C:/Users/Hbagh/Downloads/soci-4.0.2/build C:/Users/Hbagh/Downloads/soci-4.0.2/include C:/Users/Hbagh/Downloads/soci-4.0.2/build/include C:/Users/Hbagh/Downloads/soci-4.0.2/include/private C:/Users/Hbagh/Downloads/soci-4.0.2/build/src/core
-- WITH_BOOST = OFF
-- COMPILE_DEFINITIONS = _CRT_SECURE_NO_DEPRECATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNING _SCL_SECURE_NO_WARNINGS SOCI_ABI_VERSION="4_0" DBUG_OFF SOCI_LIB_PREFIX="soci_" SOCI_LIB_SUFFIX=".dll" SOCI_DEBUG_POSTFIX=""
--
-- Configuring SOCI backend libraries:
-- MySQL not found.
-- MySQL Embedded not found.
-- ORACLE_HOME=
CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
The package name passed to `find_package_handle_standard_args` (ORACLE)
does not match the name of the calling package (Oracle). This can lead to
problems in calling code that expects `find_package` result variables
(e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
cmake/modules/FindOracle.cmake:84 (find_package_handle_standard_args)
src/backends/CMakeLists.txt:17 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
-- None of the supported Oracle versions (19;18;12;11;10) could be found, consider updating ORACLE_VERSIONS if the version you use is not among them.
CMake Warning (dev) at C:/Program Files/CMake/share/cmake-3.20/Modules/FindPackageHandleStandardArgs.cmake:438 (message):
The package name passed to `find_package_handle_standard_args` (SQLITE3)
does not match the name of the calling package (SQLite3). This can lead to
problems in calling code that expects `find_package` result variables
(e.g., `_FOUND`) to follow a certain pattern.
Call Stack (most recent call first):
cmake/modules/FindSQLite3.cmake:57 (find_package_handle_standard_args)
src/backends/CMakeLists.txt:17 (find_package)
This warning is for project developers. Use -Wno-dev to suppress it.
-- SQLite3 not found (SQLITE3_INCLUDE_DIR=SQLITE3_INCLUDE_DIR-NOTFOUND, SQLITE3_LIBRARY=SQLITE3_LIBRARY-NOTFOUND.
-- Empty - SOCI backend skeleton for new backends development
-- SOCI_EMPTY = ON
-- SOCI_EMPTY_TARGET = soci_empty
-- SOCI_EMPTY_OUTPUT_NAME = soci_empty_4_0
-- SOCI_EMPTY_COMPILE_DEFINITIONS = _CRT_SECURE_NO_DEPRECATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNING _SCL_SECURE_NO_WARNINGS SOCI_ABI_VERSION="4_0" DBUG_OFF DBUG_OFF
-- SOCI_EMPTY_INCLUDE_DIRECTORIES = C:/Users/Hbagh/Downloads/soci-4.0.2/build C:/Users/Hbagh/Downloads/soci-4.0.2/include C:/Users/Hbagh/Downloads/soci-4.0.2/build/include C:/Users/Hbagh/Downloads/soci-4.0.2/include/private C:/Users/Hbagh/Downloads/soci-4.0.2/include/private
-- ODBC - SOCI backend for ODBC
-- SOCI_ODBC = ON
-- SOCI_ODBC_TARGET = soci_odbc
-- SOCI_ODBC_OUTPUT_NAME = soci_odbc_4_0
-- SOCI_ODBC_COMPILE_DEFINITIONS = _CRT_SECURE_NO_DEPRECATE _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNING _SCL_SECURE_NO_WARNINGS SOCI_ABI_VERSION="4_0" DBUG_OFF DBUG_OFF
-- SOCI_ODBC_INCLUDE_DIRECTORIES = C:/Users/Hbagh/Downloads/soci-4.0.2/build C:/Users/Hbagh/Downloads/soci-4.0.2/include C:/Users/Hbagh/Downloads/soci-4.0.2/build/include C:/Users/Hbagh/Downloads/soci-4.0.2/include/private C:/Users/Hbagh/Downloads/soci-4.0.2/include/private
--
-- Configuring SOCI tests:
-- SOCI_EMPTY_TEST_CONNSTR = dummy
-- SOCI_ODBC_TEST_ACCESS_CONNSTR = FILEDSN=C:/Users/Hbagh/Downloads/soci-4.0.2/tests/odbc/test-access.dsn
-- SOCI_ODBC_TEST_MSSQL_CONNSTR = FILEDSN=C:/Users/Hbagh/Downloads/soci-4.0.2/tests/odbc/test-mssql.dsn
-- SOCI_ODBC_TEST_MYSQL_CONNSTR = FILEDSN=C:/Users/Hbagh/Downloads/soci-4.0.2/tests/odbc/test-mysql.dsn
-- SOCI_ODBC_TEST_POSTGRESQL_CONNSTR = FILEDSN=C:/Users/Hbagh/Downloads/soci-4.0.2/tests/odbc/test-postgresql-win64.dsn
-- ODBC DB2 test disabled.
--
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:
POSTGRESQL_LIBRARIES
-- Build files have been written to: C:/Users/Hbagh/Downloads/soci-4.0.2/build
The following stands out to me:
-- PostgreSQL:
-- WARNING: PostgreSQL libraries not found, some features will be disabled.
CMake Warning:
Manually-specified variables were not used by the project:
POSTGRESQL_LIBRARIES
This refers to the original question posted by Tom Doodler, and answered by Norbert Boros, on the same topic. I am also trying to get the MySQL Connector/C or /C++ to work. Using MS Visual Studio 2017. Following the steps in the answer, did all the steps till :
Run this command ( assuming you want the STATIC DEBUG ):
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Debug -DBUILD_STATIC=true -DBUNDLE_DEPENDENCIES=ON -DSTATIC_MSVCRT=OFF -DWITH_JDBC=ON
The output on the screen says:
Configuring incomplete, errors occurred! in the last few lines. No "MYSQLCPPCONN.sln" either.
I have a pdf of the output but do not know how to attach it here. The output says three files are missing and one test failed, these are towards the end of the file, highlighted. Of course, their could be more problems that I could not identify, being a green thumb.
Any ideas about how to address this ?
I found Protobuf.sln at E:\MySQL C++ Connector Unresolved Dependencies (VS 2015) *\mysql-connector-cpp-master\cdk\protobuf*. would this be of any use ?
Here is part of the output where problems occurred (there could be more problems elsewhere, have no idea. Also, had to format the output as "code", a posting requirement on the forum ?):
-- Looking for pthread.h
-- Looking for pthread.h - not found
.
.
-- Performing Test HAVE_STATIC_ASSERT - Success
-- Performing Test HAVE_IS_SAME
-- Performing Test HAVE_IS_SAME - Failed
-- Performing Test HAVE_SHARED_PTR
-- Performing Test HAVE_SHARED_PTR - Success
-- Performing Test HAVE_SYSTEM_ERROR
-- Performing Test HAVE_SYSTEM_ERROR - Success
-- Check size of wchar_t
-- Check size of wchar_t - done
-- Looking for sys/endian.h
-- Looking for sys/endian.h - not found
-- Looking for sys/byteorder.h
-- Looking for sys/byteorder.h - not found
Wrote configuration header: E:/MySQL C++ Connector Unresolved Dependencies (VS 2
015)/mysql-connector-cpp-master/cdk/include/mysql/cdk/config.h
Legacy library soversion: 7
Looking for MySQL Client library:
CMake Error at jdbc/cmake/DepFindMySQL.cmake:128 (message):
Could not find MySQL headers at:
Point at MySQL client library location using WITH_MYSQL or
MYSQL_INCLUDE_DIR, MYSQL_LIB_DIR settings.
Call Stack (most recent call first):
jdbc/cmake/DepFindMySQL.cmake:555 (main)
cdk/cmake/dependency.cmake:42 (include)
jdbc/CMakeLists.txt:147 (find_dependency)
-- Configuring incomplete, errors occurred!
I tried to build mysql-connector-c++ from source to static library.
Referring the official spec here, I generated the Visual studio solution by the following command:
cmake -DMYSQL_DIR="E:\mysql-5.7.21-winx64" -DWITH_BOOST="E:\libs\boost_1_67_0_BUILDED" -DWITH_JDBC=ON -G "Visual Studio 15 2017 Win64" ../
Then, I opened the vs solution generated by cmake.Run build, got the two libs: mysqlcppconn8-static-mt.lib, mysqlcppconn-static-mt.lib, and copied them to my project.
When I built my project (also vs2017 version), I got the error:
mysqlcppconn-static-mt.lib(net_serv.obj) : error LNK2038: 检测到“_MSC_VER”的不匹配项: 值“1800”不匹配值“1900”(ActionProcessor.obj 中)
I am confused. They're all built in vs2017, and platform toolset are all set to "Visual Studio 2017 (v141)". I can't understand where 1800_MSC_VER has come from.
Here is what I did
Specs
Visual Studio 15, (2017)
x64
Static (.lib)
With static runtime (/MT)
Tools
CMAKE
Bison (In a folder without spaces)
Perl (ActiveState or Strawberry)
OpenSSL 1.0.2q.tar.gz
Add CMAKE, Bison and pearl to your system path
Check to see if you got all setup correctly
C:\>cmake --version
cmake version 3.9.6
C:\>bison --version
bison (GNU Bison) 2.4.1
C:\>m4 --version
m4 (GNU M4) 1.4.13
C:\>perl -version
This is perl 5, version 24, subversion 3 (v5.24.3)
Step 1: Build OpenSSL 1.0.x
Note: if you want to build OpenSSL 1.1.x steps will be a bit different
Extract to: C:\mysql-8.0.15\openssl-1.0.2q
Run: x64 Native Tools Command prompt for VS 2017
cd C:\mysql-8.0.15\openssl-1.0.2q
Release
perl Configure VC-WIN64A no-shared --openssldir=.\rel64
ms\do_win64a
nmake -f ms\nt.mak
nmake -f ms\nt.mak install
Debug
nmake -f ms\nt.mak clean
perl Configure debug-VC-WIN64A no-shared --openssldir=.\dbg64
ms\do_win64a
nmake -f ms\nt.mak
nmake -f ms\nt.mak install
Step 2: Build MySQL (Yes the actual database)
Extract to: C:\mysql-8.0.15
Run: x64 Native Tools Command prompt for VS 2017
cd C:\mysql-8.0.15\
cmake . -G "Visual Studio 15 2017 Win64" ^
-DWITH_BOOST=C:/mysql-8.0.15/boost ^
-DDOWNLOAD_BOOST=1 ^
-DBUILD_CONFIG=mysql_release ^
-DWITH_SSL=C:\mysql-8.0.15\openssl-1.0.2q\rel64 ^
-DLINK_STATIC_RUNTIME_LIBRARIES=1
Copy m4.exe to C:\mysql-8.0.15\sql\ this avoids any m4.exe errors during built
Open MySQL.sln and build for release x64
Copy binary_log_funcs.h and binary_log_types.h from mysql-8.0.15\libbinlogevents\export to mysql-8.0.15\include
The library should be located at:
Static release library: C:\mysql-8.0.15\archive_output_directory\Release\mysqlclient.lib
Step 3: Build MySQL Connector C++
Copy C:\mysql-8.0.15-dbg\archive_output_directory\Debug\mysqlclient.lib
to C:\mysql-8.0.15-dbg\lib\vs14
Run CMAKE GUI
Browse to the path of the MySQL Connector Project.
Click Configure, Select Visual studio 15 2017 Win64, native compilers
Tick BUILD_STATIC
Tick STATIC_MSVCRT
TICK WITH_JDBC
remove WIN_SSL_YASL from CONFIG_VARS
WITH_SSL = C:\mysql-8.0.15\openssl-1.0.2q\rel64
WITH_BOOST= C:\mysql-8.0.15\boost\boost_1_66_0
MYSQL_DIR=C:\mysql-8.0.15
Open MySQL_CONCPP.sln build for Release x64
The library is located at:
C:\mysql-connector-c++-8.0.15\jdbc\install\lib\mysqlcppconn-static-mt.lib
C:\mysql-connector-c++-8.0.15\Release\mysqlcppconn8-static-mt.lib
Step 4: Test it
Note: This test is for the JDBC style API. If you are not maintaining an existing application, use the new xdevapi API.
Create a new project and put the following in main.cpp
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>
#define STATIC_CONCPP
#define CONCPP_BUILD_STATIC
#define CPPCONN_PUBLIC_FUNC
#include <driver.h>
#include <connection.h>
#include <statement.h>
#include <exception.h>
sql::Driver *mDriver;
sql::Connection *mConnection;
int main() {
mDriver = get_driver_instance(); //or use: new MySQL_Driver()
try {
mConnection = mDriver->connect("host", "username", "password");
mConnection->close();
}catch(sql::SQLException& ex) {
std::cout << ex.what();
}
delete mConnection;
return 0;
}
Set: Linker > Input > Additional Dependecies:
libeay32.lib;mysqlclient.lib;mysqlcppconn8-static-mt.lib;mysqlcppconn-static-mt.lib;ssleay32.lib;%(AdditionalDependencies)
Set: Configuration Properties > VC++ Directories
Include Directories.
Library Directories.
I don't even know where to start explaining to be honest. Building this was a massive pain.
Before you begin to read this, please ensure you have the following:
C:\boost
C:\OpenSSL-Win32
C:\OpenSSL-Win64
Because I was writing my own "wrapper" and trying to make UNICODE work properly, I was getting weird exceptions, and I was unable to debug anything because I downloaded the latest package which is built without debug information (https://dev.mysql.com/downloads/connector/cpp/)
This is the first time I try to build this, so I went to their Github repository and grabbed the latest "master": https://github.com/mysql/mysql-connector-cpp
BUT! This does not contain the "JDBC" sources, which is by the way the "native" connector as they call it. So I grabbed it from the branch: https://github.com/mysql/mysql-connector-cpp/tree/jdbc and then copied the files into "mysql-connector-cpp-master\jdbc".
OK. I opened "x64 Native Tools Command Prompt for VS 2017" and navigated to "mysql-connector-cpp-master". At this point I still had no idea what I am doing and how to build it, all I could understand from the docs and different articles here is to run:
cmake -DWITH_JDBC=ON --build .
This started to configure things and build OK, but it stopped here:
-- Searching for static libraries with the base name(s) "mysqlclient"
CMake Error at FindMySQL.cmake:524 (message):
Could not find "mysql.h" from searching "/usr/include/mysql
/usr/local/include/mysql /opt/mysql/mysql/include
/opt/mysql/mysql/include/mysql /usr/local/mysql/include
/usr/local/mysql/include/mysql C:\Program Files/MySQL/*/include
C:/MySQL/*/include"
Call Stack (most recent call first):
CMakeLists.txt:332 (INCLUDE)
OK. So what now... where is "mysql.h" ?! After searching... and searching, I found this: Missing mysql.h and trying to find mysql-devel
And I quote:
Grab the MySQL Community Server and install it on your system. It
contains a directory called include in which you find the mysql.h.
Ok, great we need more stuff. So I download: https://dev.mysql.com/downloads/mysql/ and run the command again.
Happy days, something happened but no libs yet. I did get however a VS 2017 solution called: "MYSQLCPPCONN.sln".
This contains VS 2017 configuration to build the library for Win32. And of course trying to build with this solution will give you A LOT of unresolved external symbols.
So I run again the cmake but with static option added:
cmake -DWITH_JDBC=ON -DBUILD_STATIC=ON --build .
This time when I open "MYSQLCPPCONN.sln" I can see another project "mysqlcppconn-static" and this builds fine without issues.
However, in my case I need x64. I just created a new configuration for x64 by copying the exiting configuration fron Win32.
So that's it, I have both Win32 and x64 "mysqlcppconn-static.lib".
Overall Conclusion at this time:
Quite hard to build, without experience you will spend some time...
time.
No proper documentation, their existing documentation is poorly
written and very confusing.
No UNICODE support, yes the projects compile as Multi-Byte
Character Set.
I will see if I can debug and find out why am I getting exceptions in the library when using this (from their documentation):
sql::ConnectOptionsMap connection_properties;
connection_properties["hostName"] = "";
connection_properties["port"] = "";
connection_properties["userName"] = "";
connection_properties["password"] = "";
connection_properties["schema"] = "";
connection_properties["OPT_CONNECT_TIMEOUT"] = 10;
connection_properties["CLIENT_MULTI_STATEMENTS"] = (true);
connection_properties["OPT_CHARSET_NAME"] = "utf8";
connection_properties["OPT_SET_CHARSET_NAME"] = "utf8";
I hope you can build your library with this information, and hopefully in the future it will become more easier and clear.
Good Luck.