0

How do you compile a c++ program to use Hard Float registers? It is said in the FAQ section of Raspbian that the following tags are the only ones required when compiling.

-march=armv6 -mfpu=vfp -mfloat-abi=hard

Is this applicable also when compiling a c++ program in Debian.

g++ -lwiringPi -lpthread -lopencv_core -lrt -march=armv6 -mfpu=vfp -mfloat-abi=hard Testing.cpp -o Testing.out

I am using the Raspberry Pi B+. I have also checked the existence if the following directory

/lib/arm-linux-gnueabihf

which means my OS does support hard float calculations.

1

It is said in the FAQ section of Raspbian that the following tags are the only ones required when compiling.

I dunno what ancient FAQ that was; also compiler flags are one of those things that are easily used and abused by people that don't really understand what they are doing (the point of that link may not be immediately clear and it has nothing directly to do with the pi, but had me in ROTFL state the first time I saw it; also note there is a bit of foul language). This has a telephone game like effect on the internet and is characteristic of cargo cult programming. Do not fall down this rabbit hole, there is no rabbit, treasure, useful information, etc. of any sort inside.

Anyway...

How do you compile a c++ program to use Hard Float registers?

Presuming it's g++, the current best practice invocation is probably:

 g++ --std=c++11 -Wall -Wextra

Notice none of those have anything to do with the hard float ABI because if you are using the compiler than came with your arm-linux-gnueabihf pi B+ distro, it will use the correct architecture settings anyway. Adding -march=armv6 -mfpu=vfp -mfloat-abi=hard will be totally meaningless except to add extra wear to your - m, and = keys. Sort of like ordering a cheeseburger by saying, "I'd like a cheeseburger with cheese and a beef patty in a bun".

If you are referring to a cross-compiler (you don't mention this in the question) you could use those, but if you got it from the official github tools or used a sane approach when building it, they'll be irrelevant there too.

Note that if you are using an armv7 cross compiler for the 2B (these are stock on most linux distros, unlike armv6 capable ones) you should leave out march-armv6, it won't work, and armv7 binaries will work fine with Raspbian and other armv6 distros on a 2B.

  • 1
    so basically the compiler that came with the distro automatically uses Hard Float by default? :) – user123456098 Feb 28 '16 at 10:33
  • 2
    Yep, absolutely. – goldilocks Feb 28 '16 at 10:57
1

If your libraries for OpenCV are built with hard float too - I see no problems using the flags you've provided.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.