Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22118

gcc - warning: implicit declaration of function 'get_int'

$
0
0

I am doing the cs50 course and decided to run the code from there on my pc.

I have the following code:

#include "cs50.h"#include <stdio.h>int main(void){    int n;    do    {        //gets an integer from a user        n = get_int("Height: ");    }    while (n < 1 || n > 8);    for (int i = 1; i <= n; i++)    {        for (int j = 0; j < n * 2 + 2; j++)        {            //prints hashes only if j is more or equal to n - 1             if (j >= n - i && j <= n - 1)            {                printf("#");            }            //prints empty spaces to make the pyromide right alinged            else if (j <= n - i)            {                printf("");            }            //makes empty spaces between two pyromids            else if (j >= n - 1 && j <= n + 1)            {                printf("");            }            //adds hashes for the second pyromid            else if (j >= n + 2 && j <= n + 1 + i)            {                printf("#");            }        }        //starts a new line after finishing the code        printf("\n");    }}

and when I try to compile it this happens:

gcc cs50.o mario.c -o mario.exe -std=c99 -lcs50mario.c: In function 'main':mario.c:10:9: warning: implicit declaration of function 'get_int' [-Wimplicit-function-declaration]         n = get_int("Height: ");         ^C:/Program Files (x86)/Dev-Cpp/MinGW64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lcs50collect2.exe: error: ld returned 1 exit status

I am using gcc compiler on a Windows PC. I also downloaded the cs50 library from here and tried in many ways to compile and run my code.

For instance, I tried to build an intermediate file from cs50.c and cs50.h by using this line gcc -c cs50.c it created an object named cs50.o, linking it didn't work either. The last attempt to link the cs50 library with this -lcs50 did nothing as well.

I tried to use the following methods, but they too didn't work for me:


Viewing all articles
Browse latest Browse all 22118

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>