Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Illegal instruction on Raspberry Pi  (Read 2253 times)

0 Members and 1 Guest are viewing this topic.

virus989898

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Illegal instruction on Raspberry Pi
« on: July 06, 2014, 03:37:03 pm »
Hello,
I've got a problem with executing program compiled on my Raspberry Pi. It's for communication with my 3G controlled quadcopter. I compiled it on every linux at home end it worked. Compilation on Pi succeed too, when I CMade newest source form Laurent Gomila's git. I just had to put .so files path while building. When I try to execute it, there is only en error: "Illegal instruction". It only happends on Raspberry Pi. Is there a way to fix it other than resign form using SFML?

Used commands:
g++ -c programname.cpp
g++ programname.o -o programnamebuild -L /usr/local/lib/ -lsfml-network -lsfml-system
./programnamebuild  --- And then the error occurs

Here's my code:
#include <SFML/Network.hpp>
#include <iostream>

int roll = 0;
int rcthr = 0;
int pitch = 0;
int yaw = 0;
int high = 0;

int main()
{
sf::UdpSocket listener;


sf::IpAddress nadawca;
unsigned short port = 54321;
listener.bind(port);
sf::Packet paczka;

sf::SocketSelector sel;
sel.add( listener );

while (true) {

if( sel.wait(sf::seconds(1)) ) {


        if( sel.isReady( listener ) ) {
        sf::UdpSocket client;
        //j = lista.end();
        //lista[j+1] = client;
        //std::cout<<"Klient podlaczony\n";
        sel.add( client );
        }
        if (listener.receive( paczka, nadawca, port) == sf::Socket::Done)
                {
                //std::cout<< "Blad odbierania\n";
                //}

                int id;
                paczka>>id>>roll>>pitch>>rcthr>>yaw>>high;

                std::cout<<"Od: "<<nadawca<<" (ID:"<<id<<") ->\n";
                std::cout<<roll<<", "<<pitch<<", "<<rcthr<<", "<<yaw<<", "<<high<<"\n";

                }
       
       
    }

} // end while
return 0;
}
 
« Last Edit: July 06, 2014, 04:07:56 pm by virus989898 »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: Illegal instruction on Raspberry Pi
« Reply #1 on: July 06, 2014, 03:42:19 pm »
I doubt that anybody knows after your description what the problem is. First, check the obvious stuff (read the tutorial carefully, link everything correctly etc.). Then do that again -- really, there are so many people making mistakes here, and searching errors elsewhere is a waste of time in those cases.

Then, you should try to debug your program. Minimize it as much as possible and track down the error -- in which line does it happen, what are the variable values, the callstack etc.

But in general, SFML does not officially support Raspberry Pi, so it may simply not work directly. I think there have been other people experimenting with it, you might find something in the forum.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

binary1248

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1405
  • I am awesome.
    • View Profile
    • The server that really shouldn't be running
Re: Illegal instruction on Raspberry Pi
« Reply #2 on: July 06, 2014, 04:34:33 pm »
Code: [Select]
g++ -g -c programname.cpp
g++ programname.o -o programnamebuild -g -L /usr/local/lib/ -lsfml-network -lsfml-system
gdb ./programnamebuild
(gdb) run
(gdb) backtrace
Paste output here.
SFGUI # SFNUL # GLS # Wyrm <- Why do I waste my time on such a useless project? Because I am awesome (first meaning).

virus989898

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Illegal instruction on Raspberry Pi
« Reply #3 on: July 06, 2014, 06:19:17 pm »
I replaced "./programname" with "export LD_LIBRARY_PATH=/usr/local/lib && ./programname" and it looks like it is working. I'll setup whole network and share with my resault.
I think that /usr/local/lib is the default directory. Am I wrong or is because of Raspbian?

virus989898

  • Newbie
  • *
  • Posts: 5
    • View Profile
    • Email
Re: Illegal instruction on Raspberry Pi
« Reply #4 on: July 07, 2014, 06:48:53 pm »
Yup, everything's fine now. Just had to add path to .so files while executing.

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 878
    • View Profile
Re: Illegal instruction on Raspberry Pi
« Reply #5 on: July 07, 2014, 09:07:00 pm »
Sounds like a version conflict. Not having PATH set/include the lib directory shouldn't cause the program to crash. Instead you should get a message about not being able to load the library.

 

anything