undefined reference error when trying to build gprc - cmake

I tried to build grcp with CMake on Linux, but running into some errors.
Log report
/usr/bin/ld: libgrpc++_test_config.so.1.31.0:undefined reference to 'google::ParseCommandLineFlags(int*, char***, bool)'
I've already installed gflags and gflags-devel package and I tried
ldd libgrpc++_test_config.so.1.31.0
but there is no link to gflags...
I think the cmake/gflags.cmake has some error in line 28 because find_package target is gflags but the next line TARGET become gflags:: gflags...
This is my build command:
cmake ../.. -DgRPC_INSTALL=ON -DCMAKE_BUILD_TYPE=Release -DgRPC_CARES_PROVIDER=package -DgRPC_PROTOBUF_PROVIDER=package -DgRPC_SSL_PROVIDER=package -DgRPC_ZLIB_PROVIDER=package -DgRPC_GFLAGS_PROVIDER=package -DgRPC_BUILD_TESTS=ON -DBUILD_SHARED_LIBS=ON
make
make install

Related

What is the correct syntax of llvm build in WSL Ubuntu?

I have the LLVM source and I was trying to build it from source the following build script gives me errors, what is wrong with the script, It is very likely that build script has errors in it because no one place was able to give me the correct sequence. I tried making use of the syntax given by official llvm site cmake -G -DCMAKE_BUILD_TYPE= [options] ../llvm
llvm official but it doesn't help.
cmake -G "Unix Makefiles"
-DCMAKE_BUILD_TYPE=Release
-DLLVM_TARGETS_TO_BUILD="X86"
-DLLVM_ENABLE_PROJECTS='clang;lldb;lld;mlir;clang-tools-extra;compiler-rt;libcxx;libcxxabi;libunwind'
-DLLVM_PARALLEL_COMPILE_JOBS=7
-DLLVM_PARALLEL_LINK_JOBS=1
-DLLVM_CCACHE_BUILD=ON
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++ ../llvm
Error Log :
pawan31#Jay-s-Pc:~/llvm$ cmake -G "Unix Makefiles"
ase
-DLLVM_TARGETS_TO_BUILD="X86"
-DLLVM_ENABLE_PROJECTS='clang;lldb;lld;mlir;clang-tools-extra;comCMake 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.
CMake Error: The source directory "/home/pawan31/llvm" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
pawan31#Jay-s-Pc:~/llvm$ -DCMAKE_BUILD_TYPE=Release
piler-rt;libcxx;libcxxabi;libunwind'
-DLLVM_PARALLEL_COMPILE_JOBS=7
-DLLVM_PARALLEL_LINK_JOBS=1
-DLLVM_CCACHE_BUILD=ON
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++ ../llvm-DCMAKE_BUILD_TYPE=Release: command not found
pawan31#Jay-s-Pc:~/llvm$ -DLLVM_TARGETS_TO_BUILD="X86"
-DLLVM_TARGETS_TO_BUILD=X86: command not found
pawan31#Jay-s-Pc:~/llvm$ -DLLVM_ENABLE_PROJECTS='clang;lldb;lld;mlir;clang-tools-extra;compiler-rt;libcxx;libcxxabi;libunwind'
-DLLVM_ENABLE_PROJECTS=clang;lldb;lld;mlir;clang-tools-extra;compiler-rt;libcxx;libcxxabi;libunwind: command not found
pawan31#Jay-s-Pc:~/llvm$ -DLLVM_PARALLEL_COMPILE_JOBS=7
-DLLVM_PARALLEL_COMPILE_JOBS=7: command not found
pawan31#Jay-s-Pc:~/llvm$ -DLLVM_PARALLEL_LINK_JOBS=1
-DLLVM_PARALLEL_LINK_JOBS=1: command not found
pawan31#Jay-s-Pc:~/llvm$ -DLLVM_CCACHE_BUILD=ON
-DLLVM_CCACHE_BUILD=ON: command not found
pawan31#Jay-s-Pc:~/llvm$ -DCMAKE_C_COMPILER=clang
-DCMAKE_C_COMPILER=clang: command not found
pawan31#Jay-s-Pc:~/llvm$ -DCMAKE_CXX_COMPILER=clang++ ../llvm
-DCMAKE_CXX_COMPILER=clang++: command not found

Installing LLReve using Cmake. Unknown BISON_TARGET error

