Meson on windows cannot find llvm-lib? - c++

I am trying to port a Linux Library to windows, the library uses meson for compilation. I have a dummy meson.build file:
project(
'Dummy',
'cpp',
version: '0.0.1',
license: 'GPL',
default_options : [
'cpp_std=c++latest',
'default_library=static',
'optimization=3',
'buildtype=debugoptimized'])
When I run meson configure I get:
PS C:\Users\Makogan\Documents\neverengine\build> meson compile
[0/1] Regenerating build files.
The Meson build system
Version: 0.60.3
Source dir: C:\Users\Makogan\Documents\neverengine
Build dir: C:\Users\Makogan\Documents\neverengine\build
Build type: native build
Project name: NeverEngine
Project version: 0.0.1
C++ compiler for the host machine: cl (msvc 19.13.26131.1 "Microsoft (R) C/C++ Optimizing Compiler Version 19.13.26131.1 for x64")
C++ linker for the host machine: link link 14.13.26131.1
..\meson.build:1:0: ERROR: Unknown linker(s): [['lib'], ['llvm-lib']]
The following exception(s) were encountered:
Running "lib /?" gave "[WinError 2] The system cannot find the file specified"
Running "llvm-lib /?" gave "[WinError 2] The system cannot find the file specified"
A full log can be found at C:\Users\Makogan\Documents\neverengine\build\meson-logs\meson-log.txt
FAILED: build.ninja
"C:\Python311\Scripts\meson" "--internal" "regenerate" "C:\Users\Makogan\Documents\neverengine" "C:\Users\Makogan\Documents\neverengine\build" "--backend" "ninja"
ninja: error: rebuilding 'build.ninja': subcommand failed
Why is meson automatically searching for these libraries when it is aware it is on windows?

Those aren't libraries, those are static linkers (also called archivers), which are used to produce static libraries (those ending in .a or .lib, usually). Those are pretty important to meson, and it assumes that it can find the three pieces of the toolchain (The compiler, the archiver, and the [dynamic] linker) for any given language + machine.
It is interesting to me that meson is able to pick up the cl.exe and link.exe, but not lib.exe

Related

meson cannot find a conan package, despite setting pkg_config path?

I am trying to build on windows using meson and conan.
I installed packages for VS 2017 using conan and generated the PC files in the build directory.
Inside my conan.py I have the snippet:
meson = Meson(self)
self.output.warn(self.folders.generators)
meson.configure(build_folder="build", args=[
f"-Dpkg_config_path={self.folders.generators}",
f"-Db_sanitize=undefined"
])
meson.build(args=['-j2'])
I have checked and confirmed this works and that the directory is correct.
I also tried using absolute paths by doing:
os.path.abspath(self.folders.generators)
But meson still cannot find the package for some reason.
The exact error is:
Found pkg-config: C:\msys64\mingw64\bin\pkg-config.EXE (1.8.0)
Found CMake: C:\Program Files\CMake\bin\cmake.EXE (3.22.1)
Run-time dependency vulkan-memory-allocator found: NO (tried pkgconfig and cmake)
..\meson.build:97:0: ERROR: Dependency "vulkan-memory-allocator" not found, tried pkgconfig and cmake
A full log can be found at C:\Users\Makogan\Documents\neverengine\build\meson-logs\meson-log.txt
FAILED: build.ninja
"C:\Python311\Scripts\meson" "--internal" "regenerate" "C:\Users\Makogan\Documents\neverengine" "C:\Users\Makogan\Documents\neverengine\build" "--backend" "ninja"
ninja: error: rebuilding 'build.ninja': subcommand failed
ERROR: conanfile.py: Error in build() method, line 108
meson.build(args=['-j2'])
ConanException: Error 1 while executing ninja -C "C:\Users\Makogan\Documents\neverengine\build" -j2
It does work if I do meson --reconfigure -Dpkg_config=<path>.
I am confused.
Try specify instead -Dbuild.pkg_config_path=... from this
Since 0.51.0, some options are specified per machine rather than
globally for all machine configurations. Prefixing the option with
build. just affects the build machine configuration...
build.pkg_config_path controls the paths pkg-config will search for
just native: true dependencies (build machine).
PS, the version of meson and that you have native build I deduced from your previous question ;)

How to run a Tensorflow-Lite inference in (Android Studio) NDK (C / C++ API)?

Info
I built a Tensorflow (TF) model from Keras and converted it to Tensorflow-Lite (TFL)
I built an Android app in Android Studio and used the Java API to run the TFL model
In the Java app, I used the TFL Support Library (see here), and the TensorFlow Lite AAR from JCenter by including implementation 'org.tensorflow:tensorflow-lite:+' under my build.gradle dependencies
Inference times are not so great, so now I want to use TFL in Android's NDK.
So I built an exact copy of the Java app in Android Studio's NDK, and now I'm trying to include the TFL libs in the project. I followed TensorFlow-Lite's Android guide and built the TFL library locally (and got an AAR file), and included the library in my NDK project in Android Studio.
Now I'm trying to use the TFL library in my C++ file, by trying to #include it in code, but I get an error message: cannot find tensorflow (or any other name I'm trying to use, according to the name I give it in my CMakeLists.txt file).
Files
App build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.ndk.tflite"
minSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
externalNativeBuild {
cmake {
cppFlags ""
}
}
ndk {
abiFilters 'arm64-v8a'
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
// tf lite
aaptOptions {
noCompress "tflite"
}
externalNativeBuild {
cmake {
path "src/main/cpp/CMakeLists.txt"
version "3.10.2"
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
// tflite build
compile(name:'tensorflow-lite', ext:'aar')
}
Project build.gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.2'
}
}
allprojects {
repositories {
google()
jcenter()
// native tflite
flatDir {
dirs 'libs'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
CMakeLists.txt:
cmake_minimum_required(VERSION 3.4.1)
add_library( # Sets the name of the library.
native-lib
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
native-lib.cpp )
add_library( # Sets the name of the library.
tensorflow-lite
# Sets the library as a shared library.
SHARED
# Provides a relative path to your source file(s).
native-lib.cpp )
find_library( # Sets the name of the path variable.
log-lib
# Specifies the name of the NDK library that
# you want CMake to locate.
log )
target_link_libraries( # Specifies the target library.
native-lib tensorflow-lite
# Links the target library to the log library
# included in the NDK.
${log-lib} )
native-lib.cpp:
#include <jni.h>
#include <string>
#include "tensorflow"
extern "C" JNIEXPORT jstring JNICALL
Java_com_xvu_f32c_1jni_MainActivity_stringFromJNI(
JNIEnv* env,
jobject /* this */) {
std::string hello = "Hello from C++";
return env->NewStringUTF(hello.c_str());
}
class FlatBufferModel {
// Build a model based on a file. Return a nullptr in case of failure.
static std::unique_ptr<FlatBufferModel> BuildFromFile(
const char* filename,
ErrorReporter* error_reporter);
// Build a model based on a pre-loaded flatbuffer. The caller retains
// ownership of the buffer and should keep it alive until the returned object
// is destroyed. Return a nullptr in case of failure.
static std::unique_ptr<FlatBufferModel> BuildFromBuffer(
const char* buffer,
size_t buffer_size,
ErrorReporter* error_reporter);
};
Progress
I also tried to follow these:
Problems with using tensorflow lite C++ API in Android Studio Project
Android C++ NDK : some shared libraries refuses to link in runtime
How to build TensorFlow Lite as a static library and link to it from a separate (CMake) project?
how to set input of Tensorflow Lite C++
How can I build only TensorFlow lite and not all TensorFlow from source?
but in my case I used Bazel to build the TFL libs.
Trying to build the classification demo of (label_image), I managed to build it and adb push to my device, but when trying to run I got the following error:
ERROR: Could not open './mobilenet_quant_v1_224.tflite'.
Failed to mmap model ./mobilenet_quant_v1_224.tflite
I followed zimenglyu's post: trying to set android_sdk_repository / android_ndk_repository in WORKSPACE got me an error: WORKSPACE:149:1: Cannot redefine repository after any load statement in the WORKSPACE file (for repository 'androidsdk'), and locating these statements at different places resulted in the same error.
I deleted these changes to WORKSPACE and continued with zimenglyu's post: I've compiled libtensorflowLite.so, and edited CMakeLists.txt so that the libtensorflowLite.so file was referenced, but left the FlatBuffer part out. The Android project compiled successfully, but there was no evident change, I still can't include any TFLite libraries.
Trying to compile TFL, I added a cc_binary to tensorflow/tensorflow/lite/BUILD (following the label_image example):
cc_binary(
name = "native-lib",
srcs = [
"native-lib.cpp",
],
linkopts = tflite_experimental_runtime_linkopts() + select({
"//tensorflow:android": [
"-pie",
"-lm",
],
"//conditions:default": [],
}),
deps = [
"//tensorflow/lite/c:common",
"//tensorflow/lite:framework",
"//tensorflow/lite:string_util",
"//tensorflow/lite/delegates/nnapi:nnapi_delegate",
"//tensorflow/lite/kernels:builtin_ops",
"//tensorflow/lite/profiling:profiler",
"//tensorflow/lite/tools/evaluation:utils",
] + select({
"//tensorflow:android": [
"//tensorflow/lite/delegates/gpu:delegate",
],
"//tensorflow:android_arm64": [
"//tensorflow/lite/delegates/gpu:delegate",
],
"//conditions:default": [],
}),
)
and trying to build it for x86_64, and arm64-v8a I get an error: cc_toolchain_suite rule #local_config_cc//:toolchain: cc_toolchain_suite '#local_config_cc//:toolchain' does not contain a toolchain for cpu 'x86_64'.
Checking external/local_config_cc/BUILD (which provided the error) in line 47:
cc_toolchain_suite(
name = "toolchain",
toolchains = {
"k8|compiler": ":cc-compiler-k8",
"k8": ":cc-compiler-k8",
"armeabi-v7a|compiler": ":cc-compiler-armeabi-v7a",
"armeabi-v7a": ":cc-compiler-armeabi-v7a",
},
)
and these are the only 2 cc_toolchains found. Searching the repository for "cc-compiler-" I only found "aarch64", which I assumed is for the 64-bit ARM, but nothing with "x86_64". There are "x64_windows", though - and I'm on Linux.
Trying to build with aarch64 like so:
bazel build -c opt --fat_apk_cpu=aarch64 --cpu=aarch64 --host_crosstool_top=#bazel_tools//tools/cpp:toolchain //tensorflow/lite/java:tensorflow-lite
results in an error:
ERROR: /.../external/local_config_cc/BUILD:47:1: in cc_toolchain_suite rule #local_config_cc//:toolchain: cc_toolchain_suite '#local_config_cc//:toolchain' does not contain a toolchain for cpu 'aarch64'
Using the libraries in Android Studio:
I was able to build the library for x86_64 architecture by changing the soname in build config and using full paths in CMakeLists.txt. This resulted in a .so shared library. Also - I was able to build the library for arm64-v8a using the TFLite Docker container, by adjusting the aarch64_makefile.inc file, but I did not change any build options, and let build_aarch64_lib.sh whatever it builds. This resulted in a .a static library.
So now I have two TFLite libs, but I'm still unable to use them (I can't #include "..." anything for example).
When trying to build the project, using only x86_64 works fine, but trying to include the arm64-v8a library results in ninja error: '.../libtensorflow-lite.a', needed by '.../app/build/intermediates/cmake/debug/obj/armeabi-v7a/libnative-lib.so', missing and no known rule to make it.
Different approach - build/compile source files with Gradle:
I created a Native C++ project in Android Studio
I took the basic C/C++ source files and headers from Tensorflow's lite directory, and created a similar structure in app/src/main/cpp, in which I include the (A) tensorflow, (B) absl and (C) flatbuffers files
I changed the #include "tensorflow/... lines in all of tensorflow's header files to relative paths so the compiler can find them.
In the app's build.gradle I added a no-compression line for the .tflite file: aaptOptions { noCompress "tflite" }
I added an assets directory to the app
In native-lib.cpp I added some example code from the TFLite website
Tried to build the project with the source files included (build target is arm64-v8a).
I get an error:
/path/to/Android/Sdk/ndk/20.0.5594570/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include/c++/v1/memory:2339: error: undefined reference to 'tflite::impl::Interpreter::~Interpreter()'
in <memory>, line 2339 is the "delete __ptr;" line:
_LIBCPP_INLINE_VISIBILITY void operator()(_Tp* __ptr) const _NOEXCEPT {
static_assert(sizeof(_Tp) > 0,
"default_delete can not delete incomplete type");
static_assert(!is_void<_Tp>::value,
"default_delete can not delete incomplete type");
delete __ptr;
}
Question
How can I include the TFLite libraries in Android Studio, so I can run a TFL inference from the NDK?
Alternatively - how can I use gradle (currently with cmake) to build and compile the source files?
I use Native TFL with C-API in the following way:
SETUP:
Download the latest version of TensorFlow Lite AAR file
Change the file type of downloaded .arr file to .zip and unzip the file to get the shared library (.so file)
Download all header files from the c directory in the TFL repository
Create an Android C++ app in Android Studio
Create a jni directory (New -> Folder -> JNI Folder) in app/src/main and also create architecture sub-directories in it (arm64-v8a or x86_64 for example)
Put all header files in the jni directory (next to the architecture directories), and put the shared library inside the architecture directory/ies
Open the CMakeLists.txt file and include an add_library stanza for the TFL library, the path to the shared library in a set_target_properties stanza and the headers in include_directories stanza (see below, in NOTES section)
Sync Gradle
USAGE:
In native-lib.cpp include the headers, for example:
#include "../jni/c_api.h"
#include "../jni/common.h"
#include "../jni/builtin_ops.h"
TFL functions can be called directly, for example:
TfLiteModel * model = TfLiteModelCreateFromFile(full_path);
TfLiteInterpreter * interpreter = TfLiteInterpreterCreate(model);
TfLiteInterpreterAllocateTensors(interpreter);
TfLiteTensor * input_tensor =
TfLiteInterpreterGetInputTensor(interpreter, 0);
const TfLiteTensor * output_tensor =
TfLiteInterpreterGetOutputTensor(interpreter, 0);
TfLiteStatus from_status = TfLiteTensorCopyFromBuffer(
input_tensor,
input_data,
TfLiteTensorByteSize(input_tensor));
TfLiteStatus interpreter_invoke_status = TfLiteInterpreterInvoke(interpreter);
TfLiteStatus to_status = TfLiteTensorCopyToBuffer(
output_tensor,
output_data,
TfLiteTensorByteSize(output_tensor));
NOTES:
In this setup SDK version 29 was used
cmake environment also included cppFlags "-frtti -fexceptions"
CMakeLists.txt example:
set(JNI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../jni)
add_library(tflite-lib SHARED IMPORTED)
set_target_properties(tflite-lib
PROPERTIES IMPORTED_LOCATION
${JNI_DIR}/${ANDROID_ABI}/libtfl.so)
include_directories( ${JNI_DIR} )
target_link_libraries(
native-lib
tflite-lib
...)
I have also struggled with building TF Lite C++ APIs for Android. Fortunately, I managed to make it work.
The problem is we need to configure the Bazel build process before running the bazel build ... commands. The TF Lite Android Quick Start guide doesn't mention it.
Step-by-step guide (https://github.com/cuongvng/TF-Lite-Cpp-API-for-Android):
Step 1: Install Bazel
Step 2: Clone the TensorFlow repo
git clone https://github.com/tensorflow/tensorflow
cd ./tensorflow/
Step 3: Configure Android build
Before running the bazel build ... command, you need to configure the build process. Do so by executing
./configure
The configure file is at the root of the tensorflow directory, which you cd to at Step 2.
Now you have to input some configurations on the command line:
$ ./configure
You have bazel 3.7.2-homebrew installed.
Please specify the location of python. [Default is /Library/Developer/CommandLineTools/usr/bin/python3]: /Users/cuongvng/opt/miniconda3/envs/style-transfer-tf-lite/bin/python
First is the location of python, because ./configure executes the .configure.py file.
Choose the location that has Numpy installed, otherwise the later build will fail.
Here I point it to the python executable of a conda environment.
Next,
Found possible Python library paths:
/Users/cuongvng/opt/miniconda3/envs/style-transfer-tf-lite/lib/python3.7/site-packages
Please input the desired Python library path to use. Default is [/Users/cuongvng/opt/miniconda3/envs/style-transfer-tf-lite/lib/python3.7/site-packages]
I press Enter to use the default site-packages, which contains necessary libraries to build TF.
Next,
Do you wish to build TensorFlow with ROCm support? [y/N]: N
No ROCm support will be enabled for TensorFlow.
Do you wish to build TensorFlow with CUDA support? [y/N]: N
No CUDA support will be enabled for TensorFlow.
Do you wish to download a fresh release of clang? (Experimental) [y/N]: N
Clang will not be downloaded.
Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -Wno-sign-compare]:
Key in as showed above, on the last line type Enter.
Then it asks you whether to configure ./WORKSPACE for Android builds, type y to add configurations.
Would you like to interactively configure ./WORKSPACE for Android builds? [y/N]: y
Searching for NDK and SDK installations.
Please specify the home path of the Android NDK to use. [Default is /Users/cuongvng/library/Android/Sdk/ndk-bundle]: /Users/cuongvng/Library/Android/sdk/ndk/21.1.6352462
That is the home path of the Android NDK (version 21.1.6352462) on my local machine.
Note that when you ls the path, it must include platforms, e.g.:
$ ls /Users/cuongvng/Library/Android/sdk/ndk/21.1.6352462
CHANGELOG.md build ndk-stack prebuilt source.properties wrap.sh
NOTICE meta ndk-which python-packages sources
NOTICE.toolchain ndk-build package.xml shader-tools sysroot
README.md ndk-gdb platforms simpleperf toolchains
For now I ignore the resulting WARNING, then choose the min NDK API level
WARNING: The NDK version in /Users/cuongvng/Library/Android/sdk/ndk/21.1.6352462 is 21, which is not supported by Bazel (officially supported versions: [10, 11, 12, 13, 14, 15, 16, 17, 18]). Please use another version. Compiling Android targets may result in confusing errors.
Please specify the (min) Android NDK API level to use. [Available levels: ['16', '17', '18', '19', '21', '22', '23', '24', '26', '27', '28', '29']] [Default is 21]: 29
Next
Please specify the home path of the Android SDK to use. [Default is /Users/cuongvng/library/Android/Sdk]: /Users/cuongvng/Library/Android/sdk
Please specify the Android SDK API level to use. [Available levels: ['28', '29', '30']] [Default is 30]: 30
Please specify an Android build tools version to use. [Available versions: ['29.0.2', '29.0.3', '30.0.3', '31.0.0-rc1']] [Default is 31.0.0-rc1]: 30.0.3
That is all for Android build configs. Choose N for all questions appearing later:
Step 4: Build the shared library (.so)
Now you can run the bazel build command to generate libraries for your target architecture:
bazel build -c opt --config=android_arm //tensorflow/lite:libtensorflowlite.so
# or
bazel build -c opt --config=android_arm64 //tensorflow/lite:libtensorflowlite.so
It should work without errors.
The generated library would be saved at ./bazel-bin/tensorflow/lite/libtensorflowlite.so.

how to make superlu in windows

I have downloaded armadillo 6.5. it needs superLU(4.3) library to solve sparse matrix system of equations.
I have downloaded superlu from here but when i want to make it in windows, it gives:
( cd SRC; make )
process_begin: CreateProcess(NULL, ( cd SRC; make ), ...) failed.
make (e=2): The system cannot find the file specified.
Makefile:36: recipe for target 'superlulib' failed
make: *** [superlulib] Error 2
if i cd to SRC directory manually and do make in there, a lot of *.o file is created but again i get this error:
ar cr /Codes/SuperLU/SuperLU_4.3/lib/libsuperlu_4.3.a \
sgssv.o sgssvx.o ssp_blas2.o ssp_blas3.o sgscon.o slangs.o sgsequ.o slaqgs.o spivotgrowth.o sgsrfs.o sgstrf.o sgstrs.o scopy_to_ucol.o ssnode_dfs.o ssnode_bmod.o spanel_dfs.o sp
anel_bmod.o sreadhb.o sreadrb.o sreadtriple.o scolumn_dfs.o scolumn_bmod.o spivotL.o spruneL.o smemory.o sutil.o smyblas2.o sgsisx.o sgsitrf.o sldperm.o ilu_sdrop_row.o ilu_ssnode_dfs.o
ilu_scolumn_dfs.o ilu_spanel_dfs.o ilu_scopy_to_ucol.o ilu_spivotL.o sdiagonal.o superlu_timer.o util.o memory.o get_perm_c.o mmd.o sp_coletree.o sp_preorder.o sp_ienv.o relax_snode.o
heap_relax_snode.o colamd.o ilu_relax_snode.o ilu_heap_relax_snode.o mark_relax.o mc64ad.o qselect.o lsame.o xerbla.o slacon.o slamch.o
ar: /Codes/SuperLU/SuperLU_4.3/lib/libsuperlu_4.3.a: No such file or directory
Makefile:117: recipe for target 'single' failed
make: *** [single] Error 1
i almost have no experience with "make" and "superlu". how can i make superlu in windows? is there any precompiled superlu library available for windows?
Well, it seems that makefile is written for linux systems.
I could do three thing:
follow the instructions on superLU FAQ page:
This was tested in MS Visual Studio. However the configuration highly
depends on which compiler you using. Normally there is an IDE
(Integrated Development Environment) editor associated with your
compiler. You can do it in two steps:
Step I: Create SuperLU library file
Create a new project, then include all the .c and .h files in SRC directory (they can be put in two folders of the IDE).
Change the property of the project to make the output as Library file .lib (not .exe or .dll file).
Compile the project to produce the library file, e.g. superlu.lib. (after you successfully compile it, you can build a
release version without the debug information).
Step II: Build your own application Create a new project with your own
source files which call the SuperLU routines.Add the SRC directory and
the directory where superlu.lib is located to the include path and
library searching path respectively.
Add superlu.lib as the link optional library.
Compile your own .dll or .exe file. Then you are done.
If you are using a compiler with command line only, you have to play
with the makefile or -I -L -O -c options. As SuperLU calls BLAS
routines but BLAS is not a native library of MS Visual Studio, you
have to build your own BLAS library in the similar way as SuperLU
library. The SuperLU distribution includes a C version of BLAS in
SuperLU/CBLAS directory. This version is only functional but not fast.
For speed, it's better to use vendor-supplied BLAS (e.g., Intel MKL)
or public domain versions (e.g., ATLAS, or Goto BLAS).
i could not do it right.
rewrite the whole makefile for windows(i couldn't do it either because i dont know how to write a makefile)
And finally the working solution(for me):
I found a repo in github that added superLU build support for windows!
you can find it here
it has a Visual Studio(2010) solution file that builds the library and gives a lib file.

cmake: You have called ADD_LIBRARY for library cryptopp without any source files

Windows 64bit using cmake to compile c++ project: github.com/iHateInventNames/synergy-through-usb
I fixed a previous issue in this post: Compile issues: LIBUSB_1 with cmake project on Windows
So when I hit cmake now I get the following error:
> cmake .
-- Found libusb-1.0:
-- - Includes: C:/local/libs/libusbx
-- - Libraries: C:/local/libs/libusbx/libusb-1.0.lib
You have called ADD_LIBRARY for library cryptopp without any source files. This typically indicates a problem with your CMakeLists.txt file
-- Configuring done
CMake Error: CMake can not determine linker language for target: cryptopp
CMake Error: CMake can not determine linker language for target: cryptopp
CMake Error: CMake can not determine linker language for target: cryptopp
CMake Error: CMake can not determine linker language for target: cryptopp
-- Generating done
-- Build files have been written to: C:/local/projects/synergy-usb/synergy-through-usb-master
What does this mean? how can I solve it / move on?
Links to the install instructions
both goto 404 errors...
http://synergy-project.org/projects/synergy/wiki/Readme/?hl=pm
http://synergy-project.org/projects/synergy/wiki/Compiling/?hl=pm
Based on a quick browse through the project's CMakeLists, it would seem you're supposed to unpack tools/cryptopp562.zip into a directory called tools/cryptopp562 before running CMake. This should definitely have been mentioned in the projects' installation instructions, if any.
More precisely, the file tools/CMakeLists.txt contains this code:
set(cpp_dir cryptopp562)
file(GLOB cpp_src ${cpp_dir}/*.cpp)
# ...
add_library(cryptopp STATIC ${cpp_src})
This means that the variable cpp_src is filled with source files taken from directory cryptopp562 (relative to the CMakeList's directory, i.e. tools), and is then used to define the source files of library cryptopp. However, the project's distribution only contains tools/cryptopp562.zip. Unpacking that into directory tools/cryptopp562 should provide the missing files.

Adding LLVM to my Cmake Project: Why are there hardcoded paths in LLVM's Cmake file?

I'm using LLVM/Clang in my C++ project. I can build and run everything fine with a Makefile.
I'm now trying to move to Cmake and I can't get things to work. Let me explain what I've done.
I'm following this tutorial:
http://llvm.org/docs/CMake.html#embedding
A relevant snippet from that webpage is:
From LLVM 3.5 onwards both the CMake and autoconf/Makefile build
systems export LLVM libraries as importable CMake targets.
Great! I'll go download LLVM 3.5 and I should be good to go. I went to the download page:
http://llvm.org/releases/download.html
and downloaded the pre-built binaries for Clang for Ubuntu 14.04 Linux.
Then, I added the following to my CMakeLists.txt file:
find_path (LLVM_DIR LLVM-Config.cmake
/home/dev/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu/share/llvm/cmake
)
message(STATUS "LLVM_DIR = ${LLVM_DIR}")
find_package(LLVM REQUIRED CONFIG)
(This is the same as the tutorial, except I set LLVM_DIR since it is currently in a non-standard location.)
When I run cmake, I get the following error:
[dev#beauty:/path/to/project/build (develop)] $ cmake ..
-- LLVM_DIR = /home/dev/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu/share/llvm/cmake
CMake Error at /home/dev/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu/share/llvm/cmake/LLVMConfig.cmake:50 (include):
include could not find load file:
/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/share/llvm/cmake/LLVMExports.cmake
Call Stack (most recent call first):
CMakeLists.txt:14 (find_package)
CMake Error at /home/dev/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu/share/llvm/cmake/LLVMConfig.cmake:53 (include):
include could not find load file:
/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/share/llvm/cmake/LLVM-Config.cmake
Call Stack (most recent call first):
CMakeLists.txt:14 (find_package)
So Cmake seems to be finding LLVM's Cmake file, but Cmake is complaining about some path starting with /home/ben/.
Indeed, it appears that LLVM's LLVMConfig.cmake file has some absolute paths in it that are not relevant for my machine. For example:
[dev#beauty:~/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu ] $ head ./share/llvm/cmake/LLVMConfig.cmake
# This file provides information and services to the final user.
set(LLVM_INSTALL_PREFIX "/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install")
set(LLVM_VERSION_MAJOR 3)
set(LLVM_VERSION_MINOR 5)
set(LLVM_VERSION_PATCH 0)
set(LLVM_PACKAGE_VERSION 3.5.0)
set(LLVM_COMMON_DEPENDS )
Who's ben and what's he doing in this file? He shows up in a few more places:
[dev#beauty:~/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu ] $ grep ben ./share/llvm/cmake/LLVMConfig.cmake
set(LLVM_INSTALL_PREFIX "/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install")
set(LLVM_INCLUDE_DIRS "/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/include")
set(LLVM_LIBRARY_DIRS "/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/lib")
set(LLVM_CMAKE_DIR "/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/share/llvm/cmake")
set(LLVM_TOOLS_BINARY_DIR "/home/ben/development/llvm/3.5/final/Phase3/Release/llvmCore-3.5.0-final.install/bin")
Needless to say, those paths do not exist on my machine. I'm confused as to why these files have these paths in them? Am I supposed to run a tool or something to change these paths for my machine? Or do I need to change them all manually?
EDIT: Out of curiosity, I manually changed all those paths to point to paths on my machine:
[dev#beauty:~/Downloads/clang+llvm-3.5.0-x86_64-linux-gnu/share/llvm/cmake ] $ sed -i -e's/.home.ben.development.llvm.3.5.final.Phase3.Release.llvmCore-3.5.0-final.install/\/home\/dev\/Downloads\/clang+llvm-3.5.0-x86_64-linux-gnu/g' *
After that, Cmake no longer complained and my build proceeded.
I'd still like to know why I needed to do that.
Sounds like a LLVM bug. Feel free to enter it: http://llvm.org/bugs
We just have to build with 'Ninja' instead of 'Unix Makefiles' and that's all