Cannot install MySQL connector/c++ correctly in my ubuntu - c++

I followed the instructions given by Mysql but I got an error when I want to test it.
These are my inputs:
$ git clone https://github.com/mysql/mysql-connector-cpp.git
$ cd mysql-connector-cpp
$ git checkout 8.0
$ mkdir build
$ cd build
$ cmake ..
$ cmake --build .
$ sudo cmake --build . --target install
$ cmake -DWITH_CONCPP=/usr/local/mysql/connector-c++-8.0 ../testapp
And I got an error:
Using dynamic runtime library.
Generationg 64bit code
Looking for connector libraries here: /usr/local/mysql/connector-c++-8.0/lib64
Looking for the main library mysqlcppconn8
CMake Error at CMakeLists.txt:165 (message):
Could not find MySQL Connector/C++ 8.0 library mysqlcppconn8 at specified
location: /usr/local/mysql/connector-c++-8.0/lib64
-- Configuring incomplete, errors occurred!
And here is the document link:
MySql Installing Connector/C++ from Source
This is the relevant part of the document.
To verify connector functionality, build and run one or more of the test programs included in the testapp directory of the source distribution. Create a directory to use and change location into it. Then issue the following commands:
$ cmake [other_options] -DWITH_CONCPP=concpp_install concpp_source/testapp
other_options consists of the options that you used to configure
Connector/C++ itself (-G, WITH_BOOST, BUILD_STATIC, and so forth).
concpp_source is the directory containing the Connector/C++ source
code, and concpp_install is the directory where Connector/C++ is
installed:

I also occured your problems. This is my solution:
$ git clone https://github.com/mysql/mysql-connector-cpp.git
$ cd mysql-connector-cpp
$ git checkout 8.0
$ mkdir build
$ cd build
# The problem is here: CMAKE_BUILD_TYPE default value is Debug
# so it install .so in WITH_CONCPP/lib64/debug.
$ cmake -DCMAKE_BUILD_TYPE=Release ..
# I don't know why the options "--config Debug( or Release)" is disable.
$ cmake --build .
$ sudo cmake --build . --target install
$ cmake -DWITH_CONCPP=/usr/local/mysql/connector-c++-8.0 ../testapp

Related

Building Doxygen on MSYS2 - Failing building CXX object portable.cpp

I'm trying to build doxygen from source, with MSYS2.
I've installed make, bison, flex, and libiconv using the command $ pacman -S <package> and I've installed gcc, cmake and ninja using the explicit environment naming, e.g. $ pacman -S mingw-w64-ucrt-x86_64-<package>.
The build procedure:
git clone https://github.com/doxygen/doxygen.git
cd doxygen
mkdir build
cd build
cmake -G "MSYS Makefiles" ..
make
I'm getting 24% ready without warnings, but when building portable.cpp I get errors. The CMakeError.log shows two failures:
Determining if the function iconv_open exists failed
Performing C++ SOURCE FILE Test ICONV_ACCEPTS_CONST_INPUT failed
I've tried to install the iconv library using both the short libiconv name and the mingw-w64-ucrt-x86_64-iconv name.

Build of opencv4 for c++ using cmake failing after upgrading to macOS Catalina

