jus
jus

Reputation: 11

#include "header_file.hpp" error. Task is to integrate iceoryx in C++ project

I installed iceoryx from git repository in my linux system following the procedure as described. I am taking code snippets from example code given in iceoryx repository as I want to use iceoryx in my C++ project. When I use the example code in my C++ project the #include "iceoryx_hoofs/posix_wrapper/signal_watcher.hpp" lines are showing an error: no such file or directory

#include "iceoryx_hoofs/posix_wrapper/signal_watcher.hpp"
#include "iceoryx_posh/popo/untyped_publisher.hpp"
#include "iceoryx_posh/runtime/posh_runtime.hpp"

I tried including the static path of these headers.

#include "/usr/local/includes/iceoryx/v2.90.0/iceoryx_hoofs/posix_wrapper/signal_watcher.hpp"

The same error message pops up. no such file or directory

The make file also has the following lines

INCLUDEPATH += $$PWD/../../../../../usr/local/include
DEPENDPATH += $$PWD/../../../../../usr/local/include

The /usr/local/include contains the iceoryx folder where the required header files are located after installation.

compile output

This is the compailer output.'../middleware/publisher_gpsdata.cpp:3:10: fatal error: iceoryx_hoofs/posix_wrapper/signal_watcher.hpp: No such file or directory
3 | #include "iceoryx_hoofs/posix_wrapper/signal_watcher.hpp"
  |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

compilation terminated. 
make: *** [Makefile:1258: publisher_gpsdata.o] Error 1
11:15:05: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project middleware (kit: Desktop Qt 5.15.2 GCC 64bit)
When executing step "Make"

The problem is, I have no experience of using a complete software downloaded from git and used it to develop a new project. Tell me what is wrong and the steps required to include these headers in my C++ project. I highly appreciate it.

Upvotes: 0

Views: 321

Answers (2)

Simon
Simon

Reputation: 1

The iceoryx template GitHub repository and its CMakeLists.txt might be useful. It's a template on how to build and use the upstream iceoryx from source. find_package is used together with FetchContent. Then you can avoid dealing with include paths.

It's used for the ara::com-like automotive SOA binding.

Upvotes: 0

MadScientist
MadScientist

Reputation: 100926

You still didn't show us the most important thing: the compiler invocation (the compile command line that make printed). You also didn't show us enough of your makefile to infer what it might look like. If you've added @ to the beginning of your compile lines so that make doesn't print them, well, that's bad. Remove that so you can see what make is actually doing.

All we can give you is generalities. If you have a line like:

#include "iceoryx_hoofs/posix_wrapper/signal_watcher.hpp"

then the compiler will append that path to each of the built-in locations it looks for, plus each of the -I options on the command line, to search for the file.

You say that the full path to that file is:

/usr/local/includes/iceoryx/v2.90.0/iceoryx_hoofs/posix_wrapper/signal_watcher.hpp

That means that on your compile line, you need to have the path:

-I/usr/local/includes/iceoryx/v2.90.0

so that when the path in the #include is appended to it, you'll find the right file.

Note, this:

INCLUDEPATH += $$PWD/../../../../../usr/local/include
DEPENDPATH += $$PWD/../../../../../usr/local/include

is a bad idea. You don't say how you USE these variables (again, you don't show your compile line or the part of your makefile that uses these) but it's not a good idea to use a shell variable like $PWD. Not all shells set this variable, and not all the time.

You can either invoke pwd:

INCLUDEPATH += $$(pwd)/../../../../../usr/local/include
DEPENDPATH += $$(pwd)/../../../../../usr/local/include

or use make's CURDIR variable:

INCLUDEPATH += $(CURDIR)/../../../../../usr/local/include
DEPENDPATH += $(CURDIR)/../../../../../usr/local/include

but this is not enough since you're missing the v2.90.0 directory.

Anyway, with the limited information you provided that's about all we can do to help.

Upvotes: 1

Related Questions