ld returned 1 exit status, fibonacci search

Viewed 277

i think my "dear" code has a problem, i'm using code block and when i try to compile, the compiler show me this error: "ld returned 1 exit status"

main.c

#include <stdio.h>
#include <stdlib.h>
#include "C:\Users\alexl_000\Desktop\fibmodnopoin\fib.h"

int main(){
    int position;
    int *fib_ptr,fib=2;
    char confirm='y';
    fib_ptr = &fib;

printf("find Fibonacci's number by it's position \n");

while(confirm=='y'){
    printf("insert position:");
    scanf("%d", &position);
    printf("%d \n",position);
    fib=fibonacci(position);
    printf("%d \n", *fib_ptr);
    printf("find new number?");
    scanf("%s", &confirm);
}
return 0;
}

fib.h

#ifndef FIB_H_INCLUDED
#define FIB_H_INCLUDED
#endif // FIB_H_INCLUDED

int fibonacci(int );

fib.c

#include <stdio.h>
#include <stdlib.h>


int fibonacci(int position){

    int fib1=1, fib2=1, count=3, fib;

    if (posizione==0)
      fib=0;

    else if (position==1||2 )
      fib=1;

    if (position>2){
      while(count <=  position){
         count++;
         fib=fib1+fib2;
         fib2=fib1;
         fib1=fib;
        }
    }
    return fib ;
}

compiler

||=== Build: Debug in fibmodnopoin (compiler: GNU GCC Compiler) ===|
||error: ld returned 1 exit status|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 0 second(s)) ===|

before there were a linking problem due to "debug" and "release" box not checked

reference not defined to "fibonacci"

but i solve it: right click to fib.c or\and fib.h, properties->build

i really do not find a way to solve the first problem...

Thank you for the attention

3 Answers
Related