hi I am trying to build opencv4 from source using cmake (following https://thecodinginterface.com/blog/opencv-cpp-vscode/). I updated my macOS to 10.15 and installed the latest xcode. I git cloned repositories and make a build directory as below and I then try to configure cmake:
$ mkdir opencv
$ cd opencv
$ git clone https://github.com/opencv/opencv.git
$ cd opencv
$ git checkout tags/4.2.0
$ cd ..
$ git clone https://github.com/opencv/
$ cd opencv_contrib
$ git checkout tags/4.2.0
$ cd ..
$ cd build_opencv
$ cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=../install \
-D INSTALL_C_EXAMPLES=ON \
-D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules \
-D BUILD_EXAMPLES=ON ../opencv
I get the below errors and it seems that it's trying to find this non-existent path:
"/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework"
I have updated my mac version to 10.15 but it seems to be searching for a path under MacOSX10.14. I've looked online but I can't seem to find any suggestions?
CMake Error in /usr/local/include/opencv/build_opencv/CMakeFiles/CMakeTmp/CMakeLists.txt:
Imported target "VTK::RenderingOpenGL2" includes non-existent path
"/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework"
in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:
* The path was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and references files it does not
provide.
CMake Error in /usr/local/include/opencv/build_opencv/CMakeFiles/CMakeTmp/CMakeLists.txt:
Imported target "VTK::RenderingOpenGL2" includes non-existent path
"/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework"
in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:
* The path was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and references files it does not
provide.
CMake Error in /usr/local/include/opencv/build_opencv/CMakeFiles/CMakeTmp/CMakeLists.txt:
Imported target "VTK::RenderingOpenGL2" includes non-existent path
"/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/OpenGL.framework"
in its INTERFACE_INCLUDE_DIRECTORIES. Possible reasons include:
* The path was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and references files it does not
provide.
CMake Error at cmake/OpenCVDetectVTK.cmake:73 (try_compile):
Failed to generate test project build system.
Call Stack (most recent call first):
CMakeLists.txt:767 (include)
-- Configuring incomplete, errors occurred!
Download and install
Command Line Tools for XCode 12
from the apple developer tools downloads.
It used to work that you could execute xcode-select --install and it would do it for you, however, there is now an error occurring where it says that it cannot find the package or something like that. Therefore, this approach has to be taken.

How to build and install dpdk v.18.08 on Centos 7.6 with gcc?

I am trying to build and install dpdk v.18.08 on Centos 7.6 with gcc 4.8.5.
This is what I have done:
$ tar xvfz /opt/dpdk/dpdk-18.08/tar.gz
$ cd /opt/dpdk/dpdk-18.08
$ make -j T=x86_64-native-linuxapp-gcc install
<snip>
Build complete [x86_64-native-linuxapp-gcc]
Installation cannot run with T defined and DESTDIR undefined
How can I fix this failure to install?
If you want a specific folder to house current binaries and library, 'make config T=x86_64-native-linuxapp-gcc O=x86_64-native-linuxapp-gcc'.
This will create a folder 'x86_64-native-linuxapp-gcc'. You have set RTE_TARGET as x86_64-native-linuxapp-gcc. Then build by 'cd x86_64-native-linuxapp-gcc; make -j 10'
Edit: O in 'make config' is the target folder.

How to build the latest clang-tidy?

I've tried to build clang-tidy from sources but it complains about an undefined CMake command:
CMake Error at clang-apply-replacements/CMakeLists.txt:5 (add_clang_library):
Unknown CMake command "add_clang_library".
CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as
cmake_minimum_required(VERSION 3.9)
should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.
-- Configuring incomplete, errors occurred!
How can I build clang-tidy or, alternatively, how can I install the latest version on macOS?
Up-to-date steps:
git clone https://github.com/llvm/llvm-project.git
cd llvm-project
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" ../llvm
make install clang-tidy
Reference, ninja, and other details: my own blog post.
EDIT: this answer is out of date — the LLVM project has moved to a single git repository at https://github.com/llvm/llvm-project. See answers below for updated instructions.
clang-tidy is intended to be built inside a checkout of llvm/clang, and depends on CMake macros from the llvm project. You should check out the llvm repo, then the clang repo inside llvm/tools/clang, then the clang-tools-extra repo inside llvm/tools/clang/tools/extra. Then you can run CMake on the top-level directory, and make clang-tidy should work.
If you're not interested in building it yourself, it looks like the Homebrew formula for LLVM also includes the extra tools: https://github.com/Homebrew/homebrew-core/blob/382d3defb5bc48ce2dccd17261be70c4ada9a124/Formula/llvm.rb#L181
I had same problem as Per Mildner. Got is solved with slightly modified code YvesgereY posted (I don't have enough reputation to post a comment to that answer, hence a new answer instead).
In short, I added -G "Unix Makefiles" to cmake. Without this option, no makefile will be generated. Also, I used -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;". It didn't work when just clang-tools-extra was specified.
Here is the whole snippet:
git clone https://github.com/llvm/llvm-project.git
cd llvm-project
mkdir build
cd build
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;" ../llvm
make -j8 install-clang-tidy
#jtbandes: Thank you for the information.
I'd like to share these explicit steps for us noobs:
1. Download the released sources from LLVM Download Page
LLVM source code -> Links to the file llvm-6.0.0.src.tar.xz
Clang source code -> Links to the file cfe-6.0.0.src.tar.xz
clang-tools-extra -> Links to the file clang-tools-extra-6.0.0.src.tar.xz
2. Detar each of these into the proper directory:
$ tar -zxvf <download_dir_path>/llvm-6.0.1.src.tar.xz
$ cd llvm-6.0.1.src/tools
$ tar -zxcf <download_dir_path>/cfe-6.0.1.src.tar.xz
$ cd llvm-6.0.1.src/tools/cfe-6.0.1.src/tools
$ tar -zxvf <download_dir_path>/clang-tools-extra-6.0.1.src.tar.xz
Results in a directory llvm-6.0.1.src/tools/cfe-6.0.1.src/tools/clang-tools-extra-6.0.1.src/clang-tidy; Which is incorrect. The lang-tools-extra-6.0.1.src needs to be renamed to extra (as mentioned by #jtbandes).
3. So rename it or provide a symbolic link:
$ cd llvm-6.0.1.src/tools/cfe-6.0.1.src/tools
$ mv clang-tools-extra-6.0.1.src extra
or
$ ln -s clang-tools-extra-6.0.1.src extra
The path llvm-6.0.1.src/tools/cfe-6.0.1.src/tools/extra/clang-tidy should now be valid
4. Build it:
$ cd llvm-6.0.1.src
$ mkdir build
$ cd build
$ cmake ..
$ make
Everything should make without errors or warnings.
5. Build Output:
The build output can be found in llvm-6.0.1.src/build/bin.
For everyone who are looking for latest (LLVM 11) Windows build instructions (ensure CMake, Visual Studio 2019 and git are installed and set in PATH):
git clone --config core.autocrlf=false https://github.com/llvm/llvm-project.git
cd llvm-project
mkdir build
cd build
cmake -G "Visual Studio 16 2019" -Thost=x64 -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" ../llvm
cmake --build . --target clang-tidy --config RelWithDebInfo --parallel
cmake --build . --target clang-query --config RelWithDebInfo --parallel
This worked for me:
mkdir build
files="
llvm-12.0.1.src.tar.xz
clang-12.0.1.src.tar.xz
clang-tools-extra-12.0.1.src.tar.xz
"
for f in $files; do
echo "Untar $f"
tar xf $f
done
mv llvm-12.0.1.src llvm
mv clang-12.0.1.src llvm/tools/clang
mv clang-tools-extra-12.0.1.src llvm/tools/clang/tools/extra
cd build
cmake -G "Unix Makefiles" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr/local/llvm \
-DCLANG_BUILD_TOOLS=ON \
../llvm
make -j16 install
As of LLVM 14.0.0, sparse checkouts do no longer work (at least temporarily) and the top-level directory contains no CMakeLists.txt. I believe the tree layout has changed after LLVM 13.0.1. In consequence, none of the approaches here worked without quite some modification.
Here is how you can build version 15.0.0git (the most recent at the time of this writing). See related issue: https://github.com/llvm/llvm-project/issues/53281.
First, get the compressed code or clone with git (slower)
$ wget "https://github.com/llvm/llvm-project/archive/refs/heads/main.zip" -O llvm.zip
$ unzip llvm.zip
As usual, create a build directory and run cmake in the llvm directory.
$ mkdir /build
$ cd /build
$ cmake -G "Unix Makefiles" \
-DCMAKE_INSTALL_PREFIX=/usr/local/llvm \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra" \
/llvm-project-main/llvm
Navigate downwards in the generated files and only build clang-tidy.
$ cd /build/tools/clang/tools/extra/clang-tidy
$ make install
Cmake will install to /usr/local/llvm. Also, if you want to check out a specific version, use tags in the first step like this:
$ wget "https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-14.0.0.zip"
Note that you need to supply the matching builtin headers for running clang-tidy, which are located in GitHub under llvm-project/clang/lib/Headers and can by pointed to with -extra-arg=-I/path/to/builtin/headers.

How to Install Wt into a Custom Folder Without "fatal error: Wt/WApplication: No such file or directory"

I'm new to Wt and c++ and I just installed the Wt webframework on Ubuntu 16.04 LTS into a custom folder in my home directory. I cannot install or build any software into the /usr diretories of this computer. Even if I could, the PPA hasn't been active for 2 1/2 years, and the official Ubuntu installation instructions are also outdated. Aptitude no longer ships with Ubuntu and will eventually be discontinued.
I compliled and installed everything successfully, yet when I try to compile the Hello World example I get the following error:
g++ -o hello hello.cpp -lwt -lwthttp
fatal error: Wt/WApplication: No such file or directory
Here are my installation steps:
Boost:
wget https://dl.bintray.com/boostorg/release/1.65.1/source/boost_1_65_1.tar.bz2
tar --bzip2 -xf boost_1_65_1.tar.bz2
cd boost_1_65_1
./bootstrap.sh --prefix=../myfolder
sudo ./b2 install --prefix=../myfolder
CMake:
wget https://cmake.org/files/v3.9/cmake-3.9.2.tar.gz
tar -xvzf cmake-3.9.2.tar.gz
cd cmake-3.9.2
./configure --prefix=../myfolder
make
sudo make install
vim .profile
export PATH=$PATH:/home/ubuntu/myfolder/bin
Wt:
git clone https://github.com/emweb/wt.git
cd wt
cmake -DCMAKE_INSTALL_PREFIX:PATH=../myfolder .
-- Generating done
-- Build files have been written to: /home/ubuntu/myfolder
make
sudo make install
make -C examples
Since I'm lumping everything together in /myfolder I did not use the /build folder per the Wt installation instructions. The libwt and libboost libraries are in /myfolder/lib. I assumed all of the linking was taken care of during installation.
Any thoughts? Thanks in advance.
You have to tell your compiler to look for includes and libraries in the right folders, so instead of:
g++ -o hello hello.cpp -lwt -lwthttp
Try:
g++ -o hello hello.cpp -I/home/ubuntu/myfolder/include -L/home/ubuntu/myfolder/lib -lwt -lwthttp
Note that when you run your application, you'll also have to make sure that it can find the dynamic libs (.so files) it needs. You could do this:
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/ubuntu/myfolder/lib"