lazwiringpi linker problem: Error Rasperry Uses VFP register arguments

The lazwiringpi wrapper has worked fine for me in the past, found here (you must be logged in to see the download).,17404.0.html

This wrapper allows you to accessing the Raspberry Pi wiringPi library which is written in C.

Granted, it has been over a year since I last used it, but as of today I can no longer link to this library. I get the errors:

/usr/bin/ld: error: raspberry uses VFP register arguments, ./wiringPi/wiringPi.o does not
/usr/bin/ld: failed to merge target specific data of file ./wiringPi/wiringPi.

After a few hours of stumbling around I managed to get it running by recompiling the underlying C wiringPi.c library.

It was a simple matter of cd’ing to the correct wiringPi directory and simply typing:

gcc -c wiringPi.c

This recompiles the C library and the new pascal code will correctly link to it. Recompiling is the best bet since it takes into account any other recent changes as well.

If you are unable to make recompilation work, I updated the original lazwiringPi archive with the wiringPi.o file that is linking properly for me here:

This entry was posted in c-lazarus, c-rpi and tagged . Bookmark the permalink.

8 Responses to lazwiringpi linker problem: Error Rasperry Uses VFP register arguments

  1. Pingback: Accessing Raspberry Pi GPIO using Lazarus/Free Pascal | Big Dan the Blogging Man

  2. Alzibiff says:

    Hello Big Dan.
    After many years of not programming anything and having just retired from full time work, I am s-l-o-w-l-y getting back to my roots – I started playing with electronics and then computer programming back in 1971.
    I am working on a project which requires a pretty front end application on a RPi to control five of the GPIO pins on the Pi and for this, have come to the conclusion that for me, FreePascal is the way to go. (Back in the day, I taught programming at a local college and we were one of the first to use Delphi, so I am familiar with aspect of the language although this was 20 years ago).
    I am treading carefully though – I am not familiar with any Linux stuff and therefore learning by following what I can find in the form of tutorials and installation instructions on the web.
    I have FP running on the latest version of the RPi (the one with the micro SD card) after following the superb instructions posted by Hans on his site. I have even remembered how to write a simple two button, one label, one edit box program which compiled without errors and ran as I expected it to.
    However …. and I guess you know what is coming next …. when it comes to the term “wrappers” and how to install files from .tar files onto my RPi, I am completely stuck and have not been able to find anything useful to help me fathom out these questions. Please can you assist? In short, what in terms of step by step instructions do I need to do in order to write a Visual Pascal program which has code to control the GPIO pins on my new RPi?
    If you don’t have the time for this, any chance that you could point me to some other resource which you feel may be of assistance?

    Many thanks,

    • Dan TheMan says:

      Hi Alan,

      I understand your choice of FP. I was out of the programming world for a very long time, as well, and I never seem to forget Pascal like I have others.

      I have written several posts on this blog about using lazarus/free pascal. If you scroll down the table of contents, there is a section on Lazarus/FP:

      This post discusses exactly how to access GPIO pins using FP:

      Note that my program is a console program (no gui), but the concepts will be the same in a gui program.

      As far as wrappers are concerned, if you aren’t yet aware the ‘wrapper’ I mention is simply an interface between FP and the C library that accesses the RPI. Way, way back, we would have called these shims if that terminology helps any.

      To get the wiringpi library installed, it is pretty straight forward and available here:

      Follow those instructions and you should have the library installed. He’s got a test procedure as well so you can verify it installed properly.

      Next you will obtain the ‘wrapper’ that allows your FP program to call the C-based wiringpi library. Download to your desktop. Double click down to the laz2wiring directory. Copy this entire directory into your Lazarus project’s directory.

      Now you need add the h2wiringpi.pas file to your project. I never remember exactly how to do this quite right. First, open the file in Lazarus. Then I believe you right click on the tab for that file and there is an option to add it to the project. If I’m not right, look around and find the proper menu entry that adds files to the project. This will allow the compiler to find the h2wiringpi.pas file.

      Now you need to fix the linker to include the h2wiringpi object file during link. Again, I can’t recall the exact tabs to hit, but if you go into projects/linking I think you will see where to add it.

      sorry for being vague on this part, but I have no memory for such stuff and have to stumble thru it every time myself.

      I would suggest using my example, and making sure you can get it to work on your GPIO pins as it is known to work. Once you’ve got that, move the logic into your own program.

      I think you’ll find it’s surprisingly easy. I still remember the delight of the first time I ‘controlled’ an external device from a Pascal program. My entire programming career consisted strictly of manipulating data, not devices.


      • alzibiff says:

        Dan – Top man! Will have a go tomorrow. My project by the way is a photography one – I want to control a solenoid, flash gun and camera shutter in order to capture what happens when a drop of water/milk/gunge falls into a container and splashes up. The solenoid is used to release a drop of water (or whatever). There are lots of examples of this in Cyberspace and I believe that the key to getting good images comes down to timing the flash and solenoid release events. I’m thinking that using a visual interface as provided by Lazarus will make it relatively easy to change delay values – easier than doing the same job using an environment which requires code changes each time you need to change parameters. (Hope I have explained that properly).
        As said, I will have a go at installing the GPIO files tomorrow now that you have pointed out where to stick them all.
        Thank you,

      • alzibiff says:

        Looking good!
        Everything installed without problem – as I think you gathered, I was concerned about getting the wiringPi and your wrapper support files into the right directories, (Raspian is a mass of directories compared to what I was used to and I was concerned about getting hopeless lost when trying to navigate them all).
        Using your demo program, I have successfully got an LED flashing and delved deeper into the pin assignments on the RPi GPIO plug so I am good to go.
        Thank you once again, I will be using your blog posts as my goto support resource. (Did I really use a ‘goto’? 😉 )

  3. alzibiff says:

    Hello (again)… I am now deciding which of the GPIO lines to use for my project – it will come down to how easy I want to make my physical wiring scheme I guess 🙂 Looking through the Pascal code in h2wiringpi, specifically the pin mappings, I notice that P35 and P37 are given the same value of 24 – is that right? I suspect that P37 should be assigned to a value of 25 but would appreciate your comment before making any changes of my own.

    • Dan TheMan says:

      Hi Alan,

      What you say sounds logical, but check (and test) carefully. The pins used by wiringPi vs. what is documented can be confusing. The Author explains here:

      At least twice that I can remember I’ve had problems mapping wiringPi->GPIO->physical pin.


  4. Danny says:

    I’ve been trying to get this to work, I have the raspberry pi 2 model B. Not sure what I am doing wrong, all the installs seem to work ok.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.