0

I am new to clang. I am on a MacOS cataloina. I am using this command to compile some cpp code:

$ clang++ -std=c++11 Heartbeat.cpp opencv.cpp RPPG.cpp `pkg-config --cflags --libs opencv` -o test

This command works and I can run ./test and everything goes well.

As you can see, I am using the library opencv. I installed this via brew (brew install opencv). When I run ls /usr/local/Cellar/opencv/4.5.0_4/include/opencv4//opencv2/ , I see the entire opencv package. However, if I uninstall this and recompile, my code still compiles. This indicates I have opencv installed somewhere else. I've installed opencv in a conda virtual environment, but I can't see how that would effect things.

How do I print out the path to the opencv that clang uses so I can find the files?

I need to know because I am trying to see if I have opencv2/face.hpp installed.

EDIT

This is output from the original clang++ compile command PLUS adding -M:

clang: warning: -lopencv_dnn.3.4.10: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lopencv_highgui.3.4.10: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lopencv_ml.3.4.10: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lopencv_objdetect.3.4.10: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lopencv_shape.3.4.10: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lopencv_stitching.3.4.10: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lopencv_superres.3.4.10: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lopencv_videostab.3.4.10: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lopencv_calib3d.3.4.10: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lopencv_videoio.3.4.10: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lopencv_imgcodecs.3.4.10: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lopencv_features2d.3.4.10: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lopencv_video.3.4.10: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lopencv_photo.3.4.10: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lopencv_imgproc.3.4.10: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lopencv_flann.3.4.10: 'linker' input unused [-Wunused-command-line-argument]
clang: warning: -lopencv_core.3.4.10: 'linker' input unused [-Wunused-command-line-argument]
clang: error: cannot specify -o when generating multiple output files
connor449
  • 1,549
  • 2
  • 18
  • 49
  • 1
    duplicate is for gcc but clang has the same options – Alan Birtles Dec 16 '20 at 19:52
  • @AlanBirtles Thanks but I am confused. I entered `$ clang++ -M opencv` and I got `clang: warning: opencv: 'linker' input unused [-Wunused-command-line-argument]`. – connor449 Dec 16 '20 at 19:59
  • I also tried `clang++ -M opencv.hpp` and got `opencv.hpp:15:10: fatal error: 'opencv2/core.hpp' file not found #include ^~~~~~~~~~~~~~~~~~ 1 error generated.` – connor449 Dec 16 '20 at 20:00
  • Not sure what's going on here, was hoping for just a print out of the relative path to the library? – connor449 Dec 16 '20 at 20:00
  • 1
    run your normal command and just add `-M`, your object file will contain the used headers or add `-MD` to put them in a separate file – Alan Birtles Dec 16 '20 at 20:02
  • So I entered `clang++ -std=c++11 -M Heartbeat.cpp opencv.cpp RPPG.cpp `pkg-config --cflags --libs opencv` -o test1` and I got output that I added to the question body. How do I interpret this? – connor449 Dec 16 '20 at 20:04
  • 1
    `-M` doesn't compile so you don't need to add the linker flags, `-MD` is probably easier to use – Alan Birtles Dec 16 '20 at 20:06
  • Got it, thank you, this is just what I was looking for! – connor449 Dec 16 '20 at 20:07
  • @AlanBirtles if you have the time, you ought to formalize that as an answer. As you can see there are a few subtleties that can trip up the unwary. – user4581301 Dec 16 '20 at 20:10
  • @user4581301 It's all there in the existing answers, its not something I've used before I just repeated what was in the existing answers – Alan Birtles Dec 16 '20 at 20:25
  • @AlanBirtles Shoot. My page was stale. Didn't notice you'd already closed the sucker. – user4581301 Dec 16 '20 at 20:27

0 Answers0