I have read every post I can find. I have Eclipse Mars release 4.5.1 and MinGW GCC ver 4.8.1
I have done the following:
Create new workspace.
Created File > New > C++ Project.>Executable>Hello World
Built and Run successfully
added the line
auto i = 6;
The IDE shows
'auto' changes meaning in C++11; please remove it [-
Wc++0x-compat]
I then went to project>C/C++ Build>Settings>Tool Settings>GCC C++ Compiler>Dialect>Language standard and selected C++11.
I also went to project>C/C++ General>Preprocessor Include Path>Providers Select CDT GCC Built-in Compiler Settings and untick “Use global provider...” box then add –std=c++0x
Finally I chose Project>Refresh and Project>Index>Rebuild
But still the error on auto.
Is this Wc++0x-compat switch a problem? Where do I find it?
What else should I do?
Related
I searched how to use to_string() in android ndk. After a long search, from this link, i changed the Application.mk file as said. And the cpp source compiled and build properly only from the terminal.
Terminal output :
> ndk-build
Android NDK: WARNING: APP_PLATFORM android-21 is larger than android:minSdkVersion 9 in
/<some path>/Android/Exercise01/AndroidManifest.xml
[armeabi-v7a] Install : libndkfoo.so => libs/armeabi/libndkfoo.so
But in ecplise IDE, still i am getting error as "Function 'to_string' could not be resolved". So from the IDE i am not able to run the android application. (Note : before the usage of std::to_string, the source compiled properly)
I tried to include the header files as below (under project properties->C/C++ general->Path and Symbols->GNU C++)
vstring.h from //android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.9/include/ext
&
basic_string.h from //android-ndk-r10d/sources/cxx-stl/gnu-libstdc++/4.9/include/bits
But no luck.
Androi.mk File
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_LDLIBS := -llog
TARGET_PLATFORM := android-21
TARGET_ARCH_ABI := armeabi-v7a
TARGET_ABI := android-21-armeabi-v7a # concatenation of above two variables
# Here we give our module name and source file(s)
LOCAL_MODULE := ndkfoo
LOCAL_C_INCLUDES := $(LOCAL_PATH)/header
LOCAL_SRC_FILES := src/NativeFunction.cpp src/clsArithmeticParser.cpp
include $(BUILD_SHARED_LIBRARY)
Application.mk
#APP_STL := stlport_static
APP_STL:=c++_static
I know, i am doing some small mistake, but not able to find for a long time. Any solution/suggestion appreciated.
Edited :
I am able use the std::to_string & std::stoll through eclipse in the below trick only. These can help some one in rare situation. So adding this point to test the c++11 support through eclipse IDE. The error shown only when the source file or the header file opened. Just close open source file documents (.h, .c, .cpp). Close and reopen the eclipse. Now it is ready to compile and run through the android emulator.
What version of Eclipse IDE do you use? Try to update to the latest Mars version, it may fix your problem.
After referring the answer by #Khaled Lakehal, I myself posting this answer for my question.Hope this may help someone.
Followed the below step to make it work:
Update the eclipse version from Luna to latest Mars 2
Imported the existing project from the old version of the eclipse
using -> import -> Existing Android code into Workspace
Had some problem with the C/C++ project conversion after import. So followed this link to undo the C/C++ project conversion
Converted the project to C/C++ newly.
To remove the error, I referred this link, and selected the "Run with build" only
Close & Reopen the IDE
So now able to use the std::to_string & std::stoll functions.
I have the following setup:
Eclipse Mars 4.5 (Build id:20150621-1200)
MinGW 201310 with g++ 4.8.1
Windows 10
I followed few post to add std=c++11 in Project property and make sure __cplusplus is 201103L. Here is the result:
I can see that std::map compile and run ok.
If I #include , there is no syntax error. But the declaration of thread in main() shows error "Type thread could not be resolved". Then I open up thread header file located in c:/MinGW/lib/gcc/mingw32/4.8.1/include/c++/thread, it seems that the whole class is dimmed due to that _GLIBCXX_HAS_GTHREADS is undefined. If I manually define it in the path and symbols, then the thread class is fully defined. But there comes more errors in the thread itself. Did I missed something? Or if the C++11 thread isn't ready on eclipse+MinGW? Thank you!
To get support for std::thread, you will want a MinGW build equipped with posix threading model support.
I'm not sure if there's a "classic" MinGW build with that feature,
but it's available with MinGW-w64.
You can get a MinGW-w64 installation in a number of ways, but the installer under the "Mingw-builds" link should be sufficient to get you started (and will let you pick which release GCC you want).
This is my first message on this forum… so hello at all..
I have to make c++ project with Eclipse IDE and using QT library… and I want to integrate QT library…
So I have downloaded Eclipse and QT version 5.1.0, included the library and all work…My problem born when I try to integrate qmake in eclipse for using moc compiler… I followed this procedure www.qtcentre.org/wiki/index.php?title=How_to_use_Eclipse_with_Qt4_in_10_steps.. but doesn't work…
Could someone help me?
Thanks
Sorry. I try to explain better the problem...
After installing eclipse with O.S. windows I have created a new project:
1) File->new->c++ Project (inserted the project name) and selected MinGW GCC as toolchains and debug and release as configurations
2)Project->Properties-> C/C++ Build->Settings->GCC C++ Compiler->Includes .. I included the path of may Qt library
3)Project->Properties-> C/C++ Build->Settings->MinGW C++ Linker-> LIbraries I included the link to the libraries.
4)I have created my file project called main.cpp and the header and cpp for my class (testclass1.h testclass1.cpp)
5) My class is a deriverd class of QObject and since I have to use signal and slot I need of Q_OBJECT macro.
6) Run->External ToolsConfigrations I created two new Programs.
.Name:Qmake
.Location .../bin/qmake
.Name:QtAssistant
.Location .../bin/assistant
7)Created a new target in my "Make target"
Target Name: qmake
Make Target: myQtProj.pro
Build Command: qmake
Target Name: all
Make Target: all
Build Command: default (make)
8) when I run qmake I have this error: undefined reference to `vtable for testclass1..I thinks that this depends on the macro Q_OBJECT.. I expect that running qmake the moc compiler is called so I should have in testclass1.cpp the macro Q_OBJECT "expanded"..
At the moment I solved the problem in this manner(from command line I called):
qmake -project (create myproject.pro)
qmake (create a makefile)
mingw32-make that create moc_testclass1.cpp...
So I copy the content of moc_testclass1.cpp in my testclass1... and I can build the project and all work. But this is not and automated way..
I hope to be more clear in my description.
Thanks for your help.
My goal has been to create multi-threading programs, and I can not even get a simple thread
to execute ON ECLIPSE CDT. my Tools:
ECLIPSE 3.8.1 CDT
Ubuntu 13.10
I have noticed very similar issues regarding mine. I have tried those other solutions but I could not get them to work for me.
When I type the code in Eclipse CDT, Eclipse does not 'resolve' the symbols 'thread', however, It can find the header file 'thread'. 'Mutex' also does not resolve. Furthermore, after building, I run the program, eclipse returns :
"terminate called after throwing an instance of 'std::system_error'
what(): Enable multithreading to use std::thread: Operation not permitted"
Some additional notes:
I can compile and execute the code in the terminal using:
'clang++ c.cpp -pthread -std=c++11'
but...
'g++ c.cpp -pthread -std=c++11' compiles and
produces the same error as quoted above. So it looks like it's a compiler issue. I did
start to write the code in a new project within Eclipse CDT with the clang++ compiler and now that gives the same non-resolved 'thread' and produces the error as quoted above. So now I think I have some wrong settings, paths or flags set in Eclipse.
include <iostream>
include <thread>
using namespace std;
void p1(){
cout<<"process 1 is processing"<<endl;
}
int main() {
thread t1(&p1);
cout<<"Hello from main()"<<endl;
t1.join();
return 0;
}
I have been struggling with the very same issue and I finally resolved it. Here is what I did:
1) Add -std=c++11 for c++ build. To do that right-click your project, select properties and then: C/C++ Build -> Settings -> GCC C++ Compiler -> Miscellaneous(last option)
In other flags append -std=c++11. My Other flags now looks like: -c -fmessage-length=0 -std=c++11 but yours may be a bit different.
2) Add some linker options. In the same view(C/C++ Build -> Settings) as above select the GCC C++ Linker option and from there go to Miscellaneous(second to last option). Add the following Linker flags(the field was empty for me): -Wl,--no-as-needed -pthread. Hit apply.
3) Add a macro. Again from the project properties menu(project->right click->properties). Navigate to C/C++ General -> Paths and symbols -> Symbols. Select GNU C++. Add a symbol with the name __GXX_EXPERIMENTAL_CXX0X__ and no value. Again hit apply.
4) Navigate to C/C++ General -> Preprocessor Include paths.. Select the providers tab. In this tab leave only the following two options checked: CDT GCC Built-in Compiler Settings and CDT Managed Build Setting Entries. Select CDT GCC Built-in Compiler Settings uncheck the checkbox Share setting entries between projects(global provider) and now the text box labeled Command to get compiler specs should be enabled. In this text box append the good old -std=c++11. The text now looks like this for me ${COMMAND} -E -P -v -dD ${INPUTS} -std=c++11. Hit apply one last time.
5) Rebuild the index for the project. To do that right click the project->Index->Rebuild
Following these steps I was able to compile a c++11 multithreaded program, execute it and also Eclipse CDT did not report any errors and was helpful with the autocompletion. Unfortunately this setting has to be done separately for Release and Debug(or at least I have not found a way to share it). Hope this helps.
This feels silly, but its been 2 days...somewhere after upgrading from Ubuntu 10.04 to 10.11 and from Eclipse Helios to Eclipse Indigo, I got stuck with the following problem:
Problem Description:
I'm trying to use a function in math.h called isinf(), but the problem also occurs with things like isnan(). The program compiles fine on the command line using make and fine in eclipse using build. But if I open the program file in eclipse it reports that it cannot reolve the isinf() function call. If I just insert the program contents into a new project and new source file, the error appears immediately. This problem did not occur under 11.04 with Eclipse Helios CDT
Questions:
Why are these errors only reported when the program file is opened and not on when the program is compiled; why are the errors not detected make is run from the command line? Is there a solution/workaround available?
Version Info
Linux Ubuntu 10.11 64-bit
Eclipse CDT Indigo, Service Release 1, Build id: 20110916-0149
(Also using Eclipse EE Indigo – if that makes a difference)
GNU Make 3.81
gcc 4.6.1-9Ubuntu3
To Duplicate:
Please find the two files you'll need to replicate below:
Step 0. Verify that everything is fine outside of Eclipse
Copy the attached source file and make file
create a directory e.g. Mkdir FunTest
Save the source file a 'Test.cpp' and the makefile as 'makefile'
Open a command prompt and navigate to the directory e.g. FunTest
Enter 'make'
Enter ./TestOut
Program responds “is not infinite”
Step 1. Create the project in Eclipse
Open Eclipse
Select File|New|MakeFile Project with Existing Code
Click Browse – navigate to the directory (FunTest) and click ok
Select 'Linux GCC' from the Toolchain selector
Click Finish
Step 2. Find the Error
Click Build All (Ctrl-B) – project builds without errors
Open the project in the project explorer to display the file in the directory
Double click on the file “Test.cpp”
Note the error icon next to line testing for infinity
Note the 2 error messages:
Semantic error: Function _isinff could not be resolved
Semantic error: Function _isinfl could not be resolved
Test.cpp:
include <math.h>
int main(int argc, char **argv)
{
int TestNum = 10;
if (isinf(TestNum) == 0)
printf("Not infinite\n");
return 0;
}
makefile:
# Specify the compiler
CC = g++
# Specify the compiler flags
CFLAGS += -c
# Specify the files making up the application
SOURCES = Test.cpp
OBJECTS = $(SOURCES:.cpp=.o)
EXECUTABLE = TestOut
all: $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) $(LDLIBS) -o $#
.cpp.o:
$(CC) $(CPPFLAGS) $(CFLAGS) $< -o $#
install:
#echo "Build complete!"
I have experienced similar problems of the CDT reporting errors even though the code compiled fine within Eclipse Indigo.
Project > Properties > Settings > Binary Parsers > "GNU Elf Parser"
helped in my case. I had the "Elf Parser" checked.
That looks like a problem that many others have had with eclipse CDT before. Sometimes shutting eclipse down and then starting it back up again is enough to help. If that isn't the case, take a look at what I have below:
Compilation ok, but eclipse content assist having problems
Check your includes: if you're using include<math.h> change it to include<cmath>. The same for stdio.h and stdlib.h, you should replace by cstdio and cstdlib. Another option may be change you project to a C project instead of a C++.
You are missing -lm option in your build preferences.
Project->Properties->Settings->Miscleanous->Other (linker) flags[]
For me, it was solved by adding a specific ‘Source Location’ folder, and removing the default. In Luna, it is under:
Project > Properties > C/C++ General > Paths and Symbols > Source
Location