Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
ADDENDUM
Am I on right track ?

"add this to "im0plement" dbus in my copy of Linux ??? "

nov25-1@nov251-desktop:~$ g++ -Wall --std=c++11 -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include main.cpp -ldbus-1

not sure what this does

include main.cpp -ldbus-1

do I have to "add my app ?? what part ?? "






I am including a cloned (open source) "application" in my program.
Doing OK gradually adding required "include" headers...

until I run it this one

#include <dbus dbus.h="">
( this shoud read " include backslash dbus backslash dbus dot letter h ...,")

there is no visible reference, OK I may have missed it , what dbus.h does ( in github resource ) ...and WHERE it lives...

If it is indeed a "Linux system " resource

how do I link to it ?

What I have tried:

ask Mrs Goggle and found few "how to.." but no explanation what "dbus.h" does in Linux.
Posted
Updated 23-Feb-24 18:04pm
v4

 
Share this answer
 
Comments
Salvatore Terress 24-Feb-24 11:12am    
OK. I am making it too stupid - I can "include " it just like any other header.
I probably be netter off if I just copy it to my directory structure...
Salvatore Terress 24-Feb-24 11:55am    
This is getting confusing

I look in /usr/include/core/dbus/dbus.h and found no such reference
I tried to install libdbus-cpp-dev in Ubuntu but "no such package..."
Have you installed the libdbus-1-dev? The headers are included in that package, along with everything you need for programming against the library. You might also want to look into libdbus-cpp-dev, which appears to offer a CPP wrapper to the dbus library.

Copying the header to your work space is not advised. #include files often refer to other #includes, and you may end up having to copy most of /usr/include into your project directory just to get things to compile.

You need to look to your IDE documentation. It should tell you how to go about adding the right thing to the project file so that the project can find the headers.

If you're compiling by hand, you should know about pkg-config. e.g.
k5054@localhost$ pkg-config --list-all | grep dbus
dbus-1                         dbus - Free desktop message bus
k5054@localhost$ pkg-config --cflags --libs dbus-1
-I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -ldbus-1
We can use that to compile from the command line:
g++ $(pkg-config --cflags --libs) program.cpp -o program

If you're using Makefiles, you can use something like
CXXFLAGS = -Wall -Wextra $(shell pkg-config --cflags dbus-1)
LDFLAGS = -lfoo -lbar $(shell pkg-config --libs dbus-1)
 ...


Since you seem a bit unsure, a reminder:
-I adds a path to the compiler's search path for include files
-L adds a path to the linker's search path for libraries (.so and .a) 
-l adds a library name to the linker's list of objects to include when trying to resolve external object names.


Addendum: you can find what package files belong to using apt-file. See Linux Apt-file Command Help and Examples[^] Once you've installed and run apt-file update you can query the apt-file database for packages that include files with the given name:
$ apt-file search dbus/dbus.h
libdbus-1-dev: /usr/include/dbus-1.0/dbus/dbus.h
libdbus-cpp-dev: /usr/include/core/dbus/dbus.h 
This would indicate that the include file dbus/dbus.h is not part of the "common" include files, but is available as bar tof the libdbus-1-dev package.
 
Share this answer
 
v3
Comments
Salvatore Terress 24-Feb-24 12:29pm    
No, I tried to install the first package mentioned in the doc
File Packages
/usr/include/core/dbus/dbus.h libdbus-cpp-dev
/usr/include/dbus-1.0/dbus/dbus.h libdbus-1-dev

Let me try the other....


here it is !!

nov25-1@nov251-desktop:/usr/include/dbus-1.0/dbus$ ls
dbus-address.h dbus-macros.h dbus-protocol.h dbus-threads.h
dbus-bus.h dbus-memory.h dbus-server.h dbus-types.h
dbus-connection.h dbus-message.h dbus-shared.h
dbus-errors.h dbus-misc.h dbus-signature.h
dbus.h dbus-pending-call.h dbus-syntax.h
nov25-1@nov251-desktop:/usr/include/dbus-1.0/dbus$

and after modification of the original "include" I now have "dbus.h"...
Thanks
Salvatore Terress 25-Feb-24 20:07pm    
I did verify that "dbus.h" exist in my system.
As I( suspected - "dbus.h" header is a "wrapper" for many additional "incliude"......
and it fails to find very first
#include <dbus dbus-arch-deps.h="">

I went back to the source in github and cannot find dbus-arch-deps there

T tried to bypass #include <dbus dbus-arch-deps.h=""> but cannot in read only system file.

I may have to load my own copy of "dbus.h" so I can
, temporary, skip the "missing" header...
SOLVED / HACKED
Found yet another "Bluetooth" resource with dbus-arch-deps.h defined...
"it" compiles...

CASE TEMPORARY CLOSED
 
Share this answer
 
Comments
Salvatore Terress 26-Feb-24 14:06pm    
This is no longer a simple problem.
I am moving it to "discussions".
SORRY.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900