Iβm new to C++ and CMake and trying to get started on a WASM audio synth project but having trouble linking the dependencies.
βββ πcpp-wasm-audio-synth
βββ πbuild
βββ cmake_install.cmake
βββ Makefile
βββ click_sound.wav
βββ CMakeLists.txt
βββ main.cpp
CMakeLists.txt:
cmake_minimum_required(VERSION 3.22)
# Set the project name and version
project(RedButtonApp VERSION 1.0 LANGUAGES CXX)
# Find SDL2_mixer package
find_package(PkgConfig REQUIRED)
find_package(SDL2 REQUIRED)
set(SDL_MIXER_INCLUDE_DIRS /usr/local/Cellar/sdl2_mixer/2.8.0/include)
set(SDL_MIXER_LIBRARIES /usr/local/Cellar/sdl2_mixer/2.8.0/lib/libSDL2_mixer-2.0.0.dylib)
set(SDL_INCLUDE_DIRS /usr/local/Cellar/sdl2/2.30.6/include/SDL2)
set(SDL_LIBRARIES /usr/local/Cellar/sdl2/2.30.6/lib/libSDL2-2.0.0.dylib)
# Add executable
add_executable(RedButtonApp main.cpp)
# Link libraries
target_link_libraries(RedButtonApp ${SDL2_MIXER_LIBRARIES})
# Include directories for SDL2_mixer
include_directories(${SDL2_MIXER_INCLUDE_DIRS})
include_directories(${SDL_INCLUDE_DIRS})
link_directories(${SDL_MIXER_LIBRARIES})
link_directories(${SDL_LIBRARIES})
From Terminal, if I go brew list sdl2
I get:
>> brew list sdl2
/usr/local/Cellar/sdl2/2.30.6/bin/sdl2-config
/usr/local/Cellar/sdl2/2.30.6/include/SDL2/ (78 files)
/usr/local/Cellar/sdl2/2.30.6/lib/libSDL2-2.0.0.dylib
/usr/local/Cellar/sdl2/2.30.6/lib/cmake/ (2 files)
/usr/local/Cellar/sdl2/2.30.6/lib/pkgconfig/sdl2.pc
/usr/local/Cellar/sdl2/2.30.6/lib/ (4 other files)
/usr/local/Cellar/sdl2/2.30.6/sbom.spdx.json
/usr/local/Cellar/sdl2/2.30.6/share/aclocal/sdl2.m4
β¦/visual-studio-projects/cpp-wasm-audio-synth/build took 3s
>>
But if I run:
>> rm -rf CMakeFiles CMakeCache.txt
cmake ..
make
I get:
-- The CXX compiler identification is AppleClang 15.0.0.15000309
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.29.2")
-- Configuring done (0.5s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/<username>/Documents/visual-studio-projects/cpp-wasm-audio-synth/build
[ 50%] Building CXX object CMakeFiles/RedButtonApp.dir/main.cpp.o
/Users/<username>/Documents/visual-studio-projects/cpp-wasm-audio-synth/main.cpp:2:10: fatal error: 'SDL2/SDL.h' file not found
#include <SDL2/SDL.h>
^~~~~~~~~~~~
1 error generated.
make[2]: *** [CMakeFiles/RedButtonApp.dir/main.cpp.o] Error 1
make[1]: *** [CMakeFiles/RedButtonApp.dir/all] Error 2
make: *** [all] Error 2
β¦/visual-studio-projects/cpp-wasm-audio-synth/build via β³ v3.30.2
>>
Donβt know why it doesnβt find my dependencies and not sure how to resolve it.