I am getting the following error :
CMake Error at CMakeLists.txt:9 (BISON_TARGET):
Unknown CMake command "BISON_TARGET".
when I run the command :
cmake .. -GNinja
Please tell me what to do. I tried searching on google a lot and thus came up with the additions and finally ran the command :
cmake .. -D LLVM_DIR=/usr/lib/llvm-5.0/cmake/ -D FLEX_EXECUTABLE=/usr/local/Cellar/flex/2.5.37/bin/ -D FLEX_INCLUDE_DIR=/usr/local/Cellar/flex/2.5.37/include/ -D BISON_EXECUTABLE=/usr/bin/bison
but it still shows the same error :(.
Please someone help.
Your error is occurring because the BISON_TARGET function definition has not yet been supplied. This method, as commented, is supplied by FindBISON. The error indicates that either Bison was not found on your system (hopefully, you have it installed), or cmake was ran from the wrong directory. Bison is included in the top-level CMake file via:
find_package(BISON REQUIRED)
This line to include Bison must be called before using the BISON_TARGET CMake function. The LLReve instructions for compiling this repository are explicit about which directory to run the build commands in:
Go to the llreve directory and run
cd reve
mkdir build
cd build
cmake .. -GNinja
ninja
This would run on the CMake file in the llreve/reve directory, not the llreve/reve/reve directory. Please ensure you are running CMake from the correct location, as not running cmake on the top-level CMake file will often yield errors.

Use LLVM in a cmake build

I'm trying to build my own project that use LLVM. I downloaded the source code and the precompiled package on the official web site (last version).
http://releases.llvm.org/download.html
I downloaded :
LLVM source code
Clang for Windows (64-bit)
FYI, I don't build LLVM... only want to use it !
I followed the instruction here :
http://llvm.org/docs/CMake.html#embedding-llvm-in-your-project
in the section : "Embedding LLVM in your project"
So, I added this code :
find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
message("LLVM_INCLUDE_DIRS=${LLVM_INCLUDE_DIRS}")
message("LLVM_DEFINITIONS=${LLVM_DEFINITIONS}")
But I got several cmake error messages, here is my output :
-- Using LLVMConfig.cmake in: C:\\Luciad_src\\libs\\LLVM\\cmake\\modules
LLVM_INCLUDE_DIRS=
LLVM_DEFINITIONS=
CMake Error at C:/Luciad_src/libs/LLVM/cmake/modules/LLVM-Config.cmake:31 (list):
list sub-command REMOVE_ITEM requires two or more arguments.
Call Stack (most recent call first):
C:/Luciad_src/libs/LLVM/cmake/modules/LLVM-Config.cmake:256 (is_llvm_target_library)
components/query/CMakeLists.txt:15 (llvm_map_components_to_libnames)
Is there a problem with my script, or the packages I use ? Any idea ?
Thanks for your help
You can have the LLVM as binary or source package.
The binary package does not include CMake support. If you compare both installations (binary on the left, source after building and installing it on the right) you can see the difference:
LLVM-5.0.0-win64.exe
<=> llvm-5.0.1.src.tar.xz (build and installed)
So you need to build and install the source package first to get CMake support. On my Windows machine I needed a cmd shell with administrator rights, a Visual Studio installation, go to the downloaded and extracted sources and do:
> mkdir mybuilddir
> cd mybuilddir
> cmake ..
> cmake --build . --config Release --target INSTALL
If I now use your CMake example I get:
-- Found LLVM 5.0.1
-- Using LLVMConfig.cmake in: C:/Program Files (x86)/LLVM/lib/cmake/llvm
LLVM_INCLUDE_DIRS=C:/Program Files (x86)/LLVM/include
LLVM_DEFINITIONS=-DLLVM_BUILD_GLOBAL_ISEL -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -DUNICODE -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
-- Configuring done

qgis link error because of libgeos.so

When I try to build qgis-2.8.1 for arm on linux with cmake, I get the error below:
Linking CXX shared module ../../../output/lib/qgis/plugins/libspatialiteprovider.so
[ 54%] Built target spatialiteprovider
Scanning dependencies of target crssync
[ 54%] Building CXX object src/crssync/CMakeFiles/crssync.dir/main.cpp.o
Linking CXX executable ../../output/bin/crssync
/home/lib/trunk/qgis/../geos/geos-3.3.9-imx53-shared/lib/libgeos_c.so: undefined reference to `std::auto_ptr<geos::geom::Envelope>::auto_ptr(std::auto_ptr_ref<geos::geom::Envelope>)'
/home/lib/trunk/qgis/../geos/geos-3.3.9-imx53-shared/lib/libgeos_c.so: undefined reference to `_ZNSt8auto_ptrIN4geos4geom8EnvelopeEEcvSt12auto_ptr_refIT_EIS2_EEv'
I tried to build qgis with this configuration:
cmake -G "Unix Makefiles"
-DCMAKE_SYSTEM_NAME=Linux
-DCMAKE_INSTALL_PREFIX=/home/lib/trunk/qgis/qgis-2.8.1-imx53-shared
-DCMAKE_BUILD_TYPE=RELEASE
-DENABLE_TESTS=NO
-DWITH_POSTGRESQL=NO
-DWITH_GRASS=NO
-DWITH_PY_COMPILE=NO
-DWITH_BINDINGS=NO
-DENABLE_QT5=NO
-DWITH_QWTPOLAR=TRUE
-DWITH_QSPATIALITE=FALSE
-DWITH_PYSPATIALITE=FALSE
-DPROJ_INCLUDE_DIR=/home/lib/trunk/qgis/../proj/proj-4.8.0-imx53-shared/include
-DPROJ_LIBRARY=/home/lib/trunk/qgis/../proj/proj-4.8.0-imx53-shared/lib/libproj.so
-DGEOS_CONFIG=/home/lib/trunk/qgis/../geos/geos-3.3.9-imx53-shared/bin/geos-config
-DGEOS_INCLUDE_DIR=/home/lib/trunk/qgis/../geos/geos-3.3.9-imx53-shared/include
-DGEOS_LIBRARY=/home/lib/trunk/qgis/../geos/geos-3.3.9-imx53-shared/lib/libgeos_c.so;/home/lib/trunk/qgis/../geos/geos-3.3.9-imx53-shared/lib/libgeos.so
-DGDAL_CONFIG=/home/lib/trunk/qgis/../gdal/gdal-1.11.2-imx53-shared/bin/gdal-config
-DGDAL_INCLUDE_DIR=/home/lib/trunk/qgis/../gdal/gdal-1.11.2-imx53-shared/include
-DGDAL_LIBRARY=/home/lib/trunk/qgis/../gdal/gdal-1.11.2-imx53-shared/lib/libgdal.so;/home/lib/trunk/qgis/../libpng/libpng-1.6.3-imx53-shared/lib/libpng.so;/home/lib/trunk/qgis/../libjpeg/jpeg-6b-imx53-shared/lib/libjpeg.so;/home/lib/trunk/qgis/../libxml2/libxml2-2.7.8-imx53-shared/lib/libxml2.so
-DGSL_CONFIG=/home/lib/trunk/qgis/../gsl/gsl-1.9-imx53-shared/bin/gsl-config
-DGSL_INCLUDE_DIR=/home/lib/trunk/qgis/../gsl/gsl-1.9-imx53-shared/include
-DGSL_LIBRARY=/home/lib/trunk/qgis/../gsl/gsl-1.9-imx53-shared/lib/libgsl.so;/home/lib/trunk/qgis/../gsl/gsl-1.9-imx53-shared/lib/libgslcblas.so
-DSQLITE3_INCLUDE_DIR=/home/lib/trunk/qgis/../sqlite3/sqlite-3080803-imx53-shared/include
-DSQLITE3_LIBRARY=/home/lib/trunk/qgis/../sqlite3/sqlite-3080803-imx53-shared/lib/libsqlite3.so
-DSPATIALITE_INCLUDE_DIR=/home/lib/trunk/qgis/../libspatialite/libspatialite-4.2.0-imx53-shared/include
-DSPATIALITE_LIBRARY=/home/lib/trunk/qgis/../libspatialite/libspatialite-4.2.0-imx53-shared/lib/libspatialite.so;/home/lib/trunk/qgis/../libspatialite/libspatialite-4.2.0-imx53-shared/lib/mod_spatialite.so;/home/lib/trunk/qgis/../sqlite3/sqlite-3080803-imx53-shared/lib/libsqlite3.so;/home/lib/trunk/qgis/../libiconv/libiconv-1.14-imx53-shared/lib/libcharset.so;/home/lib/trunk/qgis/../libiconv/libiconv-1.14-imx53-shared/lib/libiconv.so
-DSPATIALINDEX_INCLUDE_DIR=/home/lib/trunk/qgis/../spatialindex/spatialindex-1.7.0-imx53-shared/include
-DSPATIALINDEX_LIBRARY=/home/lib/trunk/qgis/../spatialindex/spatialindex-1.7.0-imx53-shared/lib/libspatialindex.so;/home/lib/trunk/qgis/../spatialindex/spatialindex-1.7.0-imx53-shared/lib/libspatialindex_c.so
-DEXPAT_INCLUDE_DIR=/home/lib/trunk/qgis/../expat/expat-2.1.0-imx53-shared/include
-DEXPAT_LIBRARY=/home/lib/trunk/qgis/../expat/expat-2.1.0-imx53-shared/lib/libexpat.so
-DQWT_INCLUDE_DIR=/home/lib/trunk/qgis/../qwt/qwt-6.1.1-emb_imx53-shared/include
-DQWT_LIBRARY=/home/lib/trunk/qgis/../qwt/qwt-6.1.1-emb_imx53-shared/lib/libqwt.so;/home/lib/trunk/qgis/../qwt/qwt-6.1.1-emb_imx53-shared/lib/libqwtmathml.so
-DQWTPOLAR_INCLUDE_DIR=/home/lib/trunk/qgis/../qwtpolar/qwtpolar-1.1.1-imx53-shared/include
-DQWTPOLAR_LIBRARY=/home/lib/trunk/qgis/../qwtpolar/qwtpolar-1.1.1-imx53-shared/lib/libqwtpolar.so
-DCMAKE_SYSTEM_PROCESSOR=/home/toolchain/imx53 -DCMAKE_AR=/home/toolchain/imx53/bin/arm-cortex_a8-linux-gnueabi-ar
-DCMAKE_RANLIB=/home/toolchain/imx53/bin/arm-cortex_a8-linux-gnueabi-ranlib
-DCMAKE_NM=/home/toolchain/imx53/bin/arm-cortex_a8-linux-gnueabi-nm
-DCMAKE_OBJCOPY=/home/toolchain/imx53/bin/arm-cortex_a8-linux-gnueabi-objcopy
-DCMAKE_OBJDUMP=/home/toolchain/imx53/bin/arm-cortex_a8-linux-gnueabi-objdump
-DCMAKE_STRIP=/home/toolchain/imx53/bin/arm-cortex_a8-linux-gnueabi-strip
-DCMAKE_C_COMPILER=/home/toolchain/imx53/bin/arm-cortex_a8-linux-gnueabi-gcc
-DCMAKE_CXX_COMPILER=/home/toolchain/imx53/bin/arm-cortex_a8-linux-gnueabi-g++
Also, I built geos-3.3.9 with this configuration:
cmake -G "Unix Makefiles"
-DCMAKE_SYSTEM_NAME=Linux
-DCMAKE_INSTALL_PREFIX=/home/lib/trunk/geos/geos-3.3.9-imx53-shared
-DCMAKE_BUILD_TYPE=RELEASE
-DGEOS_ENABLE_TESTS=OFF
-DBUILD_TESTING=OFF
-DHAVE_LONG_LONG_INT_64=OFF
-DCMAKE_SYSTEM_PROCESSOR=/home/toolchain/imx53
-DCMAKE_AR=/home/toolchain/imx53/bin/arm-cortex_a8-linux-gnueabi-ar
-DCMAKE_RANLIB=/home/toolchain/imx53/bin/arm-cortex_a8-linux-gnueabi-ranlib
-DCMAKE_NM=/home/toolchain/imx53/bin/arm-cortex_a8-linux-gnueabi-nm
-DCMAKE_OBJCOPY=/home/toolchain/imx53/bin/arm-cortex_a8-linux-gnueabi-objcopy
-DCMAKE_OBJDUMP=/home/toolchain/imx53/bin/arm-cortex_a8-linux-gnueabi-objdump
-DCMAKE_STRIP=/home/toolchain/imx53/bin/arm-cortex_a8-linux-gnueabi-strip
-DCMAKE_C_COMPILER=/home/toolchain/imx53/bin/arm-cortex_a8-linux-gnueabi-gcc
-DCMAKE_CXX_COMPILER=/home/toolchain/imx53/bin/arm-cortex_a8-linux-gnueabi-g++
When I take a look at the build error of qgis, I think that this problem is caused by some configuration error of geos at built. But I do not find anything. Also I tried to assign the geos path to rpath for qgis, nothing changed.
I do not know why I get this error. If somebody has an idea, please guide me to solve this problem.
Thanks.

Using CMake with Eclipse CDT and Cygwin on Windows

For a new project we want to use CMake. We are using Eclipse CDT as IDE and Cygwin gcc.
We generated the CMakeLists.txt and followed [this tutorial (option 2)][1].
When I try to run the described Make target to generate the Makefiles with CMake, which executes
cmake -E chdir C:/projects/eclipse_ws/MyApp/Build/ cmake -G "Unix Makefiles" ../ Run CMake
I get the error
CMake Error: The source directory "C:/projects/eclipse_ws/MyApp/Build/CMake" does not exist.
If I run the command directly from a Cygwin console it works just fine, however then I have to run make also from the Cygwin console, because the Makefiles are generated with Unix paths.
EDIT:
So I fixed this issue (see my answer below).
But I'm still having problems.
When I try to run CMake as Make target in Eclipse as suggested in the tutorial I get the following errors:
cmake -E chdir Build/ cmake -G 'Unix Makefiles' ../
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
System is unknown to cmake, create:
Platform/MINGW32_NT-6.1 to use this system, please send your config file to cmake#www.cmake.org so it can be added to cmake
Your CMakeCache.txt file was copied to CopyOfCMakeCache.txt. Please send that file to cmake#www.cmake.org.
-- Check for working C compiler: /usr/bin/gcc.exe
System is unknown to cmake, create:
Platform/MINGW32_NT-6.1 to use this system, please send your config file to cmake#www.cmake.org so it can be added to cmake
-- Check for working C compiler: /usr/bin/gcc.exe -- broken
CMake Error at /usr/share/cmake-2.8.9/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):
The C compiler "/usr/bin/gcc.exe" is not able to compile a simple test
program.
It fails with the following output:
Change Dir: /cygdrive/c/projects/eclipse_ws/MyApp/Build/CMakeFiles CMakeTmp
Run Build Command:/usr/bin/make.exe "cmTryCompileExec726566634/fast"
/usr/bin/make -f CMakeFiles/cmTryCompileExec726566634.dir/build.make
CMakeFiles/cmTryCompileExec726566634.dir/build
make[1]: Entering directory
'/cygdrive/c/projects/eclipse_ws/MyApp/Build/CMakeFiles/CMakeTmp'
/usr/bin/cmake.exe -E cmake_progress_report
/cygdrive/c/projects/eclipse_ws/MyApp/Build/CMakeFiles/CMakeTmp/CMakeFiles
1
Building C object
CMakeFiles/cmTryCompileExec726566634.dir/testCCompiler.c.obj
/usr/bin/gcc.exe -o
CMakeFiles/cmTryCompileExec726566634.dir/testCCompiler.c.obj -c
/cygdrive/c/projects/eclipse_ws/MyApp/Build/CMakeFiles/CMakeTmp/testCCompiler.c
CMakeFiles/cmTryCompileExec726566634.dir/build.make:60: recipe for target
'CMakeFiles/cmTryCompileExec726566634.dir/testCCompiler.c.obj' failed
make[1]: Leaving directory
'/cygdrive/c/projects/eclipse_ws/MyApp/Build/CMakeFiles/CMakeTmp'
make[1]: *** [CMakeFiles/cmTryCompileExec726566634.dir/testCCompiler.c.obj]
Error 1
Makefile:117: recipe for target 'cmTryCompileExec726566634/fast' failed
make: *** [cmTryCompileExec726566634/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)
-- Configuring incomplete, errors occurred!
Seems like for some reason CMake assumes I have an MinGW environment and not Cygwin.
EDIT2
MinGW system was assumed, because a Git installation was in PATH before Cygwin and Git's uname command was used (which returns MinGW).
If you check "Make Target - Same as the target name" in Eclipse's Make dialog, Eclipse will add a
Run CMake
to the command (see question), which is misinterpreted by CMake.
I just unchecked "Same as the target name".