include .h header file into makefile
hi,
im using the given makefile from can-utils (RASPI bib) and want to include the bcm2835.h to the makefile. Of course i made it with the gcc example example.c -l bcm2835 command but now i need to put it into the makefile. (I also included it into the .c Code) thanks for your reply this is where i got the makefile |
I'm not really sure what do you mean by that.
Why do you want/need to put it into the makefile? |
Quote:
i thought this is the only way to compile the library too. f.e. make examplefile -lbcm2835 doesn't work. I made it in a different way, so im done but if this is interesting for another person, how to include this file into the makefile we can maintain this question. |
would be nice to explain what did you try (exactly). What do you mean by "to compile the library too".
-lbcm2835 should be put into the makefile, you cannot add it as an argument. Code:
examplefile: LDFLAGS += -lbcm2835 |
Yeah,
But the only question is where to put this in. I tried it like this to but seems to be the problem of sorting the arguments, because -lbcm2835 should be after examplefile.c and therefore I dont know where to set this part. |
Why not post your Makefile as an example? Including the .h file in the Makefile is not accurate, instead what people need to do is to use the -I argument and add that to the compile flags, typically named CFLAGS or CPPFLAGS and this flag variable is included in the call to the compiler. The -I argument gives the search path for include files. The other important point is that Makefiles care about TAB punctuation over a bunch of SPACES.
There are tons of notations people can, and do, use withing Makefiles, and it is always nice to see what someone has discovered, or what their style is. I keep some old Makefiles I've used around to refer to when I make new projects. |
Quote:
including -lbcm2835 into CFLAGES doesnīt solve this. sure you are right by saying its not about the bcm2853 headerfile into the makefile! |
you gave no enough information to give better help.
|
Quote:
Yes the concept of specifying a search path for include files is easy, however you do not appear to have clearly understood the former advice about that. The best way we can help you is for you to post the Makefile you do have, or if you aren't using a Makefile, for you to post the command line call you are making to compile this file. What I'm seeing (sorry to say) is that you've misinterpreted advice and tried it incorrectly. So please don't be angry with people trying to help you, and instead, give us the information we are asking for so that we can help you. We are all volunteers on LQ, like yourself. You are welcome on this site and your problem is one which I feel we can help you with. |
OK sorry. Do see that you have a link to the Makefile in your first post.
Line 48: CPPFLAGS += -Iinclude \ This line means to add the directory named include (off from the point where you are compiling) as a search directory for include files. Place your include file in that directory. Or, add to that list of -I something like: Code:
CPPFLAGS += -I. \ And then have this include file in that directory. |
All times are GMT -5. The time now is 07:00 AM. |