-1

I got a simple C++ code. The hard part is that I use -std=c++11 flag.

I've tried:

  • Compiling on Mint Code::Blocks and then move bin to run it:

    cannot execute binary file

  • Compiling on gcc 4.6.3 with different flags

  • Compiling on 4.8

    gcc-4.8 ioead.cpp -o mineprog -std=c++11
    

    It gives TONS of text.

Everything works on Windows or Mint, just can't compile this with gcc or run it any other way.

  • 2
    You need to compile programs targeted to the Pi actually on the Pi or use a cross-compiler. Your laptop or desktop is unlikely to be an ARM machine (most PCs will be Intel/AMD based x86) and will not generate the correct code for a Pi. – joan Aug 6 '15 at 20:22
  • Is RPI capable of handling codeblocks on x? I haven't monitor yet with HDMI – windman Aug 6 '15 at 20:29
  • Sorry, I have no idea, I have never used it. You'll have to try and see. – joan Aug 6 '15 at 20:31
1

As joan pointed out, the problem here are the two incompatible architectures. You can use a cross-compiler, but if your code will compile reasonably quickly on the pi, which it probably will if it is fairly simple, you could also either work directly on the pi or do what I recommend, work remotely.

First make sure that the compile time really isn't too much by trying it on the pi.

To work remotely, you can either do this via your IDE/editor directly if it has such a feature, or else mount part of the pi's filesystem as a remote filesystem; sshfs is good for this, particularly if you are already using ssh. Mounting the fs is probably a simpler option than trying to use a feature of the editor because there is less need for confusion and configuration of the compiler -- you simply don't compile via the IDE. Auto-complete and syntax checks obviously still work, but to actually compile and test, just keep a terminal open logged in via ssh to the pi and do it manually.

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.