Author Topic: Problems with WirinigPi and CodeBlocks  (Read 4448 times)

Offline nobbody

  • Single posting newcomer
  • *
  • Posts: 3
Problems with WirinigPi and CodeBlocks
« on: July 06, 2023, 04:58:16 pm »
Hello everyone, I would like to switch a GPIO port on and off using two buttons. However, it only recognizes the functions of the wiringPi.h header when programming. He already suggests the corresponding functions. If I then want to compile the whole thing, the error message "undefined reference to pinMode" comes up. In an example program with Qt, the problem was solved with the following lines in the project file: LIBS += -L/usr/local/include -lwiringPi
I also tried adding the swritch -lwiringPi under Settings->OtherCompilerOptions but it didn't work. Although the build log looks fine.
gcc -pthread -I/usr/include/gtk-2.0 -I/usr/lib/arm-linux-gnueabihf/gtk-2.0/include -I/usr/include/pango-1.0 -I/usr/include/atk-1.0 -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -Wall -O2 -lwiringPi  -c /home/andreas/GPIOTest/MeinErstesProjekt/main.c -o obj/Release/main.o
gcc  -o bin/Release/MeinErstesProjekt obj/Release/main.o  -lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 -lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lharfbuzz -lfontconfig -lfreetype -s 
My configurations:
Raspberry Pi 4B
WiringPi Version 2.52
CodeBlocks Version 20.03

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1563
Re: Problems with WirinigPi and CodeBlocks
« Reply #1 on: July 06, 2023, 05:04:31 pm »
The wiringPi library must be added in the linker tab, not in the compiler one.

Offline nobbody

  • Single posting newcomer
  • *
  • Posts: 3
Re: Problems with WirinigPi and CodeBlocks
« Reply #2 on: July 07, 2023, 10:01:52 am »
Works great. Thanks very much :)