How to compile and run a hello world JUCE program? - c++

I cloned https://github.com/juce-framework/JUCE
I first uncommented find_package(JUCE) in /GuiApp' CMakeList.txt.
Then I ran cmake .. . -B cmake-build-dir -D JUCE_BUILD_EXAMPLES=ON
on the top level directory.
It says:
-- Checking for modules 'webkit2gtk-4.0;gtk+-x11-3.0'
-- No package 'webkit2gtk-4.0' found
-- No package 'gtk+-x11-3.0' found
-- Checking for module 'alsa'
-- No package 'alsa' found
-- Configuring juceaide
-- Building juceaide
-- Exporting juceaide
CMake Error at examples/CMake/GuiApp/CMakeLists.txt:27 (find_package):
Could not find a package configuration file provided by "JUCE" with any of
the following names:
JUCEConfig.cmake
juce-config.cmake
Add the installation prefix of "JUCE" to CMAKE_PREFIX_PATH or set
"JUCE_DIR" to a directory containing one of the above files. If "JUCE"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
I tried to find where is JUCEConfig.cmake
/work/juce/temp/JUCE/build$ find . -name JUCEConfig.cmake
./cmake-build-dir/tools/JUCEConfig.cmake
How am I supposed to put this path in CMAKE_PREFIX_PATHS?

Clone this repository: https://github.com/juce-framework/JUCE
alsa and webkit2gtk are required dependencies which were absent on Ubuntu 18.04 in my computer. You too may have to install as follows:
sudo apt install libwebkit2gtk-4.0-dev libasound2-dev
In the examples/CMake folder in this repository there is a folder called GuiApp.
To build a new GUI App project with JUCE/CMake, do this (starting from scratch):
Copy the GuiApp folder to a new location.
In the GuiApp's CMakeLists.txt that you copied, replace the
add_subdirectory(JUCE)
with
add_subdirectory("<path_to_JUCE_cloned_repository>" JUCE)
replacing the path with the real location of the JUCE repository on your system.
From the GuiApp folder that you copied, run
cmake . -B cmake-build-dir
Above command will create a build tree folder named cmake-build-dir
cmake --build cmake-build-dir
Above command will build all targets in the cmake-build-dir folder.
After successful build, you can run the executable by going in directory:
cmake-build-dir/GuiAppExample_artefacts/
and issuing ./Gui\ App\ Example. That's the name of the resultant default executable.
Credit: https://forum.juce.com/u/reuk/summary

Related

vcpkg how to edit package file when compilation fails when installing package?

