# How do I include subfolders, and how do I have .h files inside subfolders find other .h files in other subfolders?

It may be best to look at this example: https://github.com/PR2/linux_networki...

I'm trying to get the code here to compile but it can't find

"/home/marco/pr2_hydro_packages/src/linux_networking/wpa_supplicant_node/wpa_supplicant/wpa_supplicant/wpa_supplicant_i.h:18:24: fatal error: utils/list.h: No such file or directory."

My question is, how do I set up the CMakeLists in catkin so that the wpa_supplicant_i.h can find the utils/list.h file which exists in another subdirectory? I've tried including all of the paths, and no avail.

Suggestions?

edit retag close merge delete

Sort by » oldest newest most voted

So it seems you've tried a lot of things, and that is confusing the issue. As far I can see, none of the things in this line are going to work:

https://github.com/PR2/linux_networki...

It appears there is a copy of wpa_supplicant in both the wpa_supplicant package and the wpa_supplicant_node package. I'm not sure which one you want to do, but is there a reason you don't just install wpa_supplicant from apt-get?

This is one of the root issues, from where do you want to get utils/list.h?

If utils/list.h is to be provided from wpa_supplicant_node, then you just need something like this in the CMakeLists.txt of wpa_supplicant_node:

include_directories(wpa_supplicant/src)


Because in that case utils/list.h is in <git root>/wpa_supplicant_node/wpa_supplicant/src/utils/list.h. You were close, you had this in the above linked line: ${catkin_INCLUDE_DIRS}wpa_supplicant/src, but the missing space between ${catkin_INCLUDE_DIRS} and wpa_supplicant/src causes them to be concatenated, so that will not work. I think if you put a space between those two and remove all the other entries it should work.

If utils/list.h is provided by another package (like wpa_supplicant) then you'll need to do something like what is suggested here:

Basically you need to install the header add the folder which contains utils/list.h to your exported include paths for the wpa_supplicant package.

If wpa_supplicant is to be used from the system (installed using apt-get) then your pkg-config approach in wpa_supplicant_node, which is currently commented out, might work. You'd have to look at wpa_supplicant's upstream documentation to find out how you are supposed to build against it.

more

Thanks! This worked.

( 2014-10-02 14:38:22 -0600 )edit