2

I am trying to run a c-program via clion IDE using the wiringPi library. Hello world runs perfectly fine, so I can assure that the connection to the pi was established correctly. However, when I add the wiringPi-Library #include and run wiringPiSetup(); I get an error message.

In order to solve this problem, I added "-lwiringPi" at Clion/Preferences/Build, Execution, Deployment/CMake/Build options. However, this didn't change anything. Maybe there is something missing in CMakeLists.c but I actually don't know what.

#include <stdio.h>
#include <wiringPi.h>

// Code I want to make running
int main() {
    wiringPiSetup();
    return 0;
}

Error Message:

====================[ Build | write_morse | Debug-Remote ]====================== /usr/local/bin/cmake --build /tmp/tmp.tL61Mxt6gP/cmake-build-debug-remote --target write_morse -- -j 4 [ 50%] Linking C executable write_morse CMakeFiles/write_morse.dir/main.c.o: In function main': /tmp/tmp.tL61Mxt6gP/main.c:6: undefined reference towiringPiSetup' collect2: error: ld returned 1 exit status CMakeFiles/write_morse.dir/build.make:83: recipe for target 'write_morse' failed make[3]: * [write_morse] Error 1 CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/write_morse.dir/all' failed make[2]: [CMakeFiles/write_morse.dir/all] Error 2 CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/write_morse.dir/rule' failed make[1]: [CMakeFiles/write_morse.dir/rule] Error 2 Makefile:118: recipe for target 'write_morse' failed make: * [write_morse] Error 2

Error Message with -lwiringPi:

====================[ Build | write_morse | Debug-Remote ]====================== /usr/local/bin/cmake --build /tmp/tmp.tL61Mxt6gP/cmake-build-debug-remote --target write_morse -- -lwiringPi [ 50%] Linking C executable write_morse CMakeFiles/write_morse.dir/main.c.o: In function main': /tmp/tmp.tL61Mxt6gP/main.c:6: undefined reference towiringPiSetup'

CMakeList.txt

cmake_minimum_required(VERSION 3.14)
project(write_morse C)

set(CMAKE_C_STANDARD 99)

add_executable(write_morse main.c)

0 Answers0