I am working in an MFC application (around 2000 files) with Visual Studio 2008. I run Cppcheck for this application, but I found these two issues.
Issue toomanyconfigs: (Information -- The checking of the file will be interrupted because there are too many #ifdef configurations. Checking of all #ifdef configurations can be forced by --force command line option or from GUI preferences. However that may increase the checking time.)
Issue missingInclude: (Information -- Cppcheck cannot find all the include files. Cppcheck can check the code without the include files found. But the results will probably be more accurate if all the include files are found. Please check your project's include directories and add all of them as include directories for Cppcheck. To see what files Cppcheck cannot find, use --check-config.)
My Cppcheck argument list is
cppcheck --quiet --verbose --check-config --force --enable=all --suppress=missingIncludeSystem --template=vs --std=c++11 $(ItemPath)
How can I resolve these issues?
I am a Cppcheck developer.
It is weird that you get the toomanyconfigs when you used --force. If you can create a file that reproduce the problem, please report it in our issue tracker. You can probably remove all code in the file and just keep the preprocessor directives.
You can specify include paths with -I.
Cppcheck-1.76 (next version) will be able to import Visual Studio 2010 and later solution files so you get includepaths automatically. Maybe that will be interesting to test.
Related
Is there a way to see the actual commmand line that VSCode is issuing to clang-tidy?
I am trying to figure out why clang-tidy is giving clang-diagnostic-error messages about being unable to find certain header files, though I have configured workspace settings file settings.json to with "C_Cpp.default.includePath" to include the necessary folders, and have configured settings.json to contain "C_Cpp.codeAnalysis.clangTidy.args" entries such as "-Imy_path/to/the/files".
The build (clang and/or gcc and/or aarch64-linux-g++) all build fine with no errors. I am using the cmake extension in VSCode to generate the makefile (Ninja) and run the build.
I can't find the reason why the #include files are not being found by clang-tidy, so it seems that checking the actual command line being issued by VSCode would be a starting point for debugging this.
Thanks in advance for any help debugging this configuration issue.
I'm building some custom Qt components as a static library, but I can't get past the compilation phase.
My project is structured as follows:
Root:
- .h and . cpp files of the custom Qt components
- GeneratedFiles/Debug/ <-- here the MOC compiler puts the generated moc_*.cpp files ("Debug" is automatically deducted from the build configuration, so it's Release for release builds)
That's a pretty standard folder setup, but for whatever reason the compiler can't find only the moc files. Anything that is in the root folder builds just fine, but the moc files are not found. Please note, the moc_ files are generated just fine and exist where they're supposed to be, with the correct content. The problem seems to be in the evaluation of the path GeneratedFiles\Debug\moc_whatever.cpp.
Interestingly enough, if I move a moc file (say, moc_example.cpp) in the root folder and manually adapt the call to CL.exe to compile moc_example.cpp instead of GeneratedFiles\Debug\moc_example.cpp, the file gets built.
I'm using VS 2017 version 15.7.1, CL is version 19.00.24215.1 for x64 and I'll update the question with any other detail might be useful, just add ask in a comment.
So... Why is the compiler telling me those files do not exist?
I finally solved this rebuilding the directory structure in a new directory. Apparently, using WSL's git to check out repositories under Windows breaks something in the filesystem in a way that is invisible from Explorer or Ubuntu's command line, but that breaks the compiler (and Visual Studio's intellisense).
Checking out the repository with Git for Windows seems to avoid causing the same problem.
Just installed the latest Eclipse IDE and am following the included C++ User Guide right from 'Before you begin' section.
The simple application was successfully completed but once I got to the makefile project and the C++ file tutorials, I got the "Unresolved inclusion: <iostream>" error and a bunch of others related to "cout, cin, endl" because of it.
I followed the tutorials exactly as instructed and am not sure why this occurred. I have since corrected it by following this answer, but now want to know why this happens, especially since I am following the official tutorial and do I have to add the C++ include path for every project on Eclipse?
Related Question
That first error in the screenshot linked in the comments provides a clue to the problem.
If you go to the preference page mentioned in the error's "Location", you'll see that there is a field called "Command to get compiler specs" with the contents something like:
${COMMAND} ${FLAGS} -E -P -v -dD "${INPUTS}"
This is a command that Eclipse tries to run to get your compiler to output its built-in include paths and other similar information.
The fact that you're getting the error Program "-E" not found in PATH suggests that the variables ${COMMAND} and ${FLAGS} are evaluating to empty strings, so that the first actual token in the command (which the shell then tries to interpret as the program name) is -E.
I'm not sure why those variables are evaluating to empty, but you should be able to work around the issue by replacing ${COMMAND} with g++ (presumably g++ is in your PATH).
I've searched for a few hours and tried a lot solutions.
Envirment: windows, Eclipse IDE for C/C++ Developers
Version: Kepler Service Release 2
CDT: 8.3.0
Following steps works for me:
make sure the envirement is clear. => I suggest delete the eclipse and unzip it again from your orginal download. Remove all variable relatated to eclipse and MinGW you set to PATH of envirment variables.
make sure the workspace is clear. => Delete .metadata folder in your workspace folder.
use valid MinGW. => the one using download tool is slow and I'm not sure which one to select. I suggest download MinGWStudio which contains an unzip MinGW from http://vaultec.mbnet.fi/mingwstudio.php This is a IDE tool like eclipse contains a downloaded unzip MinGW. Make sure you download the one plus MinGW compiler which is about 20M. You can use this studio if you want or copy the MinGW folder to C:/ if you still prefer eclipse. Copy /MinGW inside /MinGWStudio to C:/.
close your eclipse and reopen it, create a new project, you should able to see MinGW section for new project option, and it will auto map g++, gcc and include files under C:/MinGW folder. Just make sure you copy MinGW folder from MinGWStudio to the root of C:/.
You will able to see your include after these steps. Build your project, everything should goes well even there may some warning hint.
Hope it helps.
Details are saying I have two different tools of the same compiler. I'm not sure where to go from here to fix this so I can build my project. Any ideas?
This is the detailed message:
Errors occurred during the build.
Errors running builder 'CDT Builder' on project '263_Hw'.
Internal error building project 263_Hw configuration Debug
Generated resource conflict:
two resources of the same name: /263_Hw/Debug/main.o
generated by different tools
tool1: GCC C++ Compiler
tool2: GCC C++ Compiler
Generated resource conflict:
two resources of the same name: /263_Hw/Debug/main.o
generated by different tools
tool1: GCC C++ Compiler
tool2: GCC C++ Compiler
Internal error building project 263_Hw configuration Debug
Generated resource conflict:
two resources of the same name: /263_Hw/Debug/main.o
generated by different tools
tool1: GCC C++ Compiler
tool2: GCC C++ Compiler
Generated resource conflict:
two resources of the same name: /263_Hw/Debug/main.o
generated by different tools
tool1: GCC C++ Compiler
tool2: GCC C++ Compiler
The most likely situation: you have two source files with the same name but different file extensions. In your case, that would likely indicate you have something like
main.c
main.cpp
in your project tree. Could be tricky to see, especially if you have a lot of nested folders. I'd go to your source root and do a search for main.*
In Ecplise, right Click on project -> Properties -> C\C++ Build -> Tool Chain Editor. In the 'Current Builder' select box, select 'Gnu make builder' -> Apply (or Ok).
Try building the project again.
If you've exhausted all other options try using the gcc make tool directly:
1) Open the command line
2) cd to the folder containing the Make files (i.e. # cd 'C:\Path\To\MakeFile')
3) Assuming you have a typical MINGW windows install, run the command # C:\MinGW\bin\mingw32-make.exe all
4) the above command can be shorter if you have the MinGW folder set as a path variable.
5) The output binaries should be found in the bin folder in the same location.
Hope this helps anyone.
I have seen this same problem before but i don't remember what i did about it! For starters one way to try to solve it is by checking if you have more than one MinGW folder installed on your computer (I am assuming you use MinGW)! Also Check your project properties->c/c++ General->Paths and symbols->Includes and making sure that there are links to only one minGW folder! (It may look something like this (except for you they may start with "c:/mingw/...":
My solution was to delete the project (not the source code, just remove the project from Eclipse) and recreate it from scratch and setting up the include paths and linker paths again. Then it compiled properly.
This happened to me after I deleted a project from the workspace. I reimported the project with the same name to the same workspace, and when I tried to rebuild I got this error.
What I did was to delete the project from the workspace again, and then check my local directory where the workspace folder is. Voila, the deleted project is still in the workspace folder. So I deleted that project folder, then reimported the project again. It worked for me this way ;)
I'm trying to run Python modules in C++ using "#include <Python.h>", however, after setting the "Additional Include Dependencies" of the project to "\include" I get the following error when debuging,
LINK : fatal error LNK1104: cannot open file 'python27_d.lib'
I read that I should download the development version of Python, but I didn't find a link for that, plus, don't I just need the file 'python27_d.lib' to be copied to the "libs" folder?
Please note that I'm using the Anaconda distribution of Python.
Thanks in advance!
I normally circumvent this by using the non-debug Python lib in debug builds. Typically, this leads to code like:
#ifdef _DEBUG
#undef _DEBUG
#include <Python.h>
#define _DEBUG
#else
#include <Python.h>
#endif
where you hide the definition of _DEBUG during the inclusion of Python.h.
I don't know much about python, but the message indicates that python27_d.lib either doesn't exist, or at least doesn't exist where the linker is looking for it.
You already fixed the compiler include issue, now find the python27_d.lib file with Windows Explorer and and add that path to the Additional Library Dependencies path. It's under Configuration -> Linker -> General -> Additional Library Directories.
The "_d" indicates it's a debug library, so you'll want that one for your Debug configuration, and the one without the "_d" (probably) for your release configuration.
Put visual studio in release mode instead of debug.
You don't necessarily have to use a Python debug build...
[even if you are not usimng boost] I would have a look at the boost.python documentation where they have a wrapper for Python.h which handles all the windows debug issues, so that you can build a debug extension against a release python dll.
http://www.boost.org/doc/libs/1_53_0/libs/python/doc/building.html#id19
Python Debugging Builds
I ran into similar errors while attempting to use Boost.python to access Anaconda python packages from C++. Let me start off by saying that my personal impression of the C++ Boost libraries is that they are a great idea with incomplete documentation. There is a ton of documentation on boost.org, but it invariably seems to leave out critical details which the authors appear to consider too trivial to bother mentioning. But, let me get off my soapbox ...
The ongoing impetus for me to [hopefully, eventually] figure out how to get Boost.Python to work on my system is that there are so many great Python scientific packages [SymPy, Numpy, SciPy, matplotlib, etc] included in the Anaconda distribution and it would really be great to access them from C++ projects built with Qt Creator. And the Boost docs do seem to suggest that Boost.Python is supposed to do that for me. Alas, those docs seem to leave out critical details that the authors appear to consider too trivial to bother mentioning ...
Anyway, initially, I got a build error indicating that python.h could not be found. I got rid of that by adding these two statements to my Qt Creator project's .pro file, which tell qmake where Boost installed its include files and where Anaconda installed its python.h file on my system:
INCLUDEPATH += C:\boost_1_55_0
INCLUDEPATH += C:\Anaconda\include
After that, I got a LNK1104 error indicating that 'python27.lib' could not be found. I got rid of that by adding these two statements to my .pro file. The first tells qmake where to find Anaconda's python27.lib file. The second tells qmake where to find the boost.python binary:
LIBS += "C:/Anaconda/libs"
LIBS += "C:/boost_1_55_0/stage/lib/libboost_python-vc110-mt-gd-1_55.lib"
But, that is as far as I have gotten so far. I now get an error indicating it cannot open file 'C:/Anaconda/libs.obj' which I have not yet found a fix for. The error, of course, is caused by that file not existing. The challenge is to discover why it is being sought and where to find it.
On Visual studio, you need to add 'Additional include directories' for the project. Steps below.
right click on project -> properties -> c/c++ -> Additional Include Directories -> point it to 'Python\include' folder(ex: c:\python\include).