Link MySQL Librarys in CMake - c++

I'm starting to learn how to use CMake, but I have had several problems with the linking libraries. Now my problem is with MySQL (C). As there is by default the FindMySQL.cmake I included one that I found, however, it does not solve because my libraries are in separate folders within the project.
My project structure:
/
/ CMakeLists.txt
/include
/include/mysql (...)
/lib (libmysql.lib, mysqlclient.lib, libmysql.dll)
/src (main.cpp)
/src/login (login.cpp, login.h)
/build (Build Directory of CMake)
Sorry for the lack of organization, but is that a long time since I have this problem and I'm using "angry."
My current CMakeLists:
# eGest - Product Sales by Console
# Copyright (C) 2011 Bruno Alano
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# --------------------------------------------------------------------------
# CMake - Build System
# Minium CMake Version
cmake_minimum_required (VERSION 2.6)
# Project Name
project (egest)
# Add MySQL
# find_package(MySQL REQUIRED)
include_directories(include)
set(CMAKE_LIBRARY_PATH /lib)
set(LIBS ${LIBS} mysql)
# Include Directory
include_directories(src)
# Link the MySQL
# Add Sources
add_executable(test src/egest.cpp src/login/login.cpp)
target_link_libraries(test ${LIBS})
But if I use that, return this error:
C:\Users\ALANO\eGest\build>cmake .. -G "MinGW Makefiles"
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: C:/MinGW/bin/gcc.exe
-- Check for working C compiler: C:/MinGW/bin/gcc.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe
-- Check for working CXX compiler: C:/MinGW/bin/g++.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/ALANO/eGest/build
C:\Users\ALANO\eGest\build>make
Scanning dependencies of target test
[ 50%] Building CXX object CMakeFiles/test.dir/src/egest.cpp.obj
[100%] Building CXX object CMakeFiles/test.dir/src/login/login.cpp.obj
Linking CXX executable test.exe
c:/mingw/bin/../lib/gcc/mingw32/4.6.1/../../../../mingw32/bin/ld.exe: cannot fin
d -lmysql
collect2: ld returned 1 exit status
make[2]: *** [test.exe] Error 1
make[1]: *** [CMakeFiles/test.dir/all] Error 2
make: *** [all] Error 2
Thanks, Bruno Alano.

CMAKE_LIBRARY_PATH is where CMake puts the libraries it builds, not where it looks for existing libraries.
Try adding link_directories("${PROJECT_SOURCE_DIR}/lib") before add_executable.
Then do make VERBOSE=1 to see what compiler options are being passed--hopefully one of them will be the -L (library search path) you just added.

Related

How to compile RealSense examples?

I have cloned the RealSense official source code from their Github page. There was a problem when I was compiling the example align-advanced. The following is my terminal situation:
$ cd ~/librealsense/examples/align-advanced
$ mkdir build
$ cd build
~/librealsense/examples/align-advanced/build$ cmake ..
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- 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
-- Detecting C compile features
-- Detecting C compile features - 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
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/automation/librealsense/examples/align-advanced/build
~/librealsense/examples/align-advanced/build$ make
~/librealsense/examples/align-advanced/build$
As you can see, nothing happens after typing make, and no executable files appear in the build folder.
The contents of offical CMakeList.txt are as follows:
# License: Apache 2.0. See LICENSE file in root directory.
# Copyright(c) 2019 Intel Corporation. All Rights Reserved.
# minimum required cmake version: 3.1.0
cmake_minimum_required(VERSION 3.1.0)
project(RealsenseExamplesAlignAdvanced)
if(BUILD_GRAPHICAL_EXAMPLES)
add_executable(rs-align-advanced rs-align-advanced.cpp ../../third-party/imgui/imgui.cpp ../../third-party/imgui/imgui_draw.cpp ../../third-party/imgui/imgui_impl_glfw.cpp)
set_property(TARGET rs-align-advanced PROPERTY CXX_STANDARD 11)
target_link_libraries(rs-align-advanced ${DEPENDENCIES})
include_directories(rs-align-advanced ../../common ../../third-party/imgui)
set_target_properties (rs-align-advanced PROPERTIES FOLDER Examples)
install(TARGETS rs-align-advanced RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
What is the problem?
CMake was intended to be run from the top-level directory of the entire project. This is a general CMake rule-of-thumb; it typically applies to any CMake-based project, not only RealSense.
If you want to enable the compilation of the RealSense examples, you can control it via CMake with the BUILD_EXAMPLES variable, as seen the Build Configuration documentation. This only builds a small subset of the examples, however. To build the align-advanced examples, you also need to set BUILD_GRAPHICAL_EXAMPLES:
cd ~/librealsense
mkdir build; cd build
cmake -DBUILD_EXAMPLES=true -DBUILD_GRAPHICAL_EXAMPLES=true ..
make

OpenCV makefile doesn't generate exectuable

I'm new to C++ and I'm trying to recreate the openCV tutorial with Cmake https://docs.opencv.org/master/db/df5/tutorial_linux_gcc_cmake.html
I downloaded the .exe for windows, built the sources with cmake via
cmake.exe -G "MinGW Makefiles"
Then, I tried to use the make command in the project folder with the debug flag. I received this output:
GNU Make 4.2.1
Built for i686-pc-msys
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Reading makefiles...
Reading makefile 'Makefile'...
Updating makefiles....
Considering target file 'Makefile'.
Looking for an implicit rule for 'Makefile'.
No implicit rule found for 'Makefile'.
Finished prerequisites of target file 'Makefile'.
No need to remake target 'Makefile'.
Updating goal targets....
Considering target file 'default_target'.
File 'default_target' does not exist.
Considering target file 'all'.
File 'all' does not exist.
Considering target file 'cmake_check_build_system'.
File 'cmake_check_build_system' does not exist.
Finished prerequisites of target file 'cmake_check_build_system'.
Must remake target 'cmake_check_build_system'.
Putting child 0x2004f248 (cmake_check_build_system) PID 22640 on the chain.
Live child 0x2004f248 (cmake_check_build_system) PID 22640
Microsoft Windows [Version 10.0.18362.836]
(c) 2019 Microsoft Corporation. All rights reserved.
I don't quite understand the output and googling for this didn't prove to be helpful. Since I don't have an executable file at the end (as mentioned in the tutorial), there seems to be some problem. What am I missing?
The CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
set(OpenCV_DIR "C:/Users/XXX/opencv/opencv")
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
CMake output:
cmake.exe -G "MinGW Makefiles"
CMake Warning:
No source or binary directory provided. Both will be assumed to be the
same as the current working directory, but note that this warning will
become a fatal error in future CMake releases.
-- The C compiler identification is GNU 4.9.3
-- The CXX compiler identification is GNU 4.9.3
-- Check for working C compiler: C:/Rtools/mingw_64/bin/gcc.exe
-- Check for working C compiler: C:/Rtools/mingw_64/bin/gcc.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Rtools/mingw_64/bin/g++.exe
-- Check for working CXX compiler: C:/Rtools/mingw_64/bin/g++.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenCV: C:/Users/XXX/opencv/opencv (found version "4.3.0")
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/XXX/Documents/C++
make output (minGW-32)
mingw32-make.exe VERBOSE=1
"C:\Program Files\CMake\bin\cmake.exe" -SC:\Users\XXX\Documents\C++ -BC:\Users\XXX\Documents\C++ --check-build-system CMakeFiles\Makefile.cmake 0
"C:\Program Files\CMake\bin\cmake.exe" -E cmake_progress_start C:\Users\XXX\Documents\C++\CMakeFiles C:\Users\XXX\Documents\C++\CMakeFiles\progress.marks
mingw32-make.exe -f CMakeFiles\Makefile2 all
mingw32-make.exe[1]: Entering directory 'C:/Users/XXX/Documents/C++'
mingw32-make.exe -f CMakeFiles\DisplayImage.dir\build.make CMakeFiles/DisplayImage.dir/depend
mingw32-make.exe[2]: Entering directory 'C:/Users/XXX/Documents/C++'
"C:\Program Files\CMake\bin\cmake.exe" -E cmake_depends "MinGW Makefiles" C:\Users\XXX\Documents\C++ C:\Users\XXX\Documents\C++ C:\Users\XXX\Documents\C++ C:\Users\XXX\Documents\C++ C:\Users\XXX\Documents\C++\CMakeFiles\DisplayImage.dir\DependInfo.cmake --color=
mingw32-make.exe[2]: Leaving directory 'C:/Users/XXX/Documents/C++'
mingw32-make.exe -f CMakeFiles\DisplayImage.dir\build.make CMakeFiles/DisplayImage.dir/build
mingw32-make.exe[2]: Entering directory 'C:/Users/XXX/Documents/C++'
mingw32-make.exe[2]: *** No rule to make target 'C:/Users/XXX/opencv_mingw/sources/build_mingw/lib/libopencv_dnn430.dll.a', needed by 'DisplayImage.exe'. Stop.
mingw32-make.exe[2]: Leaving directory 'C:/Users/XXX/Documents/C++'
CMakeFiles\Makefile2:94: recipe for target 'CMakeFiles/DisplayImage.dir/all' failed
mingw32-make.exe[1]: *** [CMakeFiles/DisplayImage.dir/all] Error 2
mingw32-make.exe[1]: Leaving directory 'C:/Users/XXX/Documents/C++'
makefile:102: recipe for target 'all' failed
mingw32-make.exe: *** [all] Error 2

How do I get CMake to find my test in my C library project?

I have a project here:
https://github.com/edhartnett/ncglm
It is a small C library for reading netCDF data files from the Geostationary Lightning Mapper. I have an autotools build which works fine, and I'm trying to add a CMake build.
The directory structure is simple, there is a main directory, a src directory, and a test directory.
In the main directory I have:
# This is the main cmake file for ncglm, a library to help read the
# netCDF data files from the Global Lightning Mapper (GLM) instrument
# on GOES-16 and GOES-17.
#
# Ed Hartnett 11/10/19
# This will use any cmake between 3.1 and 3.15, preferint later
# versions with updated policies.
cmake_minimum_required(VERSION 3.1...3.15)
if (${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif()
# set the project name
project(ncglm VERSION 1.0)
#Add custom CMake Module
SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/"
CACHE INTERNAL "Location of our custom CMake modules.")
# Find netCDF.
include(FindNetCDF)
include_directories("${NETCDF_INCLUDES}")
# Create a config.h.
configure_file(config.h.cmake.in config.h)
# Turn on testing.
enable_testing()
include(CTest)
# Build in this subdirectory.
add_subdirectory(src test)
In the src subdirectory I have:
# This is the cmake file for the src directory of the ncglm library.
# Ed Hartnett 11/10/19
# Build the ncglm library.
add_library(ncglm glm_read.c goes_glm.h glm_data.h)
In the test directory I have:
# This is the cmake build file for the test directory of the ncglm library.
#
# Ed Hartnett 11/10/19
enable_testing()
add_test(NAME tst_glm_read COMMAND tst_glm_read)
build_test(tst_glm_read)
add_sh_test(nc_test4 run_glm_tests)
When I build, I get:
ed#mikado:~/ncglm/build$ cmake -DNETCDF_INCLUDES=/usr/local/netcdf-c-4.7.2_hdf5-1.10.5/include -DNETCDF_LIBRARIES=/usr/local/netcdf-c-4.7.2_hdf5-1.10.5/lib .. && make test
-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 7.4.0
-- 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
-- Detecting C compile features
-- Detecting C compile features - 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
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found NetCDF: /usr/local/netcdf-c-4.7.2_hdf5-1.10.5/lib
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ed/ncglm/build
Running tests...
Test project /home/ed/ncglm/build
No tests were found!!!
How come cmake is not trying to build or run my test?
add_subdirectory(src test)
This is invalid / it doesn't do what you think it does. What you want to do is:
add_subdirectory(src)
add_subdirectory(test)
The cmake website is down right now, I can't link to it. From memory the add_subdirectory(src test) reads CMakeLists.txt in the src source directory, but builds the sources in the test build directory, the test is created inside the build directory inside CMAKE_CURRENT_BUILD_DIR. To add two source directories, you have to use two add_subdirectory().

Cmake error undefined symbols for x86_64

I am trying to compile the conv-net library in my mac osx yosemite with xcode. I even set the flags to libstdc++ still it is not linking properly.
i still get undefined symbols for architecture x86_64.
any help much appreciated.
sh-3.2# ./compile.sh
Building conv-net library
-- The C compiler identification is AppleClang 6.0.0.6000056
-- The CXX compiler identification is AppleClang 6.0.0.6000056
-- 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
-- Configuring done
WARNING: Target "testimg" requests linking to directory "/usr/local/Cellar/opencv/2.4.9/lib". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "testimg" requests linking to directory "/usr/local/Cellar/opencv/2.4.9/lib". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "testmnist" requests linking to directory "/usr/local/Cellar/opencv/2.4.9/lib". Targets may link only to libraries. CMake is dropping the item.
WARNING: Target "testmnist" requests linking to directory "/usr/local/Cellar/opencv/2.4.9/lib". Targets may link only to libraries. CMake is dropping the item.
-- Generating done
-- Build files have been written to: /var/tmp/conv-net-0.1-prealpha_buildroot
Scanning dependencies of target cvconvnet
[ 11%] Building CXX object CMakeFiles/cvconvnet.dir/src/cvsubsamplingplane.cpp.o
[ 22%] Building CXX object CMakeFiles/cvconvnet.dir/src/cvconvolutionplane.cpp.o
[ 33%] Building CXX object CMakeFiles/cvconvnet.dir/src/cvgenericplane.cpp.o
[ 44%] Building CXX object CMakeFiles/cvconvnet.dir/src/cvsourceplane.cpp.o
[ 55%] Building CXX object CMakeFiles/cvconvnet.dir/src/cvrbfplane.cpp.o
[ 66%] Building CXX object CMakeFiles/cvconvnet.dir/src/cvmaxplane.cpp.o
[ 77%] Building CXX object CMakeFiles/cvconvnet.dir/src/cvconvnetparser.cpp.o
[ 88%] Building CXX object CMakeFiles/cvconvnet.dir/src/cvfastsigmoid.cpp.o
[100%] Building CXX object CMakeFiles/cvconvnet.dir/src/cvconvnet.cpp.o
/Users/prabhubalakrishnan/Desktop/conv-net/src/cvconvnet.cpp:169:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
1 warning generated.
Linking CXX static library libcvconvnet.a
[100%] Built target cvconvnet
Scanning dependencies of target testimg
Linking CXX executable testimg
Undefined symbols for architecture x86_64:
"_main", referenced from:
implicit entry/start for main executable
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [testimg] Error 1
make[1]: *** [CMakeFiles/testimg.dir/all] Error 2
make: *** [all] Error 2
cp: testimg: No such file or directory
cp: testmnist: No such file or directory
ls: illegal option -- I
usage: ls [-ABCFGHLOPRSTUWabcdefghiklmnopqrstuwx1] [file ...]
This is my make file
cmake_minimum_required(VERSION 3.0)
PROJECT (CvConvolutionalNet)
set (CMAKE_CXX_FLAGS " -stdlib=libstdc++")
# IF() ENDIF() statements
SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
# Specify build-type as Debug if not specified already
IF (NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE Debug)
ENDIF ()
# Produce verbose makefiles
# SET(CMAKE_VERBOSE_MAKEFILE ON)
# Sources for library
SET(CVCONVNET_SRCS
src/cvsubsamplingplane.cpp
src/cvconvolutionplane.cpp
src/cvgenericplane.cpp
src/cvsourceplane.cpp
src/cvrbfplane.cpp
src/cvmaxplane.cpp
src/cvconvnetparser.cpp
src/cvfastsigmoid.cpp
src/cvconvnet.cpp
)
# Sources for test files
SET(TESTIMG_SRCS tst/)
SET(TESTMNIST_SRCS tst/)
set (CV_H /usr/local/Cellar/opencv/2.4.9/include/opencv)
set (HIGHGUI_H src/include )
set (LIBCV /usr/local/Cellar/opencv/2.4.9/lib )
set (LIBHIGHGUI /usr/local/Cellar/opencv/2.4.9/lib )
# Here are common paths (in addition to default paths)
SET (INCLUDE_SEARCH_PATH
/usr/local/include /usr/include /usr/include/opencv/
/usr/include/opencv/ c:/program\ files/opencv/include
)
SET (LIBRARY_SEARCH_PATH
/usr/local/lib /usr/lib c:/program\ files/opencv/lib c:/windows/system32
)
# Find OpenCV and Expat
FIND_PATH(CV_H NAMES cv.h PATHS ${INCLUDE_SEARCH_PATH} )
FIND_PATH(HIGHGUI_H NAMES highgui.h PATHS ${INCLUDE_SEARCH_PATH} )
FIND_PATH(EXPAT_H NAMES expat.h PATHS ${INCLUDE_SEARCH_PATH} )
FIND_LIBRARY(LIBCV NAMES cv PATHS ${LIBRARY_SEARCH_PATH} )
FIND_LIBRARY(LIBHIGHGUI NAMES highgui PATHS ${LIBRARY_SEARCH_PATH} )
FIND_LIBRARY(LIBEXPAT NAMES expat PATHS ${LIBRARY_SEARCH_PATH} )
INCLUDE_DIRECTORIES(include/ ${CV_H} ${HIGHGUI_H} ${EXPAT_H})
# Here is out library
ADD_LIBRARY(cvconvnet STATIC ${CVCONVNET_SRCS})
# Here are our test programs
ADD_EXECUTABLE(testimg ${TESTIMG_SRCS})
ADD_EXECUTABLE(testmnist ${TESTMNIST_SRCS})
# Compiler options are different for Release and Debug
IF (CMAKE_BUILD_TYPE MATCHES Release)
# Highly optimized + cancel all assert()s
ADD_DEFINITIONS(-O3 -DNDEBUG)
ELSE ()
# Include debug info, profiling info, some text output
ADD_DEFINITIONS(-O -pg -g -DDEBUG)
# Set profiling for linker too
SET_TARGET_PROPERTIES(testmnist PROPERTIES LINK_FLAGS "-pg")
ENDIF ()
# We should link our test programs to libraries
TARGET_LINK_LIBRARIES(testimg cvconvnet ${LIBCV} ${LIBHIGHGUI} ${LIBEXPAT})
TARGET_LINK_LIBRARIES(testmnist cvconvnet ${LIBCV} ${LIBHIGHGUI} ${LIBEXPAT})
I fixed it by adding -c option in the compiler flags and it worked !!!!
The add_executable command takes a target name and a list of source files to be compiled. When you are creating a target for testimg you are passing it directory.
Use file(GLOB ...) command to gather all source files from directory into a list variable and pass it to add_executable call.

Error building program with MySQL Connector C++

I have the following compile time error I cannot find the reason of:
fatal error: mysql_connection.h: No such file or directory
I am using cmake, and these are the CMakeLists.txt files:
# Top level CMakeLists.txt - MyProg
cmake_minimum_required (VERSION 2.6)
set (PROJECT_NAME "MyProg")
### Out-of-tree directories
set (UTILITIES_DIR "~/utilities")
### Configure header file to pass CMake's settings to the source code
configure_file (
"Config.h.in"
"${PROJECT_SOURCE_DIR}/Config.h"
)
add_subdirectory (src "${CMAKE_CURRENT_BINARY_DIR}/obj")
add_subdirectory (${UTILITIES_DIR} "${CMAKE_CURRENT_BINARY_DIR}/obj/external/utilities")
and
# Source level CMakeLists.txt - MyProg/src
### MySQL Connector/C++ ###
set (MYSQLCONNECTORCPP_ROOT_DIR "~/3rdParty/mysql-connector-c++-1.1.0")
### Include paths ###
include_directories (${CMAKE_CURRENT_SOURCE_DIR})
include_directories (${UTILITIES_DIR})
include_directories (${MYSQLCONNECTORCPP_ROOT_DIR})
include_directories (/usr/local/include)
link_directories (/usr/local/lib)
link_directories (${MYSQLCONNECTORCPP_ROOT_DIR}/driver)
link_directories (/usr/lib64/mysql/)
link_directories (/usr/lib64/)
link_directories (/usr/local/mysql/lib/)
add_executable (myprog
entrypoint.cpp
MyProg.cpp
MyProg_test.cpp
${UTILITIES_DIR}/DBInterface.cpp
)
target_link_libraries (myprog mysqlcppconn-static mysqlclient)
This is the output from cmake (out of source build):
> cmake ../MyProg/
-- The C compiler identification is GNU 4.7.1
-- The CXX compiler identification is GNU 4.7.1
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- 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
-- Configuring done
-- Generating done
-- Build files have been written to: ~/MyProg_prj/Debug
And this is the fatal error I get from make:
> make
Scanning dependencies of target myprog
[ 8%] Building CXX object obj/CMakeFiles/myprog.dir/entrypoint.cpp.o
In file included from ~/MyProg_prj/MyProg/src/entrypoint.cpp:18:0:
~/utilities/DBInterface.hpp:18:30: fatal error: mysql_connection.h: No such file or directory
compilation terminated.
make[2]: *** [obj/CMakeFiles/myprog.dir/entrypoint.cpp.o] Error 1
make[1]: *** [obj/CMakeFiles/myprog.dir/all] Error 2
make: *** [all] Error 2
The mysql_connection.h file is in the directory specified in the CMakeLists.txt file.
This problem happened after I upgraded Linux (before it worked correctly), but this should not be the reason. The PATH should contain everything needed.
Thank you.
Platform: Linux (OpenSuse), GCC 4.7.1, cmake, MySQL Connector C++ 1.1.0
You are most likely missing the 'libmysqlcppconn-dev' library. Once installed, you shouldn't be seeing this error.
Before updating the system, in the source code I included the MySQL header like this:
#include <mysql_connection.h>
Now I have to specify the subdirectory:
#include <driver/mysql_connection.h>
Something must have changed in how the paths are set...