I'm installing dependencies for some project which downloads dependencies with vcpkg (the project is Hyperledger Iroha, but it does not matter). Unfortunately when compiling dependencies with my compiler (g++ 12.1.0) one of packages (abseil) is not compiling.
The reason why it is not compiling is easy to fix in code - just one line to change.
The line is pointed by cmake:
CMake Error at scripts/cmake/vcpkg_execute_build_process.cmake:146 (message):
Command failed: /usr/bin/cmake --build . --config Debug --target install -- -v -j13
Working Directory: /home/agh/Pulpit/blockchain/internship2022/iroha/vcpkg-build/buildtrees/abseil/x64-linux-dbg
See logs for more information:
/home/agh/Pulpit/blockchain/internship2022/iroha/vcpkg-build/buildtrees/abseil/install-x64-linux-dbg-out.log
and the error is:
/home/agh/Pulpit/blockchain/internship2022/iroha/vcpkg-build/buildtrees/abseil/src/ca9688e9f6-e4cda1d679.clean/absl/debugging/failure_signal_handler.cc:139:32: error: no matching function for call to ‘max(long int, int)’
139 | size_t stack_size = (std::max(SIGSTKSZ, 65536) + page_mask) & ~page_mask;
| ~~~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/12.1.0/algorithm:60,
The reason is easy to fix - I just need to change one line to fix this.
Unfortunately when I'm changing the line of code and then after rerunning:
vcpkg install abseil
my changes are being removed before compilation. I found option which should help:
--editable, but it is happening again.
I would like to ask what is more professional (but still fast) way to change files, which are being build with vcpkg and containing errors?
The one solution which I found is that I can edit package:
-- Using cached /home/agh/Pulpit/blockchain/internship2022/iroha/vcpkg-build/downloads/abseil-abseil-cpp-997aaf3a28308eba1b9156aa35ab7bca9688e9f6.tar.gz
when I edit the package I see error:
File path: [ /home/agh/Pulpit/blockchain/internship2022/iroha/vcpkg-build/downloads/abseil-abseil-cpp-997aaf3a28308eba1b9156aa35ab7bca9688e9f6.tar.gz ]
Expected hash: [ bdd80a2278eef121e8837791fdebca06e87bfff4adc438c123e0ce11efc42a8bd461edcbbe18c0eee05be2cd6100f9acf8eab3db58ac73322b5852e6ffe7c85b ]
Actual hash: [ cf8bb1676d2fcba8bdd4bc30e2060bc5552a348d6e192561aec2763460120b10dcb86e29efe60d972d4b241783563bc8067381c48209daee4ecc429786ef6bba ]
so I can edit file containing the hash: ports/abseil/portfile.cmake
Another solution is to run proper cmake of the abseil project with VERBOSE=1, then copy failing build commands after that edit files and rerun commands.
I know that my solutions are quite dirty so I would like to know if there is cleaner way to solve problem - how to edit source code of a library when it is not compiling when we use vcpkg package manager?
This is how I do it:
Run install with --editable
vcpkg install abseil --editable
Initialize git repo in source dir:
cd buildtrees/abseil/src/_random_string_/
git init .
git add .
git commit -m "init"
Patch the library
Verify the library builds by calling install with --editable again
vcpkg install abseil --editable
Create patch from changes (or commits)
git diff > fix_build.patch
Copy patch into port dir and adjust portfile.cmake
vcpkg_from_github(
REPO google/abseil
...
PATCHES fix_build.patch # <-- this is our patch
)
Copy the port directory into your project's overlay-ports dir. -OR- Update port version, submit it into your custom registry.
(optional, but appreciated) Create PR in upstream and vcpkg main repo.

How to install V2X-Hub on Ubuntu 18.04

I am trying to install V2X-Hub following those steps : https://github.com/usdot-fhwa-OPS/V2X-Hub/blob/develop/docs/installation_and_Setup.md
I did the compilation instructions until this one :
« Now, run the following commands from V2X-Hub directory
cd src/v2i-hub
cmake . -DqserverPedestrian_DIR=/usr/local/share/qserverPedestrian/cmake »
And it tells me :
« Cmake Error at CARMACloudPlugin/CMakeLists.txt:10 (find package):
By not providing «Findv2xhubWebAPI.cmake » in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by « v2xhubWebAPI », but Cmake did not find one.
Could not find a package configuration file provided by « v2xhubWebAPI » with any of the following names:
v2xhubWebAPIConfig.cmake
v2xhubwebapi-config.cmake
Add the installation prefix of « v2xhubWebAPI » to CMAKE_PREFIX_PATH or set « v2xhubWebAPI_DIR » to a directory containing one of the above files. If « v2xhubWebAPI » provides a separate development package or SDK, be sure it has been installed. »
Thanking you in advance for your help i am blocked.

OpenSpliceConfig.cmake or opensplice-config.cmake not found while building dds-tutorial-cpp-ex

I am trying to learn dds. According to the tutorial, Appendix 1 suggests to look at examples on provided in github called dds-examples-cpp-ex.
The simple commands to build this examples according to readme is cmake . && make
I execute the command
cmake . && make
from the cmake directory of this folder after cloning it on my local machine
I get the following error:
CMake Error at CMakeLists.txt:28 (FIND_PACKAGE):
By not providing "FindOpenSplice.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"OpenSplice", but CMake did not find one.
Could not find a package configuration file provided by "OpenSplice" with
any of the following names:
OpenSpliceConfig.cmake
opensplice-config.cmake
Add the installation prefix of "OpenSplice" to CMAKE_PREFIX_PATH or set
"OpenSplice_DIR" to a directory containing one of the above files. If
"OpenSplice" provides a separate development package or SDK, be sure it has
been installed.
-- Configuring incomplete, errors occurred!
See also "/home/gajendra/Documents/AnokhiDocs/DDS/dds-tutorial-cpp-ex/cmake/CMakeFiles/CMakeOutput.log".
I tried to locate OpenSpliceConfig.cmake && opensplice-config.cmake on my system but I did not get any result.
My question is how can I correct the paths or fix this error?
I have OpenSplice running on my local machine and I have executed other examples directly from $OSPL_HOME/opensplice/dcps/Tutorial. and they work fine.
I also tried to build ch1. I edited the second line in ch1/CMakeLists.txt from
set(CMAKE_MODULE_PATH ../cmake)
to
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
so that it can find cmake folder in the root directory where CMakeLists.txt resides.
I run into the same problem when I execute the following:
cd ch1 && mkdir build && cd build && cmake ..
CMake Error at /home/gajendra/Documents/AnokhiDocs/DDS/dds-tutorial-cpp-ex/cmake/FindOpenSplice.cmake:72 (MESSAGE):Could not find OpenSplice DDS
Call Stack (most recent call first):
CMakeLists.txt:8 (find_package)
I had the same problem on Ubuntu 20.04 and OpenSplice 6.10.3p1
I just sourced the release.com file in the installation directory, then went to each "ch" folder as suggested by #Tsyvarev and ran cmake . && make from there.
CMake ran successfully afterwards.

Problems installing AWS C++ SDK on Cloud9

I am trying to install the AWS C++ SDK on my Cloud9 environment(m4.large). I followed the steps in this tutorial.
My steps:
sudo yum -y install libcurl-devel openssl-devel libuuid-devel cmake3
wget https://github.com/aws/aws-sdk-cpp/archive/master.zip
unzip master.zip
rm master.zip
mkdir sdk_build && cd sdk_build
cmake3 ../aws-sdk-cpp-master -DBUILD_ONLY="dynamodb" //I changed s3 to dynamodb
make && cd ..
In the file dynamodb-demo.cpp:
#include <aws/core/Aws.h>
int main(){ return 0;}
In CMakeLists.txt:
cmake_minimum_required(VERSION 2.8)
project(dynamodb-demo)
find_package(aws-sdk-cpp)
add_definitions(-DUSE_IMPORT_EXPORT)
add_executable(dynamodb-demo dynamodb-demo.cpp)
target_link_libraries(dynamodb-demo aws-cpp-sdk-dynamodb)
The problem seems to be here this command throws no errors but a Warning:
cmake3 -Daws-sdk-cpp_DIR=sdk_build .
Output:
CMake Warning at /usr/share/cmake3/Modules/CMakeFindDependencyMacro.cmake:65 (find_package):
By not providing "Findaws-c-event-stream.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"aws-c-event-stream", but CMake did not find one.
Could not find a package configuration file provided by
"aws-c-event-stream" with any of the following names:
aws-c-event-streamConfig.cmake
aws-c-event-stream-config.cmake
Add the installation prefix of "aws-c-event-stream" to CMAKE_PREFIX_PATH or
set "aws-c-event-stream_DIR" to a directory containing one of the above
files. If "aws-c-event-stream" provides a separate development package or
SDK, be sure it has been installed.
Call Stack (most recent call first):
sdk_build/aws-cpp-sdk-core/aws-cpp-sdk-core-config.cmake:2 (find_dependency)
sdk_build/aws-sdk-cpp-config.cmake:1 (include)
CMakeLists.txt:14 (find_package)
CMake Warning at CMakeLists.txt:14 (find_package):
Found package configuration file:
/home/ec2-user/environment/sdk_build/aws-sdk-cpp-config.cmake
but it set aws-sdk-cpp_FOUND to FALSE so package "aws-sdk-cpp" is
considered to be NOT FOUND. Reason given by package:
aws-sdk-cpp could not be found because dependency aws-c-event-stream could
not be found.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ec2-user/environment
Therefore the make command throws fatal error: aws/core/Aws.h: No such file or directory, which i understand so i guess the mistake should be in the command above.
I haven't configured my AWS credentials yet, but i don't think this would throw those kind of erros. The problem seems to be related with cmake.
Some research showed, that aws-c-event-stream-config.cmake should be located at /home/ec2-user/environment/sdk_build/.deps/install/lib64/aws-c-event-stream/cmake which it is.
Maybe the solution is very simple, but I have only basic knowledge about cmake.
With Tsyvarev's help the project configures:
cmake3 -DCMAKE_PREFIX_PATH=/home/ec2-user/environment/sdk_build/.deps/install/lib64/aws-checksums/cmake\;/home/ec2-user/environment/sdk_build/.deps/install/lib64/aws-c-common/cmake\;/home/ec2-user/environment/sdk_build/.deps/install/lib64/aws-c-event-stream/cmake\;/home/ec2-user/environment/sdk_build .
Things i needed to change as well:
Build the AWS core (not sure if necessary):
cmake3 ../aws-sdk-cpp-master -DBUILD_ONLY="core;dynamodb"
Add this to your CMakeLists.txt:
target_link_libraries(dynamodb-demo aws-cpp-sdk-core)
And set the standard to C++ 11:
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

