Configure to scan C/C++/Objective C

I follow the document to configure to scan C/C++/Objective C:

  • Download build-wrapper-linux-x86 from host SonarQube
  • Unzip it
  • Them execute command: build-wrapper-linux-x86-64 --out-dir build_wrapper_output_directory make clean all. It response: make: *** No rule to make target ‘clean’. Stop.
    I try: build-wrapper-linux-x86-64 --out-dir build_wrapper_output_directory make. But it still response: make: *** No targets specified and no makefile found. Stop.
    Please, help me to fix it.

Hey there.

Does running make clean all without the build wrapper produce a successful build? How do you normally build your C/C++ code (what command do you run)? That’s the command you should use (make clean all is just an example of a build command, you should use your own)

I’m sorry but I don’t quite understand what you mean.
I try that command to export folder output with build_wapper.json and add it into sonar_project.properties. But it is unsuccess.
I don’t know if I did it right? Can you guide me how to do it.
And, I try to scan code application with flutter language.
Thank you

What is your procedure to build your C/C++/… project normally?

Do you have a bunch of unix-scripts that call the compiler directly, or do you perhaps use “make” and pass it a special makefile with option “-f” ?

The “make” in the description of the build-wrapper is not a “feature” of the buildwrapper, but should just serve as the example command to first clean everything, then build everything of the project.

If you have a completely special way of compiling, answer here… I might have some more tricks in my toolbox to share :wink:

1 Like

Oh, my application coded with java language and flutter SDK.
But when I scan, it response have some file with C/C++/Objective C. And I work around with:
sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=-
sonar.objc.file.suffixes=-
in sonar-project.properties.
So,I find a way to scan for all, both java and C/C++/Objective C in my application.

With those properties, you essentially tell sonarqube to not treat any file as c/c++/objectiveC.

If you really do not want to scan these files, then all is fine, but your original question did not sound like that.

If you do have c/c++/objectiveC files and you want them scanned, then you went the wrong way with those properties.

If you want your c/c++/… files scanned, you need to tell sonarqube exactly how each single c/c++/objC source is compiled. If you can wrap your build-process with sonarqube, then sonarqube can find it out by itself. If you cannot go this way, you need at least a full log of every single compiler call.

1 Like

I mean I must work around to scan success.
And now, I want scan and don’t exclude C/C++/Objective C files in my application.

To go forward, you need to know the command that gets started to normally compile all your c/c++/objC sources (without thinking about sonarqube).

If you “just click a button”, then you must find out, what program or script gets started by that click.

Without a command that completely compiles your sources, it will be hard for you, and impossible for us to help you.

Can you show me example about step to step can scan all your c/c++/objC sources.

You can find a large number of examples here: SonarSource sample C and C++ projects with SonarCloud or SonarQube analysis configured · GitHub