I am trying to follow some lessons from cs50.net. In order to do that I needed to download 2 files since they are using some custom stuff. I am using Code::Blocks under windows XP. I have selected the gcc compiler during the install.
Here is what I did:
I have downloaded these two files
cs50.h
cs50.c
from here:
Index of /pub/releases/cs50
I figured I have to put the cs50.h file into this folder:
C:\Program Files\CodeBlocks\MinGW\include
First I have got a ton of errors whenever I was trying to compile anything including <cs50.h>
Then I realized downloading them will not work, so I just copied the content of the files form the website into notepad and saved them using the "" marks i.e. "cs50.h" . Now it seems the compiler can read the cs50.h file and I did not get errors anymore when I was using
#include <cs50.h>
BUT. I do get an error if I actually use a function from that file. So I guess there is more to do:
The error I get is:
Compiling: E:\C Programming\projects\getname.c
Linking console executable: E:\C Programming\projects\getname.exe
E:\C Programming\projects\getname.o:getname.c.text+0x37): undefined reference to `GetString()'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
1 errors, 0 warnings
The code I am trying to compile is this:
Code:
#include <cs50.h>
#include <stdio.h>
int
main(int argc, char *argv[])
{
printf("state your name: ");
string name = GetString();
printf("O hai, %s!\n", name);
}
I am guessing I will need to put the cs50.c file somewhere or link it somehow but I have no clue how to do that form within code::blocks.
Thanks for any help!