Genya_LC
Genya_LC

Reputation: 1

"collect2: error: ld returned 1 exit status" on Codeblocks (Raspberry Pi 3b/GCC 5.4.0)

Currently I'm learning how to create games (at a low level) at my degree. I'm programming on Ubuntu mate 16.04, Codeblocks 13.12 and this happen:

-------------- Build: Debug in s04 (compiler: GNU GCC Compiler)---------------

g++  -o bin/Debug/s04 obj/Debug/main.o obj/Debug/Pantalla.o   
obj/Debug/main.o: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
0 error(s), 0 warning(s) (0 minute(s), 0 second(s))

I must create a new window where my "game" will run... (I add code)

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "Pantalla.h"

//Ej.1
struct BalaRep
{
    int x;
    int y;
    int vx;
    int vy;
};
typedef struct BalaRep * Bala;

//Ej.2
Bala crea_bala ( double x, double y, double vx, double vy )
{
    Bala b=malloc(sizeof(struct BalaRep));
    b->x = x;
    b->y = y;
    b->vx = vx;
    b->vy = vy;
    return b;
}

//Ej.3
void libera_bala( Bala b )
{
    free(b);
}

//Ej.4
void mueve_bala( Bala b )
{
    b->x = (b->x)+ (b->vx);
    b->y = (b->y)+ (b->vy);
}

//Ej.5
void dibuja_bala( Bala b )
{
    Pantalla_DibujaRectangulo( b->x, b->y, 7, 7);
}

//Ej.6 
/*
double get_x_bala( Bala b )
{
    return b->x;
}
*/

//Ej.7
/*
double get_y_bala( Bala b )
{
    return b->y;
}
*/
int main( int argc, char *argv[] )
{
    Pantalla_Crea("Ejemplo 3", 640,480);
    Pantalla_ColorTrazo(255,0,0, 255);
    int x = 280;
    int y = 425;
    int x2 = 200;
    int y2 = 100;
    int vx2 = 5;
    Bala b = NULL;

    while ( Pantalla_Activa() )
    {
        //Crear bala
        if (Pantalla_TeclaPulsada(SDL_SCANCODE_SPACE))
        {
            libera_bala(b);
            b=NULL;
            b=crea_bala(x,y,0,-10);
        }

        //Movimiento del rectángulo
        if (Pantalla_TeclaPulsada(SDL_SCANCODE_RIGHT))
        {
            x = x + 5;
        }
        if (Pantalla_TeclaPulsada(SDL_SCANCODE_LEFT))
        {
            x = x - 5;
        }
        /*if (Pantalla_TeclaPulsada(SDL_SCANCODE_UP))
        {
            y = y - 5;
        }
        if (Pantalla_TeclaPulsada(SDL_SCANCODE_DOWN))
        {
            y = y + 5;
        }*/

        //Bordes no-salir
        if (x > 640-80)
        {
            x = 640 - 80;
        }
        if (x < 0)
        {
            x = 0;
        }
        if (y > 480-40)
        {
            y = 480 - 40;
        }
        if (y < 0)
        {
            y = 0;
        }

        //Mov enemigo
        x2 = x2 + vx2;

        //Bordes no-salir enemigo
        if (x2 > 640-80)
        {
            x2 = 640 - 80;
            vx2 = vx2 * (-1);
        }
        if (x2 < 0)
        {
            x2 = 0;
            vx2 = vx2 * (-1);
        }


        //BALA
        if (b!=NULL)
        {
            mueve_bala(b);
        }

        if ((b!=NULL) && ((b->y) <= 0))
        {
            libera_bala(b);
            b=NULL;
        }

        Pantalla_DibujaRellenoFondo( 255,255,255, 255 );
        Pantalla_DibujaRectangulo( x, y, 80,40 );
        Pantalla_DibujaRectangulo( x2, y2, 80,40 );
        if (b!=NULL)
        {
            dibuja_bala(b);
        }
        Pantalla_Actualiza();
        Pantalla_Espera(40);
    }
    Pantalla_Libera();
    return 0;
    }

There is a file that teachers give us to run it properly. Furthermore, my classmate run the same code (what I add) on his laptop and it works. Excuse me, I know my English is bad...

Upvotes: 0

Views: 455

Answers (1)

Superlokkus
Superlokkus

Reputation: 5039

Obviously the object files are incompatible either because your build process is broken or if your professor just gives you the compiled object file, because it is not ABI compatible with your implementation i.e. compiler, OS, architecture.

Upvotes: 0

Related Questions