Author Topic: Raspberry Pi - latest version of CodeBlocks and use of sudo  (Read 1577 times)

Offline JorgenSandberg

  • Single posting newcomer
  • *
  • Posts: 2
Raspberry Pi - latest version of CodeBlocks and use of sudo
« on: October 26, 2021, 04:03:49 pm »
I have started using CodeBlocks as IDE on Raspberry Pi with Rasbian.

1. I have installed Code::Blocks version 17:12. Is that the latest for Raspberry Pi?

2. I am using the pigpio library. When I compile, link and run the program in Code::Blocks using the "Build and Run" button, I get an error message saying that I do not have permission to execute the initialisation of the pigpio. I shall have root permission i.e. use sudo for that. How do I set Code::Blocks to use sudo? (I have been through the manual, but did not find anything on the launch of the build program)

Regards,
JorgenSandberg

Offline AndrewCot

  • Almost regular
  • **
  • Posts: 248
Re: Raspberry Pi - latest version of CodeBlocks and use of sudo
« Reply #1 on: October 27, 2021, 12:29:01 am »
The error you are getting is a Linux permission problem and not related to C::B. I would ask on a Raspberry Pi forum for how to yuo can grant your user access to the pigpio.

Offline JorgenSandberg

  • Single posting newcomer
  • *
  • Posts: 2
Re: Raspberry Pi - latest version of CodeBlocks and use of sudo
« Reply #2 on: October 28, 2021, 10:53:14 am »
Sorry, it is a Code::Blocks problem. Somewhere Code:Blocks issues a command to the Raspberry Pi operating system of the kind ./executable. This is somewhere within Code::Blocks. I need to change that to sudo ./executable.
It has been a question a few years ago and I was hoping, that someone had figured out how to do it. Where in Code::Blocks is hidden the command to execute a program? Can the user change that command? (It can be done in GEANY).
Regards,
Jorgen Sandberg

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3027
Re: Raspberry Pi - latest version of CodeBlocks and use of sudo
« Reply #3 on: October 28, 2021, 11:37:03 am »
Sadly the user can not modify the "Run" command at the moment.
It is on my todo list for a while now...

One solution (not the preferible one) is to run codeblocks as sudo
A other, better solution is to create a Tools menu item to run the executable:
Tools+ -> Configure tools->New
Name: Run as sudo
Command line:
Code
sudo $(TARGET_OUTPUT_FILE)

this is not tested, but should work...


Offline AndrewCot

  • Almost regular
  • **
  • Posts: 248
Re: Raspberry Pi - latest version of CodeBlocks and use of sudo
« Reply #4 on: October 28, 2021, 11:38:46 am »
Suggest google "sudo chgrp gpio /sys/class/gpio/export" and start reading on how to fix your permission problem.

@BlueHazzard It's a linux permission issue with resources where the user needs to add themself into the group that has access or create group and give it access..... I have to do this when running poker machine code in a Linux development environment in order to gain access to the RTC hardware and TTYSxxx (serial ports).
« Last Edit: October 28, 2021, 11:42:06 am by AndrewCot »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3027
Re: Raspberry Pi - latest version of CodeBlocks and use of sudo
« Reply #5 on: October 28, 2021, 11:45:41 am »
@AndrewCot
yea, probably.... I had the same issues in my usb linux days, adding the right permissions is the right way to go