This is the header file and its C file:
cs50.h and
cs50.c
Now I use them in the following example http://www.paste.ubuntu.com/576370/ — which is no longer available.
I already put the header file in /usr/bin/include or something like that and when I try to compile my code using gcc -o xxx xxx.c, it doesn’t work, so tried to fix this and the following way worked: http://www.paste.ubuntu.com/576371/ — which is no longer available.
Now I want to do something to make the ‘make’ command work as the gcc does.
What do I need to do?
The following was the old topic:
I was using
gcccommand to
compile C programs but after a period
of time I got a problem. I need
to compile a new header file and use
it as a library.The header file called
cs50.h.so after doing it and it’s ok I can
compile using the followinggcc -o xxx xxx.c -lcs50It works but now I want to use ‘make’
command and I can’t get it to work.It just don’t compile the header file
and library as gcc was before I edit
it to accept the cs50 library.So now I want to add to the ‘make’
command the following:-lcs50Can anyone help me in this please?
Near the top of your Makefile, add the line:
If you are using Make’s default (implicit) rules for the building, then that is all you need to do. If you are using explicit rules, you will need to add $(LDLIBS) to your explicit rules.
If there is no Makefile, then make is using default rules, and you can either just create a makefile with
or tell make to link with certain libraries by specifying the required libraries in LDLIBS in the environment. For example, if you are using a sh-derived shell (anything other than csh or tcsh) you can do:
If you are using a csh variant, you can do:
or just do (again, for non-csh shells)
before running make. (For csh variants, do setenv LDLIBS -lcs50)