qgis link error because of libgeos.so - cmake

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.

Related

Trouble building wxwidget

I've been trying to build wxwidget 3.1.5 on Windows 10 using CMake.
I simply used the command recommended on the official website:
cmake -G "MinGW Makefiles" ..\wxWidgets-3.1.5\ -DwxBUILD_TESTS=ALL
cmake --build .
It went smoothly until a message popped up
[100%] Building CXX object tests/headers/CMakeFiles/test_headers.dir/__/__/__/__/tests/allheaders.cpp.obj
In file included from D:/tools/wxwidget/wxWidgets-3.1.5/include/wx/platform.h:343,
from D:/tools/wxwidget/wxWidgets-3.1.5/include/wx/defs.h:45,
from D:/tools/wxwidget/wxWidgets-3.1.5/include/wx/wxprec.h:12,
from D:\tools\wxwidget\wxWidgets-3.1.5\tests\testprec.h:4,
from D:\tools\wxwidget\wxWidgets-3.1.5\tests\allheaders.cpp:433:
D:/tools/wxwidget/wxWidgets-3.1.5/include/wx/wxcrtbase.h:228:39: error: redundant redeclaration of 'size_t wcsnlen(const wchar_t*, size_t)' in same scope [-Werror=redundant-decls]
228 | wxDECL_FOR_MINGW32_ALWAYS(size_t, wcsnlen, (const wchar_t*, size_t))
Anybody knows how to cope with it? Thanks in advance!
WxWidgets already provides makefile for you. All you need to do is use it 😀:
cd WxWidgets-3.1.5\build\msw
mingw32-bin.exe -f makefile.gcc BUILD=debug

undefined reference error when trying to build gprc

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

Cannot find -l<nameOfTheLibrary>, even after setting LD_LIBRARY_PATH

I'm trying to build OpenMVG, and can't resolve some dependency errors. I'm in an anaconda environment and using conda installed versions of g++ and some of the libs (I do not have root priveleges).
$ cmake --build . --target install
... (lots of output from seemingly successful steps) ...
[ 77%] Built target openMVG_sample_main_features_repeatability_dataset
[ 77%] Linking CXX executable ../../Linux-x86_64-RELEASE/openMVG_sample_features_affine
/home/user/anaconda3/envs/sfm/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -ljpeg
/home/user/anaconda3/envs/sfm/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -lpng
/home/user/anaconda3/envs/sfm/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -lz
/home/user/anaconda3/envs/sfm/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -ltiff
collect2: error: ld returned 1 exit status
gmake[2]: *** [Linux-x86_64-RELEASE/openMVG_sample_features_affine] Error 1
gmake[1]: *** [openMVG_Samples/features_affine_demo/CMakeFiles/openMVG_sample_features_affine.dir/all] Error 2
gmake: *** [all] Error 2
But libjpeg, libpng etc. are all /home/user/anaconda3/envs/sfm/lib/. For example:
(sfm) [openMVG]$ find /home/user/anaconda3/envs/sfm/ -name 'libjpeg*'
/home/user/anaconda3/envs/sfm/conda-meta/libjpeg-turbo-cos6-x86_64-1.2.1-h24432d5_0.json
/home/user/anaconda3/envs/sfm/lib/libjpeg.a
/home/user/anaconda3/envs/sfm/lib/libjpeg.so
...
So I've tried both of the following:
export LD_PRELOAD=/home/user/anaconda3/envs/sfm/lib/libjpeg.so
and
export LD_LIBRARY_PATH=/home/user/anaconda3/envs/sfm/lib/:/home/user/anaconda3/lib/:/usr/lib64/:/usr/lib/
before rerunning$ cmake --build . --target install, but get the same result.
It seems to me that the compiler couldn't find some libs. So I told it exactly where to look, and even tried preoloading them, and it still can't find them. Adding the paths to LD_LIBRARY_PATH was necessary to get this far - so it does seem to have worked for other things. Just not this problem. How do I troubleshoot from here?

CMake: Set zlib path

I'm trying to compile libzip on Windows using CMake to generate makefiles. Libzip needs zlib so I'm doing the following:
mkdir build
cd build
cmake -DZLIB_LIBRARY=../../../zlib-1.2.11 -DZLIB_INCLUDE_DIR=../../../zlib-1.2.11 ..
This doesn't work, however. I get the following error:
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
Could NOT find ZLIB (missing: ZLIB_LIBRARY ZLIB_INCLUDE_DIR)
Why is that? I have defined ZLIB_LIBRARY and ZLIB_INCLUDE_DIR to point to the latest zlib.
I've also tried the following:
mkdir build
cd build
cmake .. -DZLIB_LIBRARY=../../../zlib-1.2.11 -DZLIB_INCLUDE_DIR=../../../zlib-1.2.11
When I run CMake like this, I get the following two warnings:
CMake Warning:
Manually-specified variables were not used by the project:
ZLIB_INCLUDE_DIR
ZLIB_LIBRARY
In comparison to the first approach, however, build files are now written to my build directory. When running nmake, however, only zlib seems to get built. libzip itself isn't built at all.
I'm out of ideas here. What am I doing wrong?
To answer my own question, using relative paths for ZLIB_LIBRARY and ZLIB_INCLUDE_DIR was the problem. When using absolute paths, it works just fine. Furthermore, ZLIB_LIBRARY needs to point to the library itself. Here is my final build line which works:
cmake -DZLIB_INCLUDE_DIR=d:\mystuff\zlib-1.2.11 -DZLIB_LIBRARY=d:\mystuff\zlib-1.2.11\build\zlibstatic.lib -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release ..

Trying to use JetBrains CLion, but Cmake - c++ compiler broken after cygwin install

I have been trying to get JetBrains CLion IDE working, but I am running into a problem with Cmake and none of my research online has been helpful. I installed cygwin with the necessary packages (as stated here - gcc/g++, cmake, make, gdb). When I open up CLion and go into Settings (I'm running Windows 10) under Build>Toolchains>Debugger everything has a check next to it, so it seems like CLion has found everything alright, but when I look in the Debugger window I get the following error:
"C:\Users\Lucas Lofaro\.CLion2016.3\system\cygwin_cmake\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - Unix Makefiles" "/cygdrive/c/Users/Lucas Lofaro/ClionProjects/cracking_the_coding_interview"
-- The CXX compiler identification is GNU 5.3.0
-- Check for working CXX compiler: /usr/bin/c++.exe
-- Check for working CXX compiler: /usr/bin/c++.exe -- broken
CMake Error at /cygdrive/c/Users/Lucas Lofaro/.CLion2016.3/system/cygwin_cmake/share/cmake-3.6.2/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler "/usr/bin/c++.exe" is not able to compile a simple test
program.
It fails with the following output:
Change Dir: /cygdrive/c/Users/Lucas Lofaro/ClionProjects/cracking_the_coding_interview/cmake-build-debug/CMakeFiles/CMakeTmp
Run Build Command:"/usr/bin/make.exe" "cmTC_96921/fast"
/usr/bin/make -f CMakeFiles/cmTC_96921.dir/build.make
CMakeFiles/cmTC_96921.dir/build
make[1]: Entering directory '/cygdrive/c/Users/Lucas
Lofaro/ClionProjects/cracking_the_coding_interview/cmake-build-debug/CMakeFiles/CMakeTmp'
Building CXX object CMakeFiles/cmTC_96921.dir/testCXXCompiler.cxx.o
/usr/bin/c++.exe -o CMakeFiles/cmTC_96921.dir/testCXXCompiler.cxx.o -c
"/cygdrive/c/Users/Lucas
Lofaro/ClionProjects/cracking_the_coding_interview/cmake-build-debug/CMakeFiles/CMakeTmp/testCXXCompiler.cxx"
Linking CXX executable cmTC_96921.exe
"/cygdrive/c/Users/Lucas
Lofaro/.CLion2016.3/system/cygwin_cmake/bin/cmake.exe" -E cmake_link_script
CMakeFiles/cmTC_96921.dir/link.txt --verbose=1
/usr/bin/c++.exe -Wl,--enable-auto-import
CMakeFiles/cmTC_96921.dir/testCXXCompiler.cxx.o -o cmTC_96921.exe
-Wl,--out-implib,libcmTC_96921.dll.a
-Wl,--major-image-version,0,--minor-image-version,0
c++: fatal error: -fuse-linker-plugin, but cyglto_plugin.dll not found
compilation terminated.
CMakeFiles/cmTC_96921.dir/build.make:97: recipe for target 'cmTC_96921.exe'
failed
make[1]: *** [cmTC_96921.exe] Error 1
make[1]: Leaving directory '/cygdrive/c/Users/Lucas
Lofaro/ClionProjects/cracking_the_coding_interview/cmake-build-debug/CMakeFiles/CMakeTmp'
Makefile:126: recipe for target 'cmTC_96921/fast' failed
make: *** [cmTC_96921/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "/cygdrive/c/Users/Lucas Lofaro/ClionProjects/cracking_the_coding_interview/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "/cygdrive/c/Users/Lucas Lofaro/ClionProjects/cracking_the_coding_interview/cmake-build-debug/CMakeFiles/CMakeError.log".
I've also added the cygwin bin directory to my Path environment variable, but I am really at a loss as to what to do next. Something isn't linking up and I don't want to start digging around in Cmake files without a better understanding of what's going on. Any guidance would be much appreciated. Please let me know if I can provide any additional information.
It turns out that the cmake, make, and g++ packages were installed but not updated to their most recent versions. Rerunning cygwin installer solved my problem and everything now compiles fine.