I am using GNU MCU Eclipse 4.7.2-202001271244 with GCC Linaro 7.5.0 (arm-linux-gnueabihf). Both are the latest versions as of now
I set up a simple project that uses pthreads and when I try to use PTHREAD_MUTEX_INITIALIZER I get an error in Eclipse even though g++ compiles it without error. The error from Eclipse is:
Invalid arguments ' Candidates are: () (const
{C:\Download\gcc-linaro-7.5.0-2019.12-i686-mingw32_arm-linux-gnueabihf\arm-linux-gnueabihf\libc\usr\include\bits\pthreadtypes.h:1809}
&) '
Looking at pthreadtypes.h, line 1809 is not even a valid line number
My test code is very simple:
#include <pthread.h>
int main(const int argc, const char* const argv[])
{
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
pthread_mutex_lock(&lock);
return 0;
}
I am pretty confident my project is set up correctly because I can take the g++ generated executable and run it successfully on my ARM processor
Does anyone have any ideas or suggestions on resolving this issue? Any thoughts would be greatly appreciated. I have tried searching for information with no luck
Related
My laptop can not compile a simple c++ code since yesterday, it works perfectly fine before.
The c++ code is can be a hello-world code in main.cpp file.
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
cout<<"Hello World"<<endl;
return 0;
}
I am trying to compile the code by
icpc main.cpp
The error information is
In file included from /Library/Developer/CommandLineTools/usr/include/c++/v1/algorithm(637),
from /Library/Developer/CommandLineTools/usr/include/c++/v1/__string(56),
from /Library/Developer/CommandLineTools/usr/include/c++/v1/string_view(171),
from /Library/Developer/CommandLineTools/usr/include/c++/v1/string(470),
from /Library/Developer/CommandLineTools/usr/include/c++/v1/__locale(15),
from /Library/Developer/CommandLineTools/usr/include/c++/v1/ios(216),
from /Library/Developer/CommandLineTools/usr/include/c++/v1/iostream(38),
from main.cpp(1):
/Library/Developer/CommandLineTools/usr/include/c++/v1/type_traits(2065): error: expected an identifier
: public decltype((_VSTD::__is_assignable_test<_Tp, _Arg>(0))) {};
compilation aborted for main.cpp (code 2)
A few information:
I am using icpc (ICC) 17.0.4 20170411, it is installed from IntelĀ® Parallel Studio XE Composer Edition for C++ macOS.
My mac is MacBook Pro (15-inch, 2017), version 10.12.6.
If I use gnu compiler, it works fine. While my code needs to use intel's compiler.
The code works before, do not know while it becomes this. I have already tried restarting the systems.
======================================================================
Update1: The problem happened after I update my "Command Line Tools for Xcode". It looks like the /Library/Developer/CommandLineTools/usr/include/c++/ is not right.
======================================================================
Update2: This is can be solved by using icpc -std=c++11 main.cpp
However when I change my main.cpp to
#include <iostream>
#include <vector>
#include <tuple>
using namespace std;
tuple<vector<int>, vector<int>, vector<int>>
getAllBlockMeanErrorTuple(const vector<int> &vec)
{
vector<int> fact, mean, err;
fact.resize( vec.size() );
mean.resize( vec.size() );
err.resize( vec.size() );
return make_tuple(fact, mean, err);
}
int main(int argc, char** argv)
{
cout<<"Hello World"<<endl;
return 0;
}
It has error again even if I use icpc -std=c++11 main.cpp
/Library/Developer/CommandLineTools/usr/include/c++/v1/__tuple(401): error: type name is not allowed
-> __all<typename enable_if<_Trait<_LArgs, _RArgs>::value, bool>::type{true}...>;
detected during:
I encountered the same issue while upgrading command line tools to the version of September 2017
While not finding a proper solution, I reinstalled previous version ( April 2017) of command line tools and it solved the problem (https://developer.apple.com/download/more/#).
I am looking forward to having a clean solution.
EDIT (5/12/17):
I solved the issue by recompiling everything using gcc. At compilation, Intel compilers will use the compiler that responds to gcc and g++ in the path. An installation with homebrew and some symlink in /usr/local/bin pushes the newly installed gcc in front of clang and then avoids gcc to change at each system update. Hope it helps.
Try to check that you are using right settings
and GNU is working because it automatically set to C++
try to set compiler to c++
hope this works.
OR You can use xcode to write c++ Code.
If I try to compile and run this
#include <string>
int main()
{
std::string strs[5];
return 0;
}
I get an error message of
The procedure entry point ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1Ev could not be located in the dynamic link library (path to exe).
I am using mingw-w64 gcc version 6.2.0 (i686-posix-dwarf-rev1) and have already tried (i686-posix-sjlj-rev1).
Is there another compiler version that does not encounter this bug or something I can do to my code to make it compile?
This question already has answers here:
Problems with std::stoi, not working on MinGW GCC 4.7.2
(2 answers)
Closed 7 years ago.
UPDATE:
Not only does this affect the MinGW version of G++, it also affects the Cygwin version. I can't use mingw-64 as its Windows port (win-builds) does not install G++ properly (doesn't install required .dlls) and when I install them myself G++ doesn't even run. This makes the problem even more serious.
END UPDATE
So I want to compile some C++ code with G++:
#include <iostream>
#include <cstdlib>
#include <time.h>
#include <string>
using namespace std;
int main(int argc, char *argv[]) {
int maxInt = stoi(argv[1]);
srand(time(0));
cout << rand() % maxInt << endl;
}
When I compile it though, I get this error:
test.cpp: In function 'int main(int, char**)':
test.cpp:6:30: error: 'stoi' was not declared in this sopce
int maxInt = stoi(argv[1]);
^
I have tried compiling it with -std=c++11 and -std=c++0x, but it still gives this error. I am trying to compile it on a Windows 8.1 laptop with about 200 GB of free space. It has 4 GB of RAM, and has MinGW installed from SourceForge. I'm using GCC version 4.8.1, so if the version may be the case, please tell me where to get a higher version?
Since you are trying to parse a c-string, why not to use std::atoi? Remember to include cstdlib.
I have downloaded and built Xerces-c on linux:
Linux xxxx 2.6.24.7-server-3mnb #1 SMP Wed Sep 9 16:34:18 EDT 2009 x86_64 Intel(R) Xeon(R) CPU 3065 # 2.33GHz GNU/Linux
Created the simple program:
#include <xercesc/sax2/XMLReaderFactory.hpp>
#include <xercesc/sax2/SAX2XMLReader.hpp>
#include <xercesc/sax2/DefaultHandler.hpp>
#include <xercesc/util/XMLUni.hpp>
//#include <xercesc/validators/common/Grammar.hpp>
XERCES_CPP_NAMESPACE_USE;
int main(int argC, char *argv[])
{
// DefaultHandler handler;
SAX2XMLReader *parser = XMLReaderFactory::createXMLReader();
delete parser;
return 0;
}
compiled it:
g++ -lcurl -o xtest test.cpp /usr/local/lib/libxerces-c.a
successful compile, run it and this is what I get:
./xtest
xtest: xercesc/util/XMemory.cpp:63: static void* xercesc_3_1::XMemory::operator new(size_t, xercesc_3_1::MemoryManager*): Assertion `manager != 0' failed.
Aborted (core dumped)
Anyone have similar experience/successfully built and used this library... how? It's becoming a real pain and apparently it's the only thing for linux that properly validates an XML document against multiple schemas with namespace support (or is it??)
It looks like you forgot to call XMLPlatformUtils::Initialize before using any xerces functionality.
Initialization must be called first in any client code.
Also, don't forget XMLPlatformUtils::Terminate() once you're done with xerces i.e. at the end of the program.
The termination call is currently optional, to aid those dynamically loading the parser to clean up before exit, or to avoid spurious reports from leak detectors.
AFAIR failing to init xerces results in the error you listed.
I'm trying to use std:getline() but getting a strange runtime error:
malloc: * error for object 0x10000a720: pointer being freed was not allocated
* set a breakpoint in malloc_error_break to debug
This is the code that produces this error:
//main.cpp
#include <iostream>
#include <sstream>
int main (int argc, char * const argv[])
{
std::istringstream my_str("demo string with spaces");
std::string word;
while (std::getline(my_str, word, ' ')) {
std::cout << word << std::endl;
}
return 0;
}
Before each word I get this error. From the comments it seems to be a OSX/XCode specific error. Any hints on that?
Update:
The error is only printed in Debug mode. If I build this code in Release mode everything is fine.
Update 2:
More info on that issue can be found here.
Solution:
Set
_GLIBCXX_FULLY_DYNAMIC_STRING=1
in your Preprocessor Macros in targets info build tab.
System info:
OSX 10.6.2 | XCode 3.2 | g++ 4.2 | debug config for i386
At least one person has reported problems with g++ 4.2.1 on Apple that seem possibly related to yours having to do with an improper configuration of the standard library with the _GLIBCXX_FULLY_DYNAMIC_STRING definition (not that I understand any of what I'm typing here).
You might get a bit of a clue from the newsgroup thread that includes this message:
http://gcc.gnu.org/ml/gcc-bugs/2009-10/msg00807.html