cmake

How to find dll/so files in a CMake Superbuild

╄→гoц情女王★ 提交于 2021-01-29 09:40:41
问题 I have set up cross-platform software project using CMake Superbuild, where dependencies are added and built using ExternalProject_Add . The project compiles on both Windows and Linux, but when I try to run the executable programs that are produced, it does not work because it fails to find dll/so files of dependencies. This is not surprising, as the dll/so files of external dependencies are not placed in the output directory( bin in visualization below). One of the dependencies that are

GTest CMake multiple definition of main

a 夏天 提交于 2021-01-29 09:40:35
问题 I am trying to learn how to use gtest for creating unit testing in c++. I wrote a simple library to test, where I created a factorial function src/main.cpp #include <iostream> int factorial(int n) { if (n == 1) return 1; return n * factorial(n - 1); } // Default main function int main() { std::cout << "Hello, World!" << std::endl; return 0; } src/main.h #ifndef GTEST_LEARN_MAIN_H #define GTEST_LEARN_MAIN_H int factorial(int n); #endif //GTEST_LEARN_MAIN_H src/CMakeLists.txt add_executable

How to solve GTest and LibTorch linkage conflict

爷,独闯天下 提交于 2021-01-29 09:32:55
问题 This question follows my precedent one. I'm writing a C++ program with OpenCV, Torch and NumCpp. The program compiles and works fine for now, but I need to write unit tests. I've followed google's tutorial to build GTest and GMock inside my project, but it fails. When I don't link Torch libraries, that works. Error when linking GTest + Torch : /usr/bin/ld: CMakeFiles/TryGTest_test.dir/test/boxTest.cpp.o: in function `testing::AssertionResult testing::internal::CmpHelperEQFailure<int, int>

'undefined reference to' when using GTK with CMake

我怕爱的太早我们不能终老 提交于 2021-01-29 08:31:22
问题 I'm trying to build basic GTK+ code(one of its tutorials) with CMake, but I keep getting 'undefined reference to *' where * is any GTK function that is in the code. I tried to look after guides/tutorials on this, but most of them are mostly similar to what I have. Regular compilation from terminal works without a problem using command: g++ ./test.cpp -o test `pkg-config --cflags --libs gtk+-3.0` When I try using CMake my CMakeLists.txt is: cmake_minimum_required(VERSION 3.0.2) project(gtktest

Cmake Generator expressions with multiple entries (spaces?)

瘦欲@ 提交于 2021-01-29 08:30:33
问题 (During writing this question I found a solution, so this just documents it, because I would really have needed it beforehand!) Im writing a c++ project and use cmake for it. In my cmake file I have: set(MY_DEBUG_WARNINGS "-Og -Wall" ) # Add warnings: add_compile_options("$<$<CONFIG:DEBUG>:${MY_DEBUG_WARNINGS}>" "$<$<CXX_COMPILER_ID:Clang,AppleClang>:-fcolor-diagnostics>" "$<$<CXX_COMPILER_ID:GNU>:-fdiagnostics-color>" ) which doesn't work, because the compile command picks up extra escaped

Starting a cmake-built application with administrative priviliges from Visual Studio 2019 on a remote Linux machine

只谈情不闲聊 提交于 2021-01-29 06:58:10
问题 Running IDE-Machine Windows 10 with Visual Studio 2019. Target-System for debugging is a Ubuntu 18.04. Using CMake available in Visual Stdio addons. Test software is the soem lib, with the simple_test programm, wich already leads to the issue (https://github.com/OpenEtherCATsociety/SOEM). After passing the eth-interface to the built programm, it stops with cause it can't get root. Already tried to pass sudo in the launch.vs.json and also pipe sudo the programm. Tried to change the access to

Starting a cmake-built application with administrative priviliges from Visual Studio 2019 on a remote Linux machine

倖福魔咒の 提交于 2021-01-29 06:53:15
问题 Running IDE-Machine Windows 10 with Visual Studio 2019. Target-System for debugging is a Ubuntu 18.04. Using CMake available in Visual Stdio addons. Test software is the soem lib, with the simple_test programm, wich already leads to the issue (https://github.com/OpenEtherCATsociety/SOEM). After passing the eth-interface to the built programm, it stops with cause it can't get root. Already tried to pass sudo in the launch.vs.json and also pipe sudo the programm. Tried to change the access to

Cmake undefined reference to symbol 'dlsym@@GLIBC_2.2.5 even though I link with -ldl

≯℡__Kan透↙ 提交于 2021-01-29 06:43:47
问题 I'm getting undefined reference to dlsym@@GLIBC_2.2.5 even after linking it before and after the libraries. However in the linking output it appears that it's linking just before, but linking before all libraries should work, I guess. /bin/g++-9 CMakeFiles/http_downloader.dir/http_downloader_cli.cpp.o CMakeFiles/http_downloader.dir/SimpleOpenVPNSocket.cpp.o -o http_downloader -lpthread /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/x86_64-linux-gnu/liblz4.so -ldl downloader/libhttp_downloader

Undefined reference to (SFML)

百般思念 提交于 2021-01-29 06:05:06
问题 I am trying to link SFML with CMake, but I have some issues with make: /home/ishidex2/Documents/QtCreator/CMakeExample/main.cpp:-1: error: undefined reference to `sf::String::String(char const*, std::locale const&)' And some kind of errors like this. First of all, I installed SFML by this command: sudo apt-get install libsfml-dev And then followed this tutorial : https://github.com/SFML/SFML/wiki/Tutorial:-Build-your-SFML-project-with-CMake I think this is a problem with linking, but I don't

Qt Creator Error: cannot find -lopencv_imgcodecs

人走茶凉 提交于 2021-01-29 05:03:50
问题 I have installed opencv, qt, qt creator, cmake on ubuntu 15.10 through VMware on windows. The opencv is installed in this directory: /home/majidalaeinia/opencv/ The project repository is cloned in this directory: /home/majidalaeinia/Desktop/imgwarp-opencv/ I want to run the project through its CMakeLists.txt in qt creator and when I press Build now on qt creator, I get the following errors: error: cannot find -lopencv_imgcodecs error: collect2: error: ld returned 1 exit status Where is the