I can't compile the examples.
Closed this issue · 16 comments
Kontroller/Examples/ClientExample.cpp:1:10: fatal error: Kontroller/Client.h: No such file or directory
1 | #include "Kontroller/Client.h"
...
Hey! Are you using CMake to generate the project files? If so, the Include folder should be added to the list of include directories when building any projects that links against Kontroller (such as the example projects). Here's what my "Additional Include Directories" looks like in Visual Studio for KontrollerExample-Client.
You shouldn't need to manually make calls to include_directories()
, the includes should get pulled in automatically when you call target_link_libraries()
. For the examples, you shouldn't need to write any code at all - you just need to turn on KONTROLLER_BUILD_EXAMPLES
when configuring with CMake, then build the various example targets.
Are you trying to build the examples using your own CMake scripts?
I think visual studio adds things to you, always the cmakes made so produce problem in linux
I add this in cmake
include_directories( ${CMAKE_SOURCE_DIR}/../Include )
include_directories( ${CMAKE_SOURCE_DIR}/../Libraries/readerwriterqueue )
link_directories( ${CMAKE_SOURCE_DIR}/../Build/ )
error standard c++:
libKontroller.a(Client.cpp.o): in function `std::thread::thread<Kontroller::Client::Client(char const*, int, int, bool)::{lambda()#1}, , void>(Kontroller::Client::Client(char const*, int, int, bool)::{lambda()#1}&&)':
Client.cpp:(.text+0x125d): undefined reference to `pthread_create'
You shouldn't call either include_directories()
or link_directories()
, you should just call target_link_libraries()
, like this:
add_subdirectory("<your library path>/Kontroller")
target_link_libraries(<your target name> PUBLIC Kontroller)
I was able to compile under Linux with the current setup, but it's possible some compilers are more liberal with automatically linking against pthread. I've just pushed some changes to the pthread
branch in b0bdd3b, please let me know if they fix the linker error for you (you'll need to use target_link_libraries()
for my changes to be effective).
Is you code available online somewhere? I'd be happy to take a look at your CMake setup.
If you're just trying to compile the examples, you shouldn't need to make any modifications. If you do the following steps, the examples should build:
git clone https://github.com/aaronmjacobs/Kontroller.git --recursive
cd Kontroller/Build
cmake .. -DKONTROLLER_BUILD_EXAMPLES=On
make
If you still see errors related to pthread, you can try out my changes in the pthread
branch:
git checkout pthread
make
Sorry for the late reply. I've updated the README to give some more information about usage. For KontrollerExample-Device
specifically, you should be able to compile and run the program (as long as you enabled the example targets by setting KONTROLLER_BUILD_EXAMPLES
). If you have a KORG nanoKONTROL2 connected, you should see any state changes (button presses, or dial / slider changes) output to stdout. Additionally, if you push the "cycle" button on the MIDI controller, you should see the LEDs form a sine wave. Pushing the track next/previous buttons will cycle through other LED demos, including one that causes a "ripple" effect when you push any of the S/M/R buttons, and one that lights up the S/M/R LEDs based on the slider positions. Pushing the "stop" button will cause the program to exit.
The library unfortunately does not currently support controlling the LEDs on Linux. I'm going to look into utilizing ALSA as opposed to reading directly from /dev/midi1
as a possible solution.
ALSA is now set up! Please let me know if it works as expected (make sure to grab libasound2-dev
via your package manager, as it is now required to build on Linux).
@b4zz4 Have you had a chance to try things out now that ALSA is being used? I'd like to confirm things are working for you before closing out this issue :)
WOW thanks!!!!