Click here to Skip to main content
15,896,118 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: me vs. VS2022.. detecting NULL pointers Pin
Mircea Neacsu1-Mar-24 15:49
Mircea Neacsu1-Mar-24 15:49 
GeneralRe: me vs. VS2022.. detecting NULL pointers Pin
CPallini1-Mar-24 23:21
mveCPallini1-Mar-24 23:21 
AnswerRe: me vs. VS2022.. detecting NULL pointers Pin
Mircea Neacsu29-Feb-24 12:24
Mircea Neacsu29-Feb-24 12:24 
GeneralRe: me vs. VS2022.. detecting NULL pointers Pin
charlieg29-Feb-24 15:41
charlieg29-Feb-24 15:41 
GeneralRe: me vs. VS2022.. detecting NULL pointers Pin
Mircea Neacsu29-Feb-24 16:39
Mircea Neacsu29-Feb-24 16:39 
QuestionDATASET Pin
Aryan Gupta 202429-Feb-24 6:51
Aryan Gupta 202429-Feb-24 6:51 
AnswerRe: DATASET Pin
Dave Kreskowiak29-Feb-24 9:34
mveDave Kreskowiak29-Feb-24 9:34 
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 

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.