I need to use the C++ osmium library and I program using Eclipse cdt.
To be sure my system is well configured, I managed to compile and link few of the examples by hand using the installed gcc 4.8.2 that is enough according to osmium documentation.
Osmium uses C++11 and it seems my Eclipse has a problem understanding it.
I followed the instruction in the not-really-duplicate answer, but does not help.
I added -std=c++11 to the project properties under C++ Build -> Settings -> C++ compiler -> Miscellaneous and under C++ Build -> Discovery Options.
I also tried adding the macro __GXX_EXPERIMENTAL_CXX0X__.
Strangely in my main file it seems the C++11 features are working, for example I can write
for (auto a : {1,2,3,4,5}) {}
but the osmium directory I copied in the project instead results filled of errors. It is not a missing include directory since the lines #include <osmium/so/and/so> show no errors.
Similarly, std::move even after including utility, gives the cannot be resolved error.
However, I noticed that the code actually builds, even if Eclipse shows multiple errors around the code.
I stuck, what can I do to set up Eclipse?
Related
Eclipse is highlighting bool, true, and false as could not be resolved.
Note that the application builds fine.
How to fix this?
My Setup
Eclipse Version 2021-06 (4.20.0) Build 20210612-2011
gcc version 4.8.5
What I've tried
I've found posts that say to change the following:
First
Properties -> C/C++ Build -> Settings -> Tool Settings -> GCC C++
Compiler -> Dialect to -std=c++14 or whatever.
I can't find this option in my properties editor
Second
Select Window->Properties -> C/C++ General -> Preprocessor Include Paths, Marcos etc. -> Providers Tab
I did this and added -std=c99
no effect, or maybe the wrong std?
What I think is happening here is that the version that Eclipse is providing linting for is different than the one which is being used for building the program. Sync up the properties of the makefile with Eclipse.
You can find build properties at Project -> Properties -> Build Settings. Make sure the build command, flags, C dialect, etc are the same as the one in the makefile. Look at the CFLAGS variable of the makefile and it'll show the properties, like C standard, optimization(for debug mode, make sure there's none, use -g no matter what the makefile says because it's probably for release.) and then select the same options in Eclipse.
Most likely, the standard of C in the makefile is C99 but in Eclipse, it's C89 or something like that, in which case, simply modifying the standard will work.
If the makefile uses, g++ but is pure C, the project either uses a bit of C++, so port the project to a C++ project. If it's pure C but uses g++, you'll have to also make it a C++ project and deal with life or if you feel able enough to change the makefile, do so and use gcc. This problem is the most likely.
I don't even fully understand how Eclipse build works and that's why I migrated to Visual Studio Code, there might be some issues with this, feel free to ask for clarification by commenting. AND MAKE SURE YOU HAVE #include <stdbool.h> on each file that uses bools.
Clion does not officially support Intel C++ compiler but I found the information that it suppose to work. I am just not sure how to correctly setup the toolchain. At the moment I am successfully using the clang compiler. Simply changing to icc compiler fails to compile a simple test program. Unfortunately I could not find any more guidance about setting up the icc compiler on Clion, could someone more experienced to share some insights?
Currently:
Want to use intel c++:
I am using cygwin compiler (make, gdb, gcc, g++) GNU Project. I am specifying Clion's path to cygwin (gcc, cmake, make, g++) in File -> Settings -> Build, Execution, Deployment -> Toolchain. Click me - image settings Clion
Update 2021-12-06
From 2021.3, you can use a System toolchain for this.
Set environment variable VS2019INSTALLDIR or VS2017INSTALLDIR
Create a System toolchain in CLion
Add environment from file %ONEAPI_ROOT%\compiler\latest\env\vars.bat
Set MKake as nmake, C Compiler and C++ Compiler as icx
Note that you can't use icl, as cmake will fail when getting compiler information.
Original answer
You need to edit some environment variables.
Add %ICPP_COMPILER20%bin\intel64 to PATH
Add %ICPP_COMPILER20%compiler\lib\intel64 to LIB; but mostly LIB does not exist, so create this variable
You may need to modify the 20 in %ICPP_COMPILER20% to match your installation.
With the above steps, you should be able to pass the compiler check. However, CLion will complain "Unexpected compiler output".
This means you can compile your program with no issue, but the IDE can't recognize any header file and simply marks them as "not found".
I am trying to report a bug for a project using Bazel. As part of the issue report I would like to include information about the used C++ compiler.
Which command can I use to do so?
bazel build -s //the_target shows me that external/local_config_cc/wrapped_clang seems to be the compiler. In bazel-<project>/... I can find that path, but running the executable wrapped_clang in there, just leads to an abort.
This answer only applies if you're using Bazel autoconfigured C++ toolchain. If you don't you'll have to modify it.
So for debugging the best would be to zip entire local_config_cc and also to provide version of the compiler ($CC --version). You get the local_config_cc at:
`bazel info output_base`/external/local_config_cc
Path to the compiler is written into the wrapped_clang script in case of the toolchain that supports both C++ and ObjC (this one gets enabled when Xcode is properly detected). C++ only toolchain invokes compiler directly (but the CROSSTOOL file can still be useful for debugging). And just in case, you can force C++ only toolchain by setting BAZEL_USE_CPP_ONLY_TOOLCHAIN=1 environment variable.
I'm using android NDK r8d, and eclipse Juno. I'm trying to compile C++ code which uses C++11 stuff like mutex, lock_guard, shared_ptr, etc. in a native android project in eclipse.
I get errors like:
"error: 'shared_ptr' is not a member of 'std'"
"fatal error: mutex: No such file or directory"
I came across a similar question here. It seems to work for them, but the explanation there is not complete so I can't get it to work for me.
I added "NDK_TOOLCHAIN_VERSION=4.7" to the Application.mk and "LOCAL_CFLAGS += -std=c++11" to Android.mk file. Still, it doesn't compile.
In the link above it says:
"Be sure that the standard library include path (like
/android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/4.7/include) is in the
target settings."
How and where do I insert it?
I also get errors in eclipse IDE (on the source, before compiling). I know I should define "__GXX_EXPERIMENTAL_CXX0X__" to resolve them but I just don't know where to put it.
So, if someone could post an answer with a full explanation of how to compile and make eclipse work with C++11 it would be great.
Regarding your first question:
Go to Project > Properties > C/C++ General / Paths and Symbols
In the "Includes" tab, add the proper directory, e.g.
/android-ndk-r8d/sources/cxx-stl/gnu-libstdc++/4.7/include
Regarding your second question, I'm also looking for an answer. It is absolutely not clear how to define the GXX_EXPERIMENTAL_CXX0X macro in Eclipse.
Some say that it should be "added as a predefined macro to the indexer", but it looks like we both could not find a way to implement that...
I have read elsewhere that it should be added to "C/C++ General / Paths and Symbols / Symbols / GNU C++" but I can't find the "Symbols / GNU C++" part in my version of Indigo.
I find export an environment variable NDK_TOOLCHAIN_VERSION=4.8 before i start eclipse can solve this problem.
Eclipse use ndk's default toolchain version 4.6, if NDK_TOOLCHAIN_VERSION is not define, and gcc witch this version does not support all c++11's future like multithread and so on.
I am using Netbeans 7.2.1 for Ubuntu Quantal Quetzal to program C++. Unfortunately, its code assistance doesn't recognize features of C++11 even after I specified the C++ version to be C++11 and then re-parsed my code.
My code, which replies on C++11 features such as unordered_map are compiling and running just fine though.
Hence, I hypothesized that I might not be telling code assistance to seek the right directories for various headers. Hence, I went to Tools -> Options -> c/C++ and added some more directories in the "Include Directories" section (for 4.7.2):
Strangely, next to the directories I just added are little keys. What do these little keys mean?
Fyi, code assistance still does not recognize C++11 features.
They are almost certainly the include paths built into the compiler. The code assistant needs to know them or it will miss vital information needed for understanding the other headers and completions but because they are built into the compiler they cannot be changed by the user so they have a key next to them to show they cannot be changed
This is however an educated guess based on my work in other C++ IDEs and knowledge of how compilers handle this stuff
Assuming you are using gcc you can find a list of the built in include directories with echo | g++ -Wp,-v -x c++ - -fsyntax-only and check if they match up.