You are not logged in.

#1 2013-09-23 16:27:54

maximax
Member
Registered: 2011-09-29
Posts: 7

[SOLVED] g++ does not find header file in /usr/include/subfolder

Hi, I am not sure which category I should have posted this to, I hope it fits here.
I am not very skilled at C++ or programming in general and I don't know how this thing with the include directory actually works.

I am trying to implement a kalman filter using easykf
I did create a PKGBUILD and changed the install prefix to /usr and installed.

Header files were installed in

/usr/include/easykf

Now when I use

#include <ukf.h>

and compile I get

fatal error: ukf.h: No such file or directory|

When I tell Code::Blocks to look for files in /usr/include/easykf the headers are found.

What makes me curious is that I also installed another library package named kalman with a custom PKGBUILD, this package also installed header files into 

/usr/include/kalman

but I can include headers from this directory without performing any additional tasks.

Can anyone tell me why ukf.h is not being found by the compiler?
And could I change anything in the packaging process so that it will be found?

This is the (shortened) PKGBUILD

pkgname=easykf
pkgver=2.03
pkgrel=2
pkgdesc="C++ Kalman Filter library"
arch=('x86_64')
url="http://code.google.com/p/easykf/"
license=('New BSD Licence')
depends=('doxygen')
source=($pkgname-$pkgver.tar.gz)
md5sums=('0d5e58c2e54588b8a70a21c4397b0a44')

build() {
    cd "$srcdir/$pkgname-$pkgver"
    ./configure --prefix=/usr --sysconfdir=/etc --with-gnu-ld  # I have tried packaging without the gnu-ld option with the same result
    make
}
package() {
    cd "$srcdir/$pkgname-$pkgver"
    sudo make DESTDIR="$pkgdir/" install
}

Last edited by maximax (2013-09-27 00:27:57)

Offline

#2 2013-09-23 16:51:12

jdarnold
Member
From: Medford MA USA
Registered: 2009-12-15
Posts: 485
Website

Re: [SOLVED] g++ does not find header file in /usr/include/subfolder

Because without a path, it only looks in /usr/include. Use this instead:

#include <easykf/ukf.h>

Offline

#3 2013-09-23 17:47:51

maximax
Member
Registered: 2011-09-29
Posts: 7

Re: [SOLVED] g++ does not find header file in /usr/include/subfolder

Yes I should have mentioned, I did that, but the problem is that ukf.h calls other header files in the same directory -- which then cannot be found either. So I have to supply the include search path.

What I don't get is why it works for the other headers from the kalman package (which are in /usr/include/kalman) without providing a search path.

Offline

#4 2013-09-23 18:03:07

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,461

Re: [SOLVED] g++ does not find header file in /usr/include/subfolder

Try this or something similar in the build funtion:

export CFLAGS="$CFLAGS -I/usr/include/easykf"

Edit: I think I misunderstood, the problem isn't with the program with the PKGBUILD but with your program that you're building manually? Just add -I/usr/include/easykf to the build command.

Last edited by Scimmia (2013-09-23 18:56:01)

Offline

#5 2013-09-23 19:06:37

jdarnold
Member
From: Medford MA USA
Registered: 2009-12-15
Posts: 485
Website

Re: [SOLVED] g++ does not find header file in /usr/include/subfolder

Ah yes - in that case you'll have to do as Scimia says - add a -I (that's a capital Eye) to the g++ command line:

$ g++ -I/usr/include/easykf testkf.cc

But that is bad form for the easykf include files if they don't have #include <easykf/> in their header files.

Last edited by jdarnold (2013-09-23 19:07:28)

Offline

#6 2013-09-27 00:06:17

maximax
Member
Registered: 2011-09-29
Posts: 7

Re: [SOLVED] g++ does not find header file in /usr/include/subfolder

Sorry I was really busy the last few days. Thank you for your answers!

I probably should have left out all the specifics of what the software was that I was packaging, because I think what I was really asking did not come across clearly. What I really wanted to know is:

Why do I have to provide the "-I /usr/include/headers_dir" compiler option for some libraries but not for others, although the header files for each lie in a level 1 subdir of /usr/include?

I thought that maybe there was some kind of index of installed libraries that I didn't know about, which I could have updated from within PKGBUILD (so I guess that's why I included it originally). Seems to me now, though, that this is not the case.

I did put in some google time (but not lots b/c 1. hard to google and 2. busy) to find an answer, but to no avail and it's not really top priority right now (and quite honestly never will be, since there is the -I option), so I guess it'll have to wait, unless someone knows...

---EDIT---
So, right after I posted this (stupid me) I had a little think and I finally understand, whats happening.

1. Headers are not found without specifying the directory they are in.
2. I need the -I option because easykf headers are not well formed.

Thanks a lot!

Last edited by maximax (2013-09-27 00:26:03)

Offline

Board footer

Powered by FluxBB