Build opencv_contrib sample executables on Linux (OpenCV 3.0.0-alpha)

System: VM Ubuntu 14.04 x64
Summary:
I'm building OpenCV 3.0.0-dev with the contrib modules from https://github.com/Itseez/opencv_contrib but I can't get the executables from opencv_contrib.
I was trying to follow this tutorial about the tracking API: http://docs.opencv.org/trunk/modules/tracking/doc/tracking.html
Somewhere it says: To see how API works, try tracker demo: https://github.com/lenlen/opencv/blob/tracking_api/samples/cpp/tracker.cpp
But that's a forked old repository (by user lenlen), not the official repository. In the recent versions (with the new repos) it seems like that file is not in that location anymore but in:
https://github.com/Itseez/opencv_contrib/blob/master/modules/tracking/samples/tracker.cpp
The problem:
I'm being able to build OpenCV without errors, but I can't see how to build that executable file from opencv_contrib, or where is it getting located.
I've tried:
Setting up OPENCV_EXTRA_MODULES_PATH with: cmake -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ..
Setting up INSTALL_C_EXAMPLES with: cmake -D INSTALL_C_EXAMPLES=ON ..
Entering in opencv_contrib, creating and entering into a "build" directory and from there executing: "cmake .." ...but that gives errors (no CMakeLists.txt).
Entering in "opencv_contrib/modules/tracking/", creating and entering into a "build" directory and executing "cmake .." (because there's a CMakeLists.txt inside of the tracking directory). But that also gives errors.
Entering in "opencv_contrib/modules/tracking/samples/" and executing "g++ tracker.cpp", but that also gives errors.
Thanks in advance!
I solved it. It was a silly mistake.
I was setting up OPENCV_EXTRA_MODULES_PATH as: cmake -D OPENCV_EXTRA_MODULES_PATH=../opencv_contrib/modules ..
But my working directory was "opencv/build/" (I was in a directory "build" inside of opencv and the "opencv_contrib" was in the same directory as "opencv"), so that variable should have been: cmake -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules ..