1

I need to write a program for linux( lubuntu ) but I have a couple of problems. Unfortunately for some reason the header files in the /usr/include folder does not seem to be the right ones. Its like they are stripped down versions. For instance if you check Lubuntus /usr/include/pci.h its only roughly 40 lines long where the original version is much much bigger. So I went on a little hunt for the normal developer linux headers and ive found all of them in one place "/usr/src/linux-header-3.13.0-32-generic" . They should be the right ones though cause the headers have all of the functions I need.

My problem now though is Resource Linking in Eclipse C development version. Ive tried dragging the file into the Project folder (Needless to say will be a mess later on) but it didn't work. Ive tried Right clicking on project folder -> New -> Folder -> Advanced -> "Link to alternate location(Linked Folder)" -> linked the "/usr/src/linux-header-3.13.0-32-generic" . When include headers in the source it just seems to never be able to find them when you try and build the source. Doing it like the method above did make me wonder how the Libraries that the headers need to work with will be included.

So my question are. How can I link the headers from "/usr/src/linux-header-3.13.0-32-generic" into my project so that I can for example say #include and it actually then refers to the one in the "/usr/src/linux-header-3.13.0-32-generic" file instead of saying #include"/usr/src/linux-header-3.13.0.32-generic/include/linux/module.h" ?

How does this include the libraries that the headers in "/usr/src/linux-header-3.13.0-32-generic" need to work with?

If I have to link the libraries as well how do I do that in Eclipse?

  • Why don't you move those files located at "/usr/src/linux-header-3.13.0-32-generic" into "/usr/include", and also Linux is case-sensitive so #include "iostream" is NOT equal to #include "IOStream" etc. – Sohail xIN3N Aug 20 '14 at 07:22
  • Will the libraries sort themselves out though I just move them around like that? – BaddaBoompshhh Aug 20 '14 at 07:27
  • Maybe Yes... you should try this... – Sohail xIN3N Aug 20 '14 at 07:27
  • I would recommend doing like most C free software do: use a good editor (e.g. `emacs`), and several tools: GNU `make`, so write your own `Makefile` with relevant `CFLAGS`), compile with `gcc -Wall -g` thru `make` (maybe using `M-x compile` under Emacs), use `git` as the version control system, use `ctags` etc... In other words, I believe that Eclipse CDT is not the best tool to code in C under Linux. I never saw core free software developers (those working inside GCC, Gtk, the Linux kernel, ...) using it, and that is significant. – Basile Starynkevitch Aug 20 '14 at 07:39
  • @BasileStarynkevitch I think you are right but the learning curve is quite heavy especially if I have to learn makefiles to that extent. I know the makefiles end up being huge. Dont mind the effort its just the little time I have. – BaddaBoompshhh Aug 20 '14 at 08:12
  • No, `Makefile`-s can be made short (or can be generated e.g with *cmake* or *automake*). See e.g. [this example](http://stackoverflow.com/a/14180540/841108) and take advantage of GNU make. – Basile Starynkevitch Aug 20 '14 at 08:14
  • @BasileStarynkevitch Ok soo CPPFLAGS = -I/usr/include adds the entire folder as potential #include header files? Where will I find the LIBS for the Linux headers though? Ones Ill assign to "LDLIBS". Not quite sure what the OBJECTFILES constant is suppose to be doing though :/ Otherwise that seems pretty straight forward really. Especially the way you put it. – BaddaBoompshhh Aug 20 '14 at 09:03
  • Basically yes. Read relevant documentation of GCC (invoking flags) and GNU make. And Linux don't have folders but directories. – Basile Starynkevitch Aug 20 '14 at 09:05
  • Will this work " CPPFLAGS= -I C:\So\Do\header " – BaddaBoompshhh Aug 20 '14 at 12:04

1 Answers1

1

I would try going to C/C++ General > Paths and Symbols in the project Properties menu, and adding "/usr/src/linux-headers-3.13.0-24-generic/include", and then "#include " should work. It looks like there is a similar way to add libraries.

I admit that I always use an external build command with Eclipse, and it sounds like you are using a different setup. However, I always do this when the Eclipse indexer can't find includes, so I suspect it may work for you too. Let me know how it goes. Here a link in the Eclipse docs: http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.cdt.doc.user%2Ftasks%2Fcdt_t_proj_paths.htm

andrewlamb
  • 131
  • 5