Click here to Skip to main content
15,876,879 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: DATASET Pin
Richard Deeming29-Feb-24 21:34
mveRichard Deeming29-Feb-24 21:34 
GeneralRe: DATASET Pin
CPallini1-Mar-24 1:52
mveCPallini1-Mar-24 1:52 
QuestionHow to recover missing file ? Pin
Salvatore Terress28-Feb-24 6:08
Salvatore Terress28-Feb-24 6:08 
AnswerRe: How to recover missing file ? Pin
Maximilien28-Feb-24 7:37
Maximilien28-Feb-24 7:37 
GeneralRe: How to recover missing file ? Pin
Salvatore Terress28-Feb-24 10:51
Salvatore Terress28-Feb-24 10:51 
QuestionRe: How to recover missing file ? Pin
Richard MacCutchan28-Feb-24 8:00
mveRichard MacCutchan28-Feb-24 8:00 
AnswerRe: How to recover missing file ? Pin
jschell28-Feb-24 12:26
jschell28-Feb-24 12:26 
AnswerRe: How to recover missing file ? Pin
k505428-Feb-24 12:34
mvek505428-Feb-24 12:34 
!!! pkg-config is your friend !!!

Here's a very simple program that #includes <dbus/dbus.h>
C++
#include <iostream>
#include <dbus/dbus.h>

int main()
{
    std::cout << "Hello World\n";
}
Clearly, this does nothing but print "Hello World", but does ask the compiler to #include <dbus/dbus.h>

If we try to compile this naively, the compiler complains that it can't find the requested headers
Terminal
k5054@localhost:~/tmp $ g++ hello.cpp
hello.cpp:2:10: fatal error: dbus/dbus.h: No such file or directory
    2 | #include <dbus/dbus.h>
      |          ^~~~~~~~~~~~~
compilation terminated.

pkg-config --cflags dbus-1 returns the magic needed to find the headers:
Terminal
k5054@localhost:~/tmp $ pkg-config --cflags dbus-1
-I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include 
I've been over this before in answer to your question in QA I think, so I'm not going to repeat it here.

We can use some shell "magic" to tell the compiler to use pkg-config to find the headers:
Terminal
k5054@localhost:~/tmp$ g++ $(pkg-config --cflags dbus-1) hello.cpp
k5054@localhost:~/tmp$ ./a.out
Hello World
k5054@localhost:~/tmp$ 
This clearly finds the requested headers and compiles the program successfully. I'd recommend that you try this from the command line exactly as shown here. If you get a successful compile, you need to dig into your IDE and find out how to configure it correctly. If this doesn't work for you, then you've probably Elephant | [mastadon] ed up your linux installation, and my best recommendation would be to back anything you want to keep, purge your drives, then reinstall. Before recovering your backed up files, make sure that the above simple program will compile. If not, you need to figure out why.

In over 30 years of working with Unix like systems, the only time I've copied headers under /usr/include, or /usr/local/include to a local project was when I've been trying to do something weird, like trying to compile a new package on an obsolete OS [think trying to get a new version of GCC to compile on RedHat 9 (circa 2003)] or vice versa, e.g getting gcc-2.95 to compile on RedHat Fedora 37. If you find yourself copying includes from the system include directories then IMHO you're making a mistake, and clearly don't understand the build process. That would be true if you find yourself doing this on a Windows system as well.

Don't forget that in order to link to the dbus libraries, you'll need to add pkg-config --libs dbus-1 somewhere so that the link phase knows where to find the needed libraries.

Knowing that the -I flag tells the compiler where to look for include files is simple, basic unix developer course 101 stuff. You shouldn't have any issues understanding that if you've spent more than a couple of weeks doing any Linux or Unix development. The only thing I can think is that you've become over dependent on your IDE and you're not understanding the basic Linux development ecosystem. It might be worth while to break out one or two of the functional parts of your project from the UI/IDE and get them to compile using nothing more sophisticated than a Makefile. If you can get that done, and your IDE keeps breaking the build, you'll probably be better equipped to dig into the IDE settings and figure out what needs to be altered to get it to work.
Good Luck
"A little song, a little dance, a little seltzer down your pants"
Chuckles the clown

GeneralRe: How to recover missing file ? Pin
Salvatore Terress29-Feb-24 1:11
Salvatore Terress29-Feb-24 1:11 
GeneralRe: How to recover missing file ? Pin
k505429-Feb-24 5:19
mvek505429-Feb-24 5:19 
GeneralRe: How to recover missing file ? Pin
jschell29-Feb-24 12:24
jschell29-Feb-24 12:24 
GeneralRe: How to recover missing file ? Pin
k505429-Feb-24 12:50
mvek505429-Feb-24 12:50 
QuestionMpi blocking communication Pin
Member 1518121126-Feb-24 11:19
Member 1518121126-Feb-24 11:19 
AnswerRe: Mpi blocking communication Pin
jschell26-Feb-24 12:22
jschell26-Feb-24 12:22 
Questionhow to "include" this... Pin
Salvatore Terress26-Feb-24 8:37
Salvatore Terress26-Feb-24 8:37 
AnswerRe: how to "include" this... Pin
Richard MacCutchan26-Feb-24 9:09
mveRichard MacCutchan26-Feb-24 9:09 
AnswerRe: how to "include" this... Pin
jschell26-Feb-24 12:25
jschell26-Feb-24 12:25 
GeneralRe: how to "include" this... Pin
Salvatore Terress26-Feb-24 16:48
Salvatore Terress26-Feb-24 16:48 
GeneralRe: how to "include" this... Pin
RedDk27-Feb-24 7:51
RedDk27-Feb-24 7:51 
AnswerRe: how to "include" this... Pin
Maximilien27-Feb-24 1:32
Maximilien27-Feb-24 1:32 
GeneralRe: how to "include" this... Pin
Salvatore Terress27-Feb-24 7:19
Salvatore Terress27-Feb-24 7:19 
QuestionPaige-Tarjan algorithm in C Pin
Joeyabuki26-Feb-24 4:06
Joeyabuki26-Feb-24 4:06 
AnswerRe: Paige-Tarjan algorithm in C Pin
Maximilien26-Feb-24 5:51
Maximilien26-Feb-24 5:51 
GeneralRe: Paige-Tarjan algorithm in C Pin
Joeyabuki26-Feb-24 6:20
Joeyabuki26-Feb-24 6:20 
QuestionExtracting the Points from a CRgn Object - C / C++ / MFC ... Pin
Member 1601389325-Feb-24 18:47
Member 1601389325-Feb-24 18:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.