cmake compile fails for project synergy-through-usb on windows - c++

I am trying to build the following c++ project from github on windows 64bit system:
synergy-through-usb.
It says I need to use cmake, so I have installed cmake latest version.
I then downloaded and unzipped the source code.
Then I ran cmake . in the folder, but I got the following error:
C:\local\projects\synergy-usb\synergy-through-usb-master>cmake .
You have called ADD_LIBRARY for library cryptopp without any source files. This typically indicates a problem with your CMakeLists.txt file
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LIBUSB_1_INCLUDE_DIR
used as include directory in directory C:/local/projects/synergy-usb/synergy-through-usb-master/src/lib/arch
used as include directory in directory C:/local/projects/synergy-usb/synergy-through-usb-master/src/lib/net
LIBUSB_1_LIBRARY
linked by target "arch" in directory C:/local/projects/synergy-usb/synergy-through-usb-master/src/lib/arch
-- Configuring incomplete, errors occurred!
See also "C:/local/projects/synergy-usb/synergy-through-usb-master/CMakeFiles/CMakeOutput.log".
I am not familiar with cmake and also the links to the instructions / guide for this git repo seem to be removed:
http://synergy-project.org/projects/synergy/wiki/Readme/?hl=pm
http://synergy-project.org/projects/synergy/wiki/Compiling/?hl=pm
Can anyone help me compile this - i.e. suggest what I need to do to get around these errors? or has anyone tried to use this project?

Related

Installing FTP Client (Library) in C++ Ubuntu

I have found this library https://github.com/embeddedmz/ftpclient-cpp on GitHub but how to install it on Linux(Ubuntu) is quite obscure.
You will need CMake to generate a makefile for the static library or
to build the tests/code coverage program. Also make sure you have
libcurl and Google Test installed.
You can follow this script
https://gist.github.com/fideloper/f72997d2e2c9fbe66459 to install
libcurl.
This tutorial will help you installing properly Google Test on Ubuntu:
https://www.eriksmistad.no/getting-started-with-google-test-on-ubuntu/
The CMake script located in the tree will produce Makefiles for the
creation of the static library and for the unit tests program.
To create a debug static library and a test binary, change directory
to the one containing the first CMakeLists.txt and :
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE:STRING=Debug
make
It is not clear to me what "to the one containing the first CMakeLists.txt" refers to. Is it the one in the Gtest? The one in Curl? Or What?
After trying both (the Cmake in Gtest and Curl) I still get the error: "No such file or directory" while trying to #include "FTPClient.h" .
UPDATE:
Listing what I am doing:
I did git clone https://github.com/embeddedmz/ftpclient-cpp.git then made the build folder, navigate into it, I tried cmake .. -DCMAKE_BUILD_TYPE:STRING=Debug (this is the literal command I inserted) and I get
Cmake Error at CmakeLists.txt: 27 (add_subdirectory): add_subdirectory given source "TestFTP" which is not an existing directory
So what is wrong so far?
After you build the library, there will be a libftpclient.a generated in your build tree.
You can install it to your system as follows:
In this case, copy libftpclient.a to /usr/local/lib and the two header files in FTP to /usr/local/include.
You should then be able to include the header files by adding the -I/usr/local/include flag and link by adding -L/usr/local/lib -lftpclient.

Adding Eigen library to c++ project using cmake

Unfortunately, i have some problems adding the headers only Eigen 3.3.7 Library to my Makefile with Cmake on my Ubuntu 18.04.4 LTS system.
I can compile my code using the library by just copying the library folder in the include directory and using
include_directories(./include/eigen3) in the CMakeLists.txt file. However, i would much prefer not having the library path hard-coded but being able set it dynamically in the CMakeLists.txt file to make sharing the project with other people easier. Unfortunately, none of the instructions i found worked for me.
I prepared the following minimum code example:
main.cpp:
#include <eigen3/Eigen/Dense>
#include <iostream>
int main()
{
Eigen::Vector3d test_vec(1.0f, 2.0f, 3.0f);
std::cout << test_vec << std::endl;
return 0;
}
CMakeLists.txt:
cmake_minimum_required(VERSION 3.0)
project(Eigen-Cmake-Test VERSION 1.0) # set the project name
find_package (Eigen3 3.3 REQUIRED NO_MODULE)
include_directories(${EIGEN_INCLUDE_DIR})
# add the executable
add_executable("${PROJECT_NAME}" ./main.cpp)
target_link_libraries("${PROJECT_NAME}" Eigen3::Eigen)
I downloaded the headers only Eigen 3.3.7 Library and renamed the folder to eigen3. The folder was then moved to:
/usr/local/share/eigen3
when i run cmake CMakeLists.txt i get the following error:
CMake Error at CMakeLists.txt:5 (find_package):
Could not find a package configuration file provided by "Eigen3" (requested
version 3.3) with any of the following names:
Eigen3Config.cmake
eigen3-config.cmake
Add the installation prefix of "Eigen3" to CMAKE_PREFIX_PATH or set
"Eigen3_DIR" to a directory containing one of the above files. If "Eigen3"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
As i checked the Eigen library folder i realized that /usr/local/share/eigen3/cmake only contained a file named Eigen3Config.cmake.in instead of Eigen3Config.cmake which was required. Why is this the case?
I tried renaming the file to Eigen3Config.cmake. Here the error was the following:
CMake Error at CMakeLists.txt:5 (find_package):
Could not find a configuration file for package "Eigen3" that is compatible
with requested version "3.3".
The following configuration files were considered but not accepted:
/usr/local/share/eigen3/cmake/Eigen3Config.cmake, version: unknown
-- Configuring incomplete, errors occurred!
Furthermore, i also tried the solutions explained stackoverflow: CMake find_package not working for Eigen? without success.
How can i make this work properly? Also i think i do not quite understand the underlying system yet. Any explanation would be appreciated.
The problems you are running into are caused by downloading the Eigen source code but not actually building the project. You may think since its a header only library that there is no build step. Well there is; it builds the package config .pc and Eigen3Config.cmake files. One of which you are trying to use.
From my previous comment the file Eigen3Config.cmake.in is a template and will be used to generate the Eigen3Config.cmake which then would be usable.
Its probably easier to install the libeigen3-dev package, it is packaged with /usr/lib/cmake/eigen3/Eigen3Config.cmake. If you insist on using Eigen from source then build and install it
If you DO want to download and install as source maybe take a look at the INSTALL file which has a "Method 2" suggesting how to use it in cmake.

Compile GLEW with CMake and Visual Studio 2019?

I tried to compile (build) GLEW source code with CMake and Visual Studio 2019 for get binaries. In directory (disk) C:\ I created folder GL and inside it, placed unzipped glew-2.1.0. In C:\GL\, I created the folder build. Because I found the file "CMakeLists.txt" in 3 folders,
C:\GL\glew-2.1.0\build\conan\test_package
C:\GL\glew-2.1.0\build\cmake
C:\GL\glew-2.1.0\build\cmake\testbuild
I tested all 3 paths in "Browse Source..." text box in CMake. In "Browse Build..." text box I pasted C:/GL/build.
In all 3 tests CMake responded:
"CMake Error: The source
"C:/GL/glew-2.1.0/build/cmake/CMakeLists.txt"
does not match the source
"C:/GL/glew-2.1.0/build/cmake/testbuild/CMakeLists.txt"
used to generate cache. Re-run cmake with a different source directory."
that is "file CMakeLists.txt in 2nd path does not match file of same name in 3rd path".
If you change the top-level source directory on which CMake runs, you should first delete your CMake cache (File > Delete Cache in CMake GUI), and run CMake from scratch to avoid these errors.
Have you tried the CMake instructions on the GLEW Github here? Try running these commands from the command line:
> cd C:/GL/glew-2.1.0/build
> cmake ./cmake
Though this deviates from the typical out-of-source build CMake idiom, this is how GLEW intends the build system be created. So on your system:
Source directory: C:/GL/glew-2.1.0/build/cmake
Build directory: C:/GL/glew-2.1.0/build
Note, the GLEW build instructions warn about the use of CMake for building this repo:
The cmake build is mostly contributer maintained. Due to the multitude of use cases this is maintained on a best effort basis. Pull requests are welcome.
Thus, you may have better luck following the typical Windows build approaches recommended here.
According to Mr. squareskittles answer-comment to my comment to his answer, that I have tested successfully, correct answer is that the folder to accommodate binaries should be C:/GL/glew-2.1.0/build or any folder you have created in glew-2.1.0. It is peculiarity of glew though. With GLFW you can create accommodating binaries folder outside it. However according to Mr.squareskittles's edit in his answer which I have tested successfully, if you delete Cashe (in CMake GUI, click File > Delete Cashe) you can create accommodating binaries folder outside glew-2.1.0. Regards.

CMake "find_package" command on a package that was not installed is unexpectedly successful

I am following chapter-02/recipe-06 in "CMake Cookbook". This particular example requires the Eigen C++ libraries.
I attempted to build the example and got the error that Eigen was not found.
CMake Error at CMakeLists.txt:9 (find_package):
Could not find a package configuration file provided by "Eigen3" (requested
version 3.3) with any of the following names:
Eigen3Config.cmake
eigen3-config.cmake
Add the installation prefix of "Eigen3" to CMAKE_PREFIX_PATH or set
"Eigen3_DIR" to a directory containing one of the above files. If "Eigen3"
provides a separate development package or SDK, be sure it has been
installed.
This was expected because the library was not installed on my system.
I then downloaded the ".zip" file for the Eigen libraries and unzipped it to an arbitrary location outside of my project. I created a "build" folder in the Eigen directory and ran cmake .. in the "build" folder. (I only ran cmake - I did NOT build or install the package.)
After running CMake on the Eigen build directory, I went back to the example code for "recipe-06" and it was magically able to find the Eigen library and built successfully even though Eigen was never built or installed.
Somehow just running CMake in the Eigen project made CMake aware of the Eigen libraries location. After doing this, any projects that do find_package to find Eigen3 somehow get the ${Eigen3_DIR} variable defined and are able to find it.
Looking at the CMake documentation for find_package I don't see any explanation of why this works. Eigen is not in any of the typical locations that find_package searches. According to the documentation it looks like it should NOT be found.
Even more interesting - it doesn't matter where I put Eigen on my system. I can put it literally anywhere and it will still find it.
According to everything I see in the documentation it should not be found... but it is found. So the question is how? Why does this work?
Additional info: I am using CMake version 3.13.3
There are 2 "origins" of XXXConfig.cmake files, used internally by find_package() call.
Usually, XXXConfig.cmake file is produced when the project is installed, and the file contains information about installed libraries and headers.
But CMake provides also an export() command, which allows to export build tree.
export(PACKAGE <name>)
Store the current build directory in the CMake user package registry for package <name>. The find_package command may consider the directory while searching for package <name>.
Eigen's CMakeLists.txt uses export() command, so the project becomes detectable with find_package just after running cmake for Eigen.

How to build tesseract4.0 from source code in windows using cmake?

I already tried the pre-compiled Leptonica binary link but I read here that I have to build this from source only. So I tried building Leptonica from source.
I downloaded the source code of Leptonica from this [link].(https://github.com/tesseract-ocr/tesseract) Then I tried to build this code using CMake. To build I used CMake GUI. In source-code path I gave where CMakeLists.txt is located and in cross compiling option I gave this scripts\buildsystems\vcpkg.cmake from this link.
But I am getting this error
CMake Error at C:/vcpkg/scripts/buildsystems/vcpkg.cmake:247 (_find_package):
Could not find a package configuration file provided by "Leptonica" (requested version 1.74) with any of the following names:
LeptonicaConfig.cmake
leptonica-config.cmake
Add the installation prefix of "Leptonica" to CMAKE_PREFIX_PATH or set
"Leptonica_DIR" to a directory containing one of the above files.
If "Leptonica" provides a separate development package or SDK,
be sure it has been installed.
For this I build leptonica separately and generated this LeptonicaConfig.cmake file as asked in this error. But now I have to change the CMakeLists.txt and set Leptonica_DIR to the directory where my this LeptonicaConfig.cmake located. I don't know how to do this I tried adding this line in cmakelists file set(Leptonica_DIR="C:\Leptonica"). But this doesn't work, may be this is wrong.
I am really stuck, I am using tesseract4.0 and Leptonica 17.6 and really new to this building process.