0

I'm using visual studio code, in window 10 device, and live in a area where internet accessibility is not good.

I have completed of lecturers of first week of cs50x. Had extracted cs50.h and cs50.c and copy them to C:\msys64\mingw64\include\ Now after running the code, I'm getting undefined reference to 'get_int' and Id returned 1 exit status.

  1. After going through some online solutions, I get this

In your source code, change #include <cs50.h> to #include <cs50.c> But I'm not finding any <cs50.h> in cs50.c source file instead it has "cs50.h"

  1. I'm not able to understand

How to link cs50 when compiling your code with clang, by using -lcs50

Manas Deo
  • 23
  • 1
  • 4
  • .h file are a header file that contains definition to include in other c or h file. .c file are the file that are to be compiled to generate object file that will then be linked to generate executsble program (.exe files on windows) so .h files in include is good. .c files must be in another dir. – Ptit Xav Mar 23 '22 at 07:29
  • You can only use `-lcs50` if you have installed the CS50 library or compiled the source code into a library. Otherwise you have to compile and link cs50.c with your project. – Gerhardh Mar 23 '22 at 07:32
  • @Gerhardh, where I'll use `-lcs50`?. I just installed `vs code` & `cs50 library` in `Ubuntu` as well – Manas Deo Mar 23 '22 at 09:19
  • Are you asking about Windows or Ubuntu now? If you have installed the library in Ubuntu, you can use `-lcs50` as last option in your compiler command. – Gerhardh Mar 23 '22 at 09:31
  • @Gerhardh, `compiler command?` there is a `terminal window` in Ubuntu. – Manas Deo Mar 23 '22 at 11:24
  • I assume you mean your shell window. What command do you enter to compile your code? – Gerhardh Mar 23 '22 at 11:26
  • @Gerhardh I'm using an extension in vs code `code runner`. – Manas Deo Mar 23 '22 at 11:43
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Mar 31 '22 at 22:49

0 Answers0