Printf("Please input a string to count how long it is: ") To make sure our library works, we can throw one of the example scripts in the lecture and see if we can compile it using cs50.h header file for the get_string() method. My MinGW is installed in C:\ so I copy them there We are interested in only 2 of them cs50.h libcs50.aĬopy Library and header files to their target locations. Now using the generated cs50.o object file we can create our cs50 library archive file.Īfter all this steps we ended with 2 additional files to our original files. Now we need to compile object file for the library using Navigate into src directory and list the files to make sure you are on the right location usingĬool, we are here. This should be applicable for any other libraries introduced later in the course.ĭownload latest source code file cs50.c and header file cs50.h from and save them in Documents/Harvard_CS50/src Now to the important bit, installing CS50 library locally and using it offline. If you see Hello StackOverflow, your compiler works and you can write C code.start Git Bash -> navigate to working directory.by saving it in your working directory Documents/Harvard_CS50/Week2/ hello.c.You can use my configuration for reference. Once Git installed make sure that gcc packages are installed.I prefer to use Git as I need linux tools such as sed, awk, pull, push on my Windows and can replace Guthub's terminal. It includes Git Bash, which is MINGW64 linux terminal. Steps for setting up gcc C compiler, if already set please skip to 5 Under Windows using MinGW and Notepad as an IDE (because I love it and use it usually while codding python) I finally found a solution and some time to write it down. I take this course and sometimes I need to practice offline while I am traveling or commuting. To link against a library: gcc -o myProgram myProgram.c -l(library name goes here but no parentheses) You need to link against the library during compilation. Read also How to debug small programs and the famous SICP (which teaches very important concepts you might want to use guile on Linux while reading it, see for more). Get the habit to always ask for warnings from the compiler, and always improve your program till you get no warnings: the compiler is your friend, it is helping you! Very quickly you'll want to use build automation tools like GNU make (perhaps with the help of remake on Linux) Don't use the default name a.outĭirectory giving options -I (for preprocessor includes) and -L for libraries can be given several times, order is significant (search order). End with -o your-program-name to give the name of the produced binary.Pur the library names -laa and -lbb (when the libaa.so depends upon libbb.so, in that order).Put the library directories -Lmy-lib-dir/ if relevant.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |