LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-14-2018, 04:19 AM   #1
stestraspb
LQ Newbie
 
Registered: Sep 2018
Posts: 4

Rep: Reputation: Disabled
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

Last edited by stestraspb; 09-14-2018 at 04:22 AM.
 
Old 09-14-2018, 06:28 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,629

Rep: Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265
I'm not really sure what do you mean by that.
Why do you want/need to put it into the makefile?
 
Old 09-14-2018, 06:45 AM   #3
stestraspb
LQ Newbie
 
Registered: Sep 2018
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
I'm not really sure what do you mean by that.
Why do you want/need to put it into the makefile?
Hi,

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.
 
Old 09-14-2018, 06:58 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,629

Rep: Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265
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
probably works, but I can only guess.
 
Old 09-14-2018, 07:05 AM   #5
stestraspb
LQ Newbie
 
Registered: Sep 2018
Posts: 4

Original Poster
Rep: Reputation: Disabled
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 don’t know where to set this part.
 
Old 09-14-2018, 07:35 AM   #6
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,876
Blog Entries: 13

Rep: Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929
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.
 
Old 09-14-2018, 07:43 AM   #7
stestraspb
LQ Newbie
 
Registered: Sep 2018
Posts: 4

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by rtmistler View Post
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.
this is just basic stuff i didnīt ask for it. I postet the link above!
including -lbcm2835 into CFLAGES doesnīt solve this.
sure you are right by saying its not about the bcm2853 headerfile into the makefile!
 
Old 09-14-2018, 08:18 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,629

Rep: Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265
you gave no enough information to give better help.
 
Old 09-14-2018, 08:53 AM   #9
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,876
Blog Entries: 13

Rep: Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929
Quote:
Originally Posted by stestraspb View Post
this is just basic stuff i didnīt ask for it. I postet the link above!
including -lbcm2835 into CFLAGES doesnīt solve this.
sure you are right by saying its not about the bcm2853 headerfile into the makefile!
Makefiles "can" be very simple, or they can be somewhat more complex, we haven't seen yours so we do not know what notations you are using.


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.

Last edited by rtmistler; 09-14-2018 at 08:54 AM.
 
1 members found this post helpful.
Old 09-14-2018, 11:19 AM   #10
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,876
Blog Entries: 13

Rep: Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929Reputation: 4929
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. \
So as to make ".", or your current directory also be in the include file search path.

And then have this include file in that directory.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Makefile not finding the include file dexterous.me82 Linux - Software 1 08-25-2013 11:20 AM
[SOLVED] how to include a file after updating in makefile k_element Linux - Newbie 1 04-17-2012 06:04 AM
include header file utkarshrawat Programming 6 03-22-2011 11:28 AM
cant include libipq.h header file rohit83.ken Programming 3 04-04-2008 01:53 AM
unable to include header file.. nick021 Programming 2 05-05-2006 03:11 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:46 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration