This works but you do not have to expose the entire OS to Root access, as well as run Lazarus as root. But because these are dynamic devices you have to run a script in rc.local or something as root to give yourself permissions to write on every reboot or runlevel change.
Example command line:
sudo echo 4 > /sys/class/gpio/export
sudo echo out > /sys/class/gpio4/direction
sudo chmod 666 > /sys/class/gpio4/value
now because the permissions are rw rw rw world can read/write to gpio4
you can add this kinda stuff to the rc.local in the /etc without the sudo, as that runs as root on boot up, so your System is GPIO ready on boot for normal users to use.
i2c is a bit different, I found these instructions in a word document for settting up i2c on the raspberry pi, but I use this all the time instead of running lazarus as "Root". I am sorry but I can't remember the link to these instructions, but thanks! it was the key to cleaning up this debacle of having to be root for me. I also hear there is a more formal program to do all this in unix as well.
Once the reboot has finished you need to make the ports active by running this command:
$sudo modprobe i2c-dev
Now you should be able to see the i2c ports listed in your /dev/ directory
$ls /dev/i2c*
You should see /dev/i2c-0 and /dev/i2c-1 listed. To be able to use these ports you need to give yourself permission to access them.
$sudo chmod o+rw /dev/i2c*
Now your i2c ports will be ready for you to use. You will have to run the modprobe and chmod commands every time you login to activate the ports and apply the permissions. If you wish to automate this process so the commands are run every time you log in then you can edit /etc/rc.local and add the commands in.
Just keep in mind that GPIO ( working with pins) on the rasp pi is a restricted operation and often needs to be run with root privileges that usually means the lazarus IDE or the o file needs to run from root. Other things like I2C are less restricted