I've installed MongoDB on ubuntu 12.10, tested on the mongo shell and it works ok.
Then, i installed cxx-driver from http://dl.mongodb.org/dl/cxx-driver/
Here is a MongoDB client example that i'm trying to build:
#include <cstdlib>
#include <iostream>
#include "mongo/bson/bsonobjbuilder.h"
#include "mongo/client/dbclient.h"
#include "mongo/client/dbclientcursor.h"
#include <boost/shared_ptr.hpp>
using namespace mongo;
void run() {
DBClientConnection c;
c.connect("localhost");
boost::shared_ptr<DBClientCursor> cursor =
c.query("test", BSONObj());
while (cursor->more())
std::cout << cursor->next().toString() << std::endl;
}
int main() {
try {
run();
std::cout << "connected ok" << std::endl;
} catch( const DBException &e ) {
std::cout << "caught " << e.what() << std::endl;
}
return EXIT_SUCCESS;
}
But this fails with this error:
In file included from /home/lurscher/third_party/usr/local/include/mongo/bson/oid.h:22:0,
from /home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h:25,
from /home/lurscher/third_party/usr/local/include/mongo/bson/bsonobjbuilder.h:29,
from test_mongo.cpp:3:
/home/lurscher/third_party/usr/local/include/mongo/bson/util/misc.h: In member function ‘time_t mongo::Date_t::toTimeT() const’:
/home/lurscher/third_party/usr/local/include/mongo/bson/util/misc.h:96:42: error: ‘verify’ was not declared in this scope
In file included from /home/lurscher/third_party/usr/local/include/mongo/util/hex.h:22:0,
from /home/lurscher/third_party/usr/local/include/mongo/bson/oid.h:23,
from /home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h:25,
from /home/lurscher/third_party/usr/local/include/mongo/bson/bsonobjbuilder.h:29,
from test_mongo.cpp:3:
/home/lurscher/third_party/usr/local/include/mongo/bson/util/builder.h: In member function ‘void mongo::StringBuilderImpl<Allocator>::appendDoubleNice(double)’:
/home/lurscher/third_party/usr/local/include/mongo/bson/util/builder.h:302:28: error: there are no arguments to ‘verify’ that depend on a template parameter, so a declaration of ‘verify’ must be available [-fpermissive]
/home/lurscher/third_party/usr/local/include/mongo/bson/util/builder.h:302:28: note: (if you use ‘-fpermissive’, G++ will accept your code, but allowing the use of an undeclared name is deprecated)
/home/lurscher/third_party/usr/local/include/mongo/bson/util/builder.h:303:33: error: there are no arguments to ‘verify’ that depend on a template parameter, so a declaration of ‘verify’ must be available [-fpermissive]
/home/lurscher/third_party/usr/local/include/mongo/bson/util/builder.h: In member function ‘mongo::StringBuilderImpl<Allocator>& mongo::StringBuilderImpl<Allocator>::SBNUM(T, int, const char*)’:
/home/lurscher/third_party/usr/local/include/mongo/bson/util/builder.h:336:28: error: there are no arguments to ‘verify’ that depend on a template parameter, so a declaration of ‘verify’ must be available [-fpermissive]
/home/lurscher/third_party/usr/local/include/mongo/bson/util/builder.h:337:33: error: there are no arguments to ‘verify’ that depend on a template parameter, so a declaration of ‘verify’ must be available [-fpermissive]
In file included from /home/lurscher/third_party/usr/local/include/mongo/bson/oid.h:23:0,
from /home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h:25,
from /home/lurscher/third_party/usr/local/include/mongo/bson/bsonobjbuilder.h:29,
from test_mongo.cpp:3:
/home/lurscher/third_party/usr/local/include/mongo/util/hex.h: In function ‘int mongo::fromHex(char)’:
/home/lurscher/third_party/usr/local/include/mongo/util/hex.h:33:23: error: ‘verify’ was not declared in this scope
In file included from /home/lurscher/third_party/usr/local/include/mongo/bson/bsonobjbuilder.h:29:0,
from test_mongo.cpp:3:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h: In member function ‘const char* mongo::BSONElement::codeWScopeCode() const’:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h:265:70: error: ‘massert’ was not declared in this scope
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h: In member function ‘int mongo::BSONElement::codeWScopeCodeLen() const’:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h:272:70: error: ‘massert’ was not declared in this scope
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h: In member function ‘const char* mongo::BSONElement::binData(int&) const’:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h:309:39: error: ‘verify’ was not declared in this scope
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h: In member function ‘mongo::BinDataType mongo::BSONElement::binDataType() const’:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h:328:39: error: ‘verify’ was not declared in this scope
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h: In member function ‘const char* mongo::BSONElement::regex() const’:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h:335:35: error: ‘verify’ was not declared in this scope
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h: In member function ‘const char* mongo::BSONElement::dbrefNS() const’:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h:409:63: error: ‘uassert’ was not declared in this scope
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h: In member function ‘const mongo::OID& mongo::BSONElement::dbrefOID() const’:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h:414:63: error: ‘uassert’ was not declared in this scope
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h: In constructor ‘mongo::BSONElement::BSONElement(const char*, int)’:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h:439:72: error: ‘uassert’ was not declared in this scope
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h: In member function ‘const mongo::BSONElement& mongo::BSONElement::chk(bool) const’:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h:477:83: error: ‘massert’ was not declared in this scope
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h: In member function ‘int mongo::BSONElement::canonicalType() const’:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h:522:21: error: ‘verify’ was not declared in this scope
In file included from /home/lurscher/third_party/usr/local/include/mongo/bson/bsonobjbuilder.h:30:0,
from test_mongo.cpp:3:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonobj.h: In member function ‘void mongo::BSONObj::appendSelfToBufBuilder(mongo::BufBuilder&) const’:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonobj.h:456:31: error: ‘verify’ was not declared in this scope
In file included from /home/lurscher/third_party/usr/local/include/mongo/bson/bsonobjbuilder.h:31:0,
from test_mongo.cpp:3:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonmisc.h: At global scope:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonmisc.h:173:9: error: ‘auto_ptr’ in namespace ‘std’ does not name a type
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonmisc.h: In member function ‘bool mongo::BSONObjBuilderValueStream::haveSubobj() const’:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonmisc.h:171:42: error: ‘_subobj’ was not declared in this scope
In file included from test_mongo.cpp:3:0:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonobjbuilder.h: In member function ‘virtual mongo::BSONObjBuilder& mongo::BSONObjBuilder::append(const mongo::BSONElement&)’:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonobjbuilder.h:124:30: error: ‘verify’ was not declared in this scope
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonobjbuilder.h: In member function ‘virtual mongo::BSONObjBuilder& mongo::BSONObjBuilder::appendAs(const mongo::BSONElement&, const mongo::StringData&)’:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonobjbuilder.h:131:30: error: ‘verify’ was not declared in this scope
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonobjbuilder.h: In member function ‘mongo::BSONObjBuilder& mongo::BSONObjBuilder::appendObject(const mongo::StringData&, const char*, int)’:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonobjbuilder.h:148:29: error: ‘verify’ was not declared in this scope
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonobjbuilder.h: In member function ‘virtual mongo::BSONObj mongo::BSONObjBuilder::obj()’:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonobjbuilder.h:554:65: error: ‘massert’ was not declared in this scope
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonobjbuilder.h: In member function ‘char* mongo::BSONObjBuilder::decouple(int&)’:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonobjbuilder.h:589:23: error: ‘verify’ was not declared in this scope
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonobjbuilder.h: In member function ‘mongo::Labeler mongo::BSONObjBuilder::operator<<(const mongo::Labeler::Label&)’:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonobjbuilder.h:629:74: error: ‘massert’ was not declared in this scope
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonobjbuilder.h: In member function ‘void mongo::BSONArrayBuilder::fill(int)’:
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonobjbuilder.h:836:102: error: ‘uassert’ was not declared in this scope
In file included from /home/lurscher/third_party/usr/local/include/mongo/db/jsobj.h:41:0,
from /home/lurscher/third_party/usr/local/include/mongo/client/authentication_table.h:23,
from /home/lurscher/third_party/usr/local/include/mongo/client/dbclientinterface.h:26,
from /home/lurscher/third_party/usr/local/include/mongo/client/connpool.h:23,
from /home/lurscher/third_party/usr/local/include/mongo/client/dbclient.h:32,
from test_mongo.cpp:4:
/home/lurscher/third_party/usr/local/include/mongo/db/../bson/bson-inl.h: In member function ‘void mongo::BSONObjBuilderValueStream::endField(const char*)’:
/home/lurscher/third_party/usr/local/include/mongo/db/../bson/bson-inl.h:359:9: error: ‘_subobj’ was not declared in this scope
/home/lurscher/third_party/usr/local/include/mongo/db/../bson/bson-inl.h: In member function ‘mongo::BSONObjBuilder* mongo::BSONObjBuilderValueStream::subobj()’:
/home/lurscher/third_party/usr/local/include/mongo/db/../bson/bson-inl.h:365:13: error: ‘_subobj’ was not declared in this scope
/home/lurscher/third_party/usr/local/include/mongo/db/../bson/bson-inl.h:366:16: error: ‘_subobj’ was not declared in this scope
test_mongo.cpp: In function ‘void run()’:
test_mongo.cpp:15:28: error: conversion from ‘std::auto_ptr<mongo::DBClientCursor>’ to non-scalar type ‘boost::shared_ptr<mongo::DBClientCursor>’ requested
In file included from /home/lurscher/third_party/usr/local/include/mongo/util/hex.h:22:0,
from /home/lurscher/third_party/usr/local/include/mongo/bson/oid.h:23,
from /home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h:25,
from /home/lurscher/third_party/usr/local/include/mongo/bson/bsonobjbuilder.h:29,
from test_mongo.cpp:3:
/home/lurscher/third_party/usr/local/include/mongo/bson/util/builder.h: In member function ‘void mongo::StringBuilderImpl<Allocator>::appendDoubleNice(double) [with Allocator = mongo::TrivialAllocator]’:
/home/lurscher/third_party/usr/local/include/mongo/db/../bson/bson-inl.h:702:42: instantiated from here
/home/lurscher/third_party/usr/local/include/mongo/bson/util/builder.h:302:13: error: ‘verify’ was not declared in this scope
/home/lurscher/third_party/usr/local/include/mongo/bson/util/builder.h: In member function ‘mongo::StringBuilderImpl<Allocator>& mongo::StringBuilderImpl<Allocator>::SBNUM(T, int, const char*) [with T = int, Allocator = mongo::TrivialAllocator, mongo::StringBuilderImpl<Allocator> = mongo::StringBuilderImpl<mongo::TrivialAllocator>]’:
/home/lurscher/third_party/usr/local/include/mongo/bson/util/builder.h:272:53: instantiated from ‘mongo::StringBuilderImpl<Allocator>& mongo::StringBuilderImpl<Allocator>::operator<<(int) [with Allocator = mongo::TrivialAllocator, mongo::StringBuilderImpl<Allocator> = mongo::StringBuilderImpl<mongo::TrivialAllocator>]’
/home/lurscher/third_party/usr/local/include/mongo/bson/bsonelement.h:469:64: instantiated from here
/home/lurscher/third_party/usr/local/include/mongo/bson/util/builder.h:336:13: error: ‘verify’ was not declared in this scope
/home/lurscher/third_party/usr/local/include/mongo/bson/util/builder.h: In member function ‘mongo::StringBuilderImpl<Allocator>& mongo::StringBuilderImpl<Allocator>::SBNUM(T, int, const char*) [with T = unsigned int, Allocator = mongo::TrivialAllocator, mongo::StringBuilderImpl<Allocator> = mongo::StringBuilderImpl<mongo::TrivialAllocator>]’:
/home/lurscher/third_party/usr/local/include/mongo/bson/util/builder.h:275:53: instantiated from ‘mongo::StringBuilderImpl<Allocator>& mongo::StringBuilderImpl<Allocator>::operator<<(unsigned int) [with Allocator = mongo::TrivialAllocator, mongo::StringBuilderImpl<Allocator> = mongo::StringBuilderImpl<mongo::TrivialAllocator>]’
/home/lurscher/third_party/usr/local/include/mongo/db/../bson/bson-inl.h:493:66: instantiated from here
/home/lurscher/third_party/usr/local/include/mongo/bson/util/builder.h:336:13: error: ‘verify’ was not declared in this scope
/home/lurscher/third_party/usr/local/include/mongo/bson/util/builder.h: In member function ‘mongo::StringBuilderImpl<Allocator>& mongo::StringBuilderImpl<Allocator>::SBNUM(T, int, const char*) [with T = long long int, Allocator = mongo::TrivialAllocator, mongo::StringBuilderImpl<Allocator> = mongo::StringBuilderImpl<mongo::TrivialAllocator>]’:
/home/lurscher/third_party/usr/local/include/mongo/bson/util/builder.h:284:55: instantiated from ‘mongo::StringBuilderImpl<Allocator>& mongo::StringBuilderImpl<Allocator>::operator<<(long long int) [with Allocator = mongo::TrivialAllocator, mongo::StringBuilderImpl<Allocator> = mongo::StringBuilderImpl<mongo::TrivialAllocator>]’
/home/lurscher/third_party/usr/local/include/mongo/db/../bson/bson-inl.h:693:50: instantiated from here
/home/lurscher/third_party/usr/local/include/mongo/bson/util/builder.h:336:13: error: ‘verify’ was not declared in this scope
/home/lurscher/third_party/usr/local/include/mongo/bson/util/builder.h: In member function ‘mongo::StringBuilderImpl<Allocator>& mongo::StringBuilderImpl<Allocator>::SBNUM(T, int, const char*) [with T = long long unsigned int, Allocator = mongo::TrivialAllocator, mongo::StringBuilderImpl<Allocator> = mongo::StringBuilderImpl<mongo::TrivialAllocator>]’:
/home/lurscher/third_party/usr/local/include/mongo/bson/util/builder.h:287:55: instantiated from ‘mongo::StringBuilderImpl<Allocator>& mongo::StringBuilderImpl<Allocator>::operator<<(long long unsigned int) [with Allocator = mongo::TrivialAllocator, mongo::StringBuilderImpl<Allocator> = mongo::StringBuilderImpl<mongo::TrivialAllocator>]’
/home/lurscher/third_party/usr/local/include/mongo/db/../bson/bson-inl.h:776:48: instantiated from here
/home/lurscher/third_party/usr/local/include/mongo/bson/util/builder.h:336:13: error: ‘verify’ was not declared in this scope
Try this...
#include <cstdlib>
#include <iostream>
#include "mongo/client/dbclient.h"
using namespace mongo;
void run() {
mongo::DBClientConnection c;
c.connect("localhost");
auto_ptr<DBClientCursor> cursor = c.query("test.test", BSONObj());
while (cursor->more())
std::cout << cursor->next().toString() << std::endl;
}
int main() {
try {
run();
std::cout << "connected ok" << std::endl;
} catch( const DBException &e ) {
std::cout << "caught " << e.what() << std::endl;
}
return EXIT_SUCCESS;
}
They can be compiled using...
g++ test.cpp -pthread -lmongoclient -lboost_thread-mt -lboost_filesystem -lboost_program_options -lboost_system -o test
The reason for your code's not working is the order of your includes. You just have to put dbclient.h in front of the the mongo includes. Actually, you only need dbclient.h, as it includes all other necessary headers.
What you additionally need to get this working with a shared_ptr, is a cast, for DBClientConnection::query()returns a std::auto_ptr.
The code below should work fine:
#include "mongo/client/dbclient.h"
using namespace mongo;
void run() {
DBClientConnection c;
c.connect("localhost");
boost::shared_ptr<DBClientCursor> cursor =
(boost::shared_ptr<DBClientCursor>) c.query("test", BSONObj());
while (cursor->more())
std::cout << cursor->next().toString() << std::endl;
}
int main() {
try {
run();
std::cout << "connected ok" << std::endl;
} catch( const DBException &e ) {
std::cout << "caught " << e.what() << std::endl;
}
return EXIT_SUCCESS;
}
Related
The G++ complier is not working. Yesterday I was updating MinGW and Windows PATHS to get Natbeans working but now Visual Studio Code is not Saying "Hello World", It is giving 20+ errors each run.
Any ideas on how to fix so I can run my program? I Uninstalled and Reinstalled MinGw twice but it did not work
Some of the Errors:
required from 'class std::__cxx11::basic_string<char16_t>'
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h:5677:41:
required from here
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ext\alloc_traits.h:61:53:
error: no type named 'size_type' in 'struct
std::allocator_traitsstd::allocator<char16_t >'
typedef typename _Base_type::size_type size_type;
^~~~~~~~~ c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ext\alloc_traits.h:62:53:
error: no type named 'difference_type' in 'struct
std::allocator_traitsstd::allocator<char16_t >'
typedef typename _Base_type::difference_type difference_type;
^~~~~~~~~~~~~~~ c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ext\alloc_traits.h:70:23:
error: no members matching
'__gnu_cxx::__alloc_traitsstd::allocator<char16_t >::_Base_type {aka
std::allocator_traitsstd::allocator<char16_t >}::max_size' in
'__gnu_cxx::__alloc_traitsstd::allocator<char16_t >::_Base_type {aka
struct std::allocator_traitsstd::allocator<char16_t >}'
using _Base_type::max_size;
^~~~~~~~ In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\string:52:0,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\locale_classes.h:40,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\ios_base.h:41,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:42,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from test17.cpp:23: c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h: In
member function 'size_t std::hashstd::__cxx11::basic_string<char16_t
::operator()(const u16string&) const': c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h:5678:42:
error: 'const u16string {aka const class
std::__cxx11::basic_string<char16_t>}' has no member named 'length'
__s.length() * sizeof(char16_t)); }
^~~~~~ In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h:40:0,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\string:52,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\locale_classes.h:40,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\ios_base.h:41,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:42,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from test17.cpp:23: c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ext\alloc_traits.h: In
instantiation of 'struct
__gnu_cxx::__alloc_traitsstd::allocator<char32_t >': c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h:75:24:
required from 'class std::__cxx11::basic_string<char32_t>'
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h:5692:41:
required from here
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ext\alloc_traits.h:61:53:
error: no type named 'size_type' in 'struct
std::allocator_traitsstd::allocator<char32_t >'
typedef typename _Base_type::size_type size_type;
^~~~~~~~~ c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ext\alloc_traits.h:62:53:
error: no type named 'difference_type' in 'struct
std::allocator_traitsstd::allocator<char32_t >'
typedef typename _Base_type::difference_type difference_type;
^~~~~~~~~~~~~~~ c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ext\alloc_traits.h:70:23:
error: no members matching
'__gnu_cxx::__alloc_traitsstd::allocator<char32_t >::_Base_type {aka
std::allocator_traitsstd::allocator<char32_t >}::max_size' in
'__gnu_cxx::__alloc_traitsstd::allocator<char32_t >::_Base_type {aka
struct std::allocator_traitsstd::allocator<char32_t >}'
using _Base_type::max_size;
^~~~~~~~ In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\string:52:0,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\locale_classes.h:40,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\ios_base.h:41,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ios:42,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\ostream:38,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\iostream:39,
from test17.cpp:23: c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h: In
member function 'size_t std::hashstd::__cxx11::basic_string<char32_t
::operator()(const u32string&) const': c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\basic_string.h:5693:42:
error: 'const u32string {aka const class
std::__cxx11::basic_string<char32_t>}' has no member named 'length'
The Code so far (Want it to print Hello World to the Console using C++):
#include <iostream>
int main()
{
//Prints Hello World to the Console
std::cout << "Hello World" << std::endl;
}
Desired output:
"Hello World"
after using cmake on my opencv build folder, I used cmd to run mingw32-make and got the following error.
In file included from C:\opencv\sources\modules\core\src\utils\logtagconfigparser.hpp:14,
from C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:6:
C:/opencv/sources/modules/core/include/opencv2/core/utils/logtag.hpp:18:5: error: 'LogLevel' does not name a type
LogLevel level;
^~~~~~~~
C:/opencv/sources/modules/core/include/opencv2/core/utils/logtag.hpp:20:38: error: 'LogLevel' has not been declared
inline LogTag(const char* _name, LogLevel _level)
^~~~~~~~
C:/opencv/sources/modules/core/include/opencv2/core/utils/logtag.hpp: In constructor 'cv::utils::logging::LogTag::LogTag(const char*, int)':
C:/opencv/sources/modules/core/include/opencv2/core/utils/logtag.hpp:22:11: error: class 'cv::utils::logging::LogTag' does not have any field named 'level'
, level(_level)
^~~~~
In file included from C:\opencv\sources\modules\core\src\utils\logtagconfigparser.hpp:15,
from C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:6:
C:\opencv\sources\modules\core\src\utils\logtagconfig.hpp: At global scope:
C:\opencv\sources\modules\core\src\utils\logtagconfig.hpp:20:5: error: 'LogLevel' does not name a type
LogLevel level;
^~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfig.hpp:34:48: error: 'LogLevel' has not been declared
LogTagConfig(const std::string& _namePart, LogLevel _level, bool _isGlobal = false,
^~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfig.hpp: In constructor 'cv::utils::logging::LogTagConfig::LogTagConfig()':
C:\opencv\sources\modules\core\src\utils\logtagconfig.hpp:27:11: error: class 'cv::utils::logging::LogTagConfig' does not have any field named 'level'
, level()
^~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfig.hpp: In constructor 'cv::utils::logging::LogTagConfig::LogTagConfig(const string&, int, bool, bool, bool)':
C:\opencv\sources\modules\core\src\utils\logtagconfig.hpp:37:11: error: class 'cv::utils::logging::LogTagConfig' does not have any field named 'level'
, level(_level)
^~~~~
In file included from C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:6:
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.hpp: At global scope:
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.hpp:24:32: error: expected ')' before 'defaultUnconfiguredGlobalLevel'
LogTagConfigParser(LogLevel defaultUnconfiguredGlobalLevel = LOG_LEVEL_VERBOSE);
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
)
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.hpp:40:49: error: 'LogLevel' has not been declared
void parseWildcard(const std::string& name, LogLevel level);
^~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.hpp:41:22: error: 'LogLevel' was not declared in this scope
static std::pair<LogLevel, bool> parseLogLevel(const std::string& s);
^~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.hpp:41:36: error: template argument 1 is invalid
static std::pair<LogLevel, bool> parseLogLevel(const std::string& s);
^
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.hpp:42:33: error: 'LogLevel' has not been declared
static std::string toString(LogLevel level);
^~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:12:39: error: expected constructor, destructor, or type conversion before '(' token
LogTagConfigParser::LogTagConfigParser(LogLevel defaultUnconfiguredGlobalLevel)
^
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp: In member function 'void cv::utils::logging::LogTagConfigParser::parseNameAndLevel(const string&)':
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:105:25: error: request for member 'second' in 'parsedLevel', which is of non-class type 'int'
if (parsedLevel.second)
^~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:108:43: error: request for member 'first' in 'parsedLevel', which is of non-class type 'int'
parseWildcard("", parsedLevel.first);
^~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:132:21: error: request for member 'second' in 'parsedLevel', which is of non-class type 'int'
if (parsedLevel.second)
^~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:134:59: error: request for member 'first' in 'parsedLevel', which is of non-class type 'int'
parseWildcard(s.substr(0u, colonIdx), parsedLevel.first);
^~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp: At global scope:
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:146:65: error: 'LogLevel' has not been declared
void LogTagConfigParser::parseWildcard(const std::string& name, LogLevel level)
^~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp: In member function 'void cv::utils::logging::LogTagConfigParser::parseWildcard(const string&, int)':
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:152:24: error: 'struct cv::utils::logging::LogTagConfig' has no member named 'level'
m_parsedGlobal.level = level;
^~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:158:24: error: 'struct cv::utils::logging::LogTagConfig' has no member named 'level'
m_parsedGlobal.level = level;
^~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:164:24: error: 'struct cv::utils::logging::LogTagConfig' has no member named 'level'
m_parsedGlobal.level = level;
^~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:175:24: error: 'struct cv::utils::logging::LogTagConfig' has no member named 'level'
m_parsedGlobal.level = level;
^~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp: At global scope:
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:193:11: error: 'LogLevel' was not declared in this scope
std::pair<LogLevel, bool> LogTagConfigParser::parseLogLevel(const std::string& s)
^~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:193:25: error: template argument 1 is invalid
std::pair<LogLevel, bool> LogTagConfigParser::parseLogLevel(const std::string& s)
^
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp: In static member function 'static int cv::utils::logging::LogTagConfigParser::parseLogLevel(const string&)':
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:195:47: error: 'LOG_LEVEL_VERBOSE' was not declared in this scope
const auto falseDontCare = std::make_pair(LOG_LEVEL_VERBOSE, false);
^~~~~~~~~~~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:195:47: note: suggested alternative: 'CV_LOG_LEVEL_VERBOSE'
const auto falseDontCare = std::make_pair(LOG_LEVEL_VERBOSE, false);
^~~~~~~~~~~~~~~~~
CV_LOG_LEVEL_VERBOSE
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:196:40: error: 'LogLevel' has not been declared
const auto make_parsed_result = [](LogLevel lev) -> std::pair<LogLevel, bool>
^~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:196:67: error: 'LogLevel' was not declared in this scope
const auto make_parsed_result = [](LogLevel lev) -> std::pair<LogLevel, bool>
^~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:196:67: note: suggested alternative: 'parseLogLevel'
const auto make_parsed_result = [](LogLevel lev) -> std::pair<LogLevel, bool>
^~~~~~~~
parseLogLevel
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:196:81: error: template argument 1 is invalid
const auto make_parsed_result = [](LogLevel lev) -> std::pair<LogLevel, bool>
^
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp: In lambda function:
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:198:40: error: cannot convert 'std::pair<int, bool>' to 'int' in return
return std::make_pair(lev, true);
^
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp: In static member function 'static int cv::utils::logging::LogTagConfigParser::parseLogLevel(const string&)':
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:209:43: error: 'LOG_LEVEL_SILENT' was not declared in this scope
return make_parsed_result(LOG_LEVEL_SILENT);
^~~~~~~~~~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:209:43: note: suggested alternative: 'CV_LOG_LEVEL_SILENT'
return make_parsed_result(LOG_LEVEL_SILENT);
^~~~~~~~~~~~~~~~
CV_LOG_LEVEL_SILENT
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:216:43: error: 'LOG_LEVEL_DEBUG' was not declared in this scope
return make_parsed_result(LOG_LEVEL_DEBUG);
^~~~~~~~~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:216:43: note: suggested alternative: 'CV_LOG_LEVEL_DEBUG'
return make_parsed_result(LOG_LEVEL_DEBUG);
^~~~~~~~~~~~~~~
CV_LOG_LEVEL_DEBUG
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:221:43: error: 'LOG_LEVEL_SILENT' was not declared in this scope
return make_parsed_result(LOG_LEVEL_SILENT);
^~~~~~~~~~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:221:43: note: suggested alternative: 'CV_LOG_LEVEL_SILENT'
return make_parsed_result(LOG_LEVEL_SILENT);
^~~~~~~~~~~~~~~~
CV_LOG_LEVEL_SILENT
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:228:43: error: 'LOG_LEVEL_ERROR' was not declared in this scope
return make_parsed_result(LOG_LEVEL_ERROR);
^~~~~~~~~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:228:43: note: suggested alternative: 'CV_LOG_LEVEL_ERROR'
return make_parsed_result(LOG_LEVEL_ERROR);
^~~~~~~~~~~~~~~
CV_LOG_LEVEL_ERROR
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:235:43: error: 'LOG_LEVEL_FATAL' was not declared in this scope
return make_parsed_result(LOG_LEVEL_FATAL);
^~~~~~~~~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:235:43: note: suggested alternative: 'CV_LOG_LEVEL_FATAL'
return make_parsed_result(LOG_LEVEL_FATAL);
^~~~~~~~~~~~~~~
CV_LOG_LEVEL_FATAL
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:242:43: error: 'LOG_LEVEL_INFO' was not declared in this scope
return make_parsed_result(LOG_LEVEL_INFO);
^~~~~~~~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:242:43: note: suggested alternative: 'CV_LOG_LEVEL_INFO'
return make_parsed_result(LOG_LEVEL_INFO);
^~~~~~~~~~~~~~
CV_LOG_LEVEL_INFO
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:248:43: error: 'LOG_LEVEL_SILENT' was not declared in this scope
return make_parsed_result(LOG_LEVEL_SILENT);
^~~~~~~~~~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:248:43: note: suggested alternative: 'CV_LOG_LEVEL_SILENT'
return make_parsed_result(LOG_LEVEL_SILENT);
^~~~~~~~~~~~~~~~
CV_LOG_LEVEL_SILENT
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:255:43: error: 'LOG_LEVEL_SILENT' was not declared in this scope
return make_parsed_result(LOG_LEVEL_SILENT);
^~~~~~~~~~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:255:43: note: suggested alternative: 'CV_LOG_LEVEL_SILENT'
return make_parsed_result(LOG_LEVEL_SILENT);
^~~~~~~~~~~~~~~~
CV_LOG_LEVEL_SILENT
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:271:43: error: 'LOG_LEVEL_WARNING' was not declared in this scope
return make_parsed_result(LOG_LEVEL_WARNING);
^~~~~~~~~~~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:271:43: note: suggested alternative: 'CV_LOG_LEVEL_WARN'
return make_parsed_result(LOG_LEVEL_WARNING);
^~~~~~~~~~~~~~~~~
CV_LOG_LEVEL_WARN
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp: At global scope:
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:282:42: error: 'std::__cxx11::string cv::utils::logging::LogTagConfigParser::toString' is not a static data member of 'class cv::utils::logging::LogTagConfigParser'
std::string LogTagConfigParser::toString(LogLevel level)
^~~~~~~~
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:282:42: error: 'LogLevel' was not declared in this scope
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:282:42: note: suggested alternative: 'parseLogLevel'
std::string LogTagConfigParser::toString(LogLevel level)
^~~~~~~~
parseLogLevel
C:\opencv\sources\modules\core\src\utils\logtagconfigparser.cpp:283:1: error: expected ',' or ';' before '{' token
{
^
mingw32-make[2]: *** [modules\core\CMakeFiles\opencv_core.dir\build.make:1258: modules/core/CMakeFiles/opencv_core.dir/src/utils/logtagconfigparser.cpp.obj] Error 1
mingw32-make[1]: *** [CMakeFiles\Makefile2:2318: modules/core/CMakeFiles/opencv_core.dir/all] Error 2
mingw32-make: *** [Makefile:182: all] Error 2
Please how do i solve this, and what is LogLevel?.
At first i was using Mingw then i ran into a "mutex" issue.So i changed to Mingw64 to solve it, the I arrived at this problem. Is there a library I'm missing cause I havent found what LogLevel is.
I am trying to write a parallel version of wc. I am using TBB library, but unfortunately something is going wrong, and I don't know how to fix the errors.
My code
#include<string>
#include<iostream>
#include<fstream>
#include<sstream>
#include<algorithm>
#include<boost/lambda/lambda.hpp>
#include"include/tbb/pipeline.h"
using namespace std;
class Counter
{
private:
public:
unsigned int operator()(std::string const& str){
std::stringstream stream(str);
return std::distance(std::istream_iterator<std::string>(stream), std::istream_iterator<std::string>());
} ;
};
class Reader
{
private:
std::fstream m_file;
string m_line;
public:
Reader(string &path):
m_line(""){
fstream file(path.c_str(), fstream::in);
};
std::string operator()(tbb::flow_control& fc){
if(m_file.eof()){
fc.stop();
m_file.close();
return m_line;
}
getline(m_file,m_line);
return m_line;
}
};
int main(int argc, const char* argv[] ){
unsigned int sum=0;
if(argc!= 3){
cout<<"podaj sciezke!"<<endl;
}else{
string path(argv[1]);
tbb::parallel_pipeline( /*max_number_of_live_token=*/16,
tbb::make_filter<void,string>(tbb::filter::serial_in_order, Reader(path))&
tbb::make_filter<string,unsigned int>(tbb::filter::parallel, Counter())&
tbb::make_filter<unsigned int,void>(tbb::filter::serial_in_order, [&](unsigned int x) {sum+=x;})
);
std::cout<<"word count "<<sum <<endl;
}
return 0;
}`
and compiler output
g
++ -std=gnu++0x my_wc.cpp -o program -Xlinker -rpath -Xlinker lib/ia32/gcc4.4/ -L lib/ia32/gcc4.4/ -ltbb
In file included from my_wc.cpp:7:0:
include/tbb/pipeline.h: In constructor ‘tbb::interface6::internal::filter_node_leaf<T, U, Body>::filter_node_leaf(tbb::filter::mode, const Body&) [with T = void, U = std::basic_string<char>, Body = Reader]’:
include/tbb/pipeline.h:583:63: instantiated from ‘tbb::interface6::filter_t<T, U> tbb::interface6::make_filter(tbb::filter::mode, const Body&) [with T = void, U = std::basic_string<char>, Body = Reader]’
my_wc.cpp:49:80: instantiated from here
include/tbb/pipeline.h:554:77: error: use of deleted function ‘Reader::Reader(const Reader&)’
my_wc.cpp:20:7: error: ‘Reader::Reader(const Reader&)’ is implicitly deleted because the default definition would be ill-formed:
my_wc.cpp:20:7: error: use of deleted function ‘std::basic_fstream<char>::basic_fstream(const std::basic_fstream<char>&)’
In file included from my_wc.cpp:3:0:
/usr/include/c++/4.6/fstream:761:11: error: ‘std::basic_fstream<char>::basic_fstream(const std::basic_fstream<char>&)’ is implicitly deleted because the default definition would be ill-formed:
/usr/include/c++/4.6/fstream:761:11: error: use of deleted function ‘std::basic_iostream<char>::basic_iostream(const std::basic_iostream<char>&)’
In file included from /usr/include/c++/4.6/iostream:41:0,
from my_wc.cpp:2:
/usr/include/c++/4.6/istream:774:11: error: ‘std::basic_iostream<char>::basic_iostream(const std::basic_iostream<char>&)’ is implicitly deleted because the default definition would be ill-formed:
/usr/include/c++/4.6/istream:774:11: error: use of deleted function ‘std::basic_istream<char>::basic_istream(const std::basic_istream<char>&)’
/usr/include/c++/4.6/istream:57:11: error: ‘std::basic_istream<char>::basic_istream(const std::basic_istream<char>&)’ is implicitly deleted because the default definition would be ill-formed:
/usr/include/c++/4.6/istream:57:11: error: use of deleted function ‘std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)’
In file included from /usr/include/c++/4.6/ios:45:0,
from /usr/include/c++/4.6/ostream:40,
from /usr/include/c++/4.6/iostream:40,
from my_wc.cpp:2:
/usr/include/c++/4.6/bits/basic_ios.h:64:11: error: ‘std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)’ is implicitly deleted because the default definition would be ill-formed:
/usr/include/c++/4.6/bits/ios_base.h:788:5: error: ‘std::ios_base::ios_base(const std::ios_base&)’ is private
/usr/include/c++/4.6/bits/basic_ios.h:64:11: error: within this context
In file included from /usr/include/c++/4.6/iostream:41:0,
from my_wc.cpp:2:
/usr/include/c++/4.6/istream:57:11: error: use of deleted function ‘std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)’
/usr/include/c++/4.6/istream:774:11: error: use of deleted function ‘std::basic_ostream<char>::basic_ostream(const std::basic_ostream<char>&)’
In file included from /usr/include/c++/4.6/iostream:40:0,
from my_wc.cpp:2:
/usr/include/c++/4.6/ostream:57:11: error: ‘std::basic_ostream<char>::basic_ostream(const std::basic_ostream<char>&)’ is implicitly deleted because the default definition would be ill-formed:
/usr/include/c++/4.6/ostream:57:11: error: use of deleted function ‘std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)’
/usr/include/c++/4.6/ostream:57:11: error: use of deleted function ‘std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)’
In file included from /usr/include/c++/4.6/iostream:41:0,
from my_wc.cpp:2:
/usr/include/c++/4.6/istream:774:11: error: use of deleted function ‘std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)’
In file included from my_wc.cpp:3:0:
/usr/include/c++/4.6/fstream:761:11: error: use of deleted function ‘std::basic_ios<char>::basic_ios(const std::basic_ios<char>&)’
/usr/include/c++/4.6/fstream:761:11: error: use of deleted function ‘std::basic_filebuf<char>::basic_filebuf(const std::basic_filebuf<char>&)’
/usr/include/c++/4.6/fstream:69:11: error: ‘std::basic_filebuf<char>::basic_filebuf(const std::basic_filebuf<char>&)’ is implicitly deleted because the default definition would be ill-formed:
/usr/include/c++/4.6/streambuf:782:7: error: ‘std::basic_streambuf<_CharT, _Traits>::basic_streambuf(const __streambuf_type&) [with _CharT = char, _Traits = std::char_traits<char>, std::basic_streambuf<_CharT, _Traits>::__streambuf_type = std::basic_streambuf<char>]’ is private
/usr/include/c++/4.6/fstream:69:11: error: within this context
In file included from my_wc.cpp:7:0:
include/tbb/pipeline.h: In member function ‘void* tbb::interface6::internal::concrete_filter<void, U, Body>::operator()(void*) [with U = std::basic_string<char>, Body = Reader]’:
my_wc.cpp:56:1: instantiated from here
include/tbb/pipeline.h:449:69: error: passing ‘const Reader’ as ‘this’ argument of ‘std::string Reader::operator()(tbb::interface6::flow_control&)’ discards qualifiers [-fpermissive]
include/tbb/pipeline.h: In member function ‘void* tbb::interface6::internal::concrete_filter<T, U, Body>::operator()(void*) [with T = std::basic_string<char>, U = unsigned int, Body = Counter]’:
my_wc.cpp:56:1: instantiated from here
include/tbb/pipeline.h:426:89: error: passing ‘const Counter’ as ‘this’ argument of ‘unsigned int Counter::operator()(const string&)’ discards qualifiers [-fpermissive]
Especially the line
Reader::Reader(const Reader&)’ is implicitly deleted because the default definition would be ill-formed:
is very strange.
This is my first multi thread task, so please give me some advice how can I fix my source code.
The error stems from the fact that tbb::make_filter is attempting to make a copy of the Reader object you pass it. Reader is non-copyable because it holds an std::fstream data member, which is non-copyable. You need to redesign Reader such that it does not hold an std::fstream, or pass an std::reference_wrapper<Reader>.
I can't get my C++ program to compile. As you can see, I'm writing a Node.js addon. Here is the code (Eamorr_addon.cpp):
#include <iostream>
#include <v8.h>
#include <node.h>
#include <gmp.h>
#include "Definitions.h"
#include "Rk.h"
#include "tbb/concurrent_hash_map.h"
//#include <tbb/concurrent_vector.h>
using namespace std;
using namespace v8;
static Handle<Value> Echo(const Arguments& args) {
HandleScope scope;
if (args.Length() < 1) {
return ThrowException(Exception::TypeError(String::New("Bad argument")));
}
return scope.Close(args[0]);
}
extern "C" void init (Handle<Object> target)
{
HandleScope scope;
target->Set(String::New("hello"), String::New("world"));
NODE_SET_METHOD(target, "echo", Echo);
}
Everything works just fine when I remove the line #include "tbb/concurrent_hash_map.h".
Here is my gyp make file:
{
'targets': [
{
'target_name':'Eamorr_addon',
'sources':['src/Eamorr_addon.cpp'],
'include_dirs': ['/usr/include','/usr/local/include/'],
'cflags': ['-Wall','-fopenmp'],
'ldflags': ['-ltbb','-lgmp']
}
]
}
When I do node-gyp build, I get the following stream of errors which I can't get to the bottom of:
node-gyp build
info it worked if it ends with ok
spawn make [ 'BUILDTYPE=Release', '-f', 'Makefile.gyp' ]
CXX(target) out/Release/obj.target/DeDuplicator_addon/src/DeDuplicator_addon.o
In file included from /usr/include/tbb/concurrent_hash_map.h:51:0,
from src/DeDuplicator_addon.cpp:17:
/usr/include/tbb/atomic.h:218:31: error: expected nested-name-specifier before numeric constant
/usr/include/tbb/atomic.h:218:31: error: expected ‘>’ before numeric constant
/usr/include/tbb/atomic.h:224:33: error: expected ‘)’ before ‘addend’
/usr/include/tbb/atomic.h:224:40: error: ISO C++ forbids initialization of member ‘fetch_and_add’
/usr/include/tbb/atomic.h:224:40: error: making ‘fetch_and_add’ static
/usr/include/tbb/atomic.h:224:40: error: template declaration of ‘value_type tbb::internal::fetch_and_add’
In file included from /usr/include/tbb/concurrent_hash_map.h:51:0,
from src/DeDuplicator_addon.cpp:17:
/usr/include/tbb/atomic.h:228:31: error: expected identifier before numeric constant
/usr/include/tbb/atomic.h:228:31: error: expected ‘,’ or ‘...’ before numeric constant
/usr/include/tbb/atomic.h:251:28: error: expected identifier before numeric constant
/usr/include/tbb/atomic.h:251:28: error: expected ‘,’ or ‘...’ before numeric constant
/usr/include/tbb/atomic.h:255:28: error: expected identifier before numeric constant
/usr/include/tbb/atomic.h:255:28: error: expected ‘,’ or ‘...’ before numeric constant
/usr/include/tbb/atomic.h: In member function ‘value_type tbb::internal::atomic_impl_with_arithmetic<I, <anonymous> >::fetch_and_add(int)’:
/usr/include/tbb/atomic.h:229:48: error: ‘addend’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘value_type tbb::internal::atomic_impl_with_arithmetic<I, <anonymous> >::fetch_and_decrement()’:
/usr/include/tbb/atomic.h:243:33: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h:243:33: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h:243:33: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h: In member function ‘value_type tbb::internal::atomic_impl_with_arithmetic<I, <anonymous> >::fetch_and_decrement()’:
/usr/include/tbb/atomic.h:247:30: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h:247:30: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h:247:30: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h: In member function ‘value_type tbb::internal::atomic_impl_with_arithmetic<I, <anonymous> >::operator+=(int)’:
/usr/include/tbb/atomic.h:252:30: error: ‘addend’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘value_type tbb::internal::atomic_impl_with_arithmetic<I, <anonymous> >::operator-=(int)’:
/usr/include/tbb/atomic.h:258:30: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h:258:32: error: ‘addend’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘value_type tbb::internal::atomic_impl_with_arithmetic<I, <anonymous> >::operator--()’:
/usr/include/tbb/atomic.h:266:30: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h:266:30: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h:266:30: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h: In member function ‘value_type tbb::internal::atomic_impl_with_arithmetic<I, <anonymous> >::operator--(int)’:
/usr/include/tbb/atomic.h:274:30: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h:274:30: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h:274:30: error: ‘2’ cannot be used as a function
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:329:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘long long int tbb::atomic<long long int>::operator=(long long int)’:
/usr/include/tbb/atomic.h:329:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<long long int>& tbb::atomic<long long int>::operator=(const tbb::atomic<long long int>&)’:
/usr/include/tbb/atomic.h:329:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:330:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘long long unsigned int tbb::atomic<long long unsigned int>::operator=(long long unsigned int)’:
/usr/include/tbb/atomic.h:330:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<long long unsigned int>& tbb::atomic<long long unsigned int>::operator=(const tbb::atomic<long long unsigned int>&)’:
/usr/include/tbb/atomic.h:330:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:335:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘long int tbb::atomic<long int>::operator=(long int)’:
/usr/include/tbb/atomic.h:335:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<long int>& tbb::atomic<long int>::operator=(const tbb::atomic<long int>&)’:
/usr/include/tbb/atomic.h:335:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:336:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘long unsigned int tbb::atomic<long unsigned int>::operator=(long unsigned int)’:
/usr/include/tbb/atomic.h:336:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<long unsigned int>& tbb::atomic<long unsigned int>::operator=(const tbb::atomic<long unsigned int>&)’:
/usr/include/tbb/atomic.h:336:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:352:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘unsigned int tbb::atomic<unsigned int>::operator=(unsigned int)’:
/usr/include/tbb/atomic.h:352:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<unsigned int>& tbb::atomic<unsigned int>::operator=(const tbb::atomic<unsigned int>&)’:
/usr/include/tbb/atomic.h:352:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:353:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘int tbb::atomic<int>::operator=(int)’:
/usr/include/tbb/atomic.h:353:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<int>& tbb::atomic<int>::operator=(const tbb::atomic<int>&)’:
/usr/include/tbb/atomic.h:353:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:356:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘short unsigned int tbb::atomic<short unsigned int>::operator=(short unsigned int)’:
/usr/include/tbb/atomic.h:356:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<short unsigned int>& tbb::atomic<short unsigned int>::operator=(const tbb::atomic<short unsigned int>&)’:
/usr/include/tbb/atomic.h:356:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:357:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘short int tbb::atomic<short int>::operator=(short int)’:
/usr/include/tbb/atomic.h:357:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<short int>& tbb::atomic<short int>::operator=(const tbb::atomic<short int>&)’:
/usr/include/tbb/atomic.h:357:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:358:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘char tbb::atomic<char>::operator=(char)’:
/usr/include/tbb/atomic.h:358:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<char>& tbb::atomic<char>::operator=(const tbb::atomic<char>&)’:
/usr/include/tbb/atomic.h:358:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:359:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘signed char tbb::atomic<signed char>::operator=(signed char)’:
/usr/include/tbb/atomic.h:359:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<signed char>& tbb::atomic<signed char>::operator=(const tbb::atomic<signed char>&)’:
/usr/include/tbb/atomic.h:359:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:360:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘unsigned char tbb::atomic<unsigned char>::operator=(unsigned char)’:
/usr/include/tbb/atomic.h:360:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<unsigned char>& tbb::atomic<unsigned char>::operator=(const tbb::atomic<unsigned char>&)’:
/usr/include/tbb/atomic.h:360:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:363:1: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
/usr/include/tbb/atomic.h: In member function ‘wchar_t tbb::atomic<wchar_t>::operator=(wchar_t)’:
/usr/include/tbb/atomic.h:363:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: In member function ‘tbb::atomic<wchar_t>& tbb::atomic<wchar_t>::operator=(const tbb::atomic<wchar_t>&)’:
/usr/include/tbb/atomic.h:363:1: error: ‘store_with_release’ was not declared in this scope
/usr/include/tbb/atomic.h: At global scope:
/usr/include/tbb/atomic.h:367:93: error: wrong number of template arguments (3, should be 2)
/usr/include/tbb/atomic.h:219:8: error: provided for ‘template<class I, int <anonymous> > struct tbb::internal::atomic_impl_with_arithmetic’
In file included from src/DeDuplicator_addon.cpp:17:0:
/usr/include/tbb/concurrent_hash_map.h: In member function ‘bool tbb::interface4::internal::hash_map_base::check_mask_race(tbb::interface4::internal::hash_map_base::hashcode_t, tbb::interface4::internal::hash_map_base::hashcode_t&) const’:
/usr/include/tbb/concurrent_hash_map.h:266:21: error: cannot convert ‘const tbb::atomic<long unsigned int>’ to ‘tbb::interface4::internal::hash_map_base::hashcode_t’ in assignment
/usr/include/tbb/concurrent_hash_map.h: In member function ‘tbb::interface4::internal::hash_map_base::segment_index_t tbb::interface4::internal::hash_map_base::insert_new_node(tbb::interface4::internal::hash_map_base::bucket*, tbb::interface4::internal::hash_map_base::node_base*, tbb::interface4::internal::hash_map_base::hashcode_t)’:
/usr/include/tbb/concurrent_hash_map.h:296:30: error: no match for ‘operator++’ in ‘++((tbb::interface4::internal::hash_map_base*)this)->tbb::interface4::internal::hash_map_base::my_size’
/usr/include/tbb/concurrent_hash_map.h: In member function ‘void tbb::interface4::internal::hash_map_base::reserve(tbb::interface4::internal::hash_map_base::size_type)’:
/usr/include/tbb/concurrent_hash_map.h:316:32: error: no match for ‘operator!’ in ‘!((tbb::interface4::internal::hash_map_base*)this)->tbb::interface4::internal::hash_map_base::my_size’
/usr/include/tbb/concurrent_hash_map.h:316:32: note: candidate is: operator!(bool) <built-in>
/usr/include/tbb/concurrent_hash_map.h:317:32: error: cannot convert ‘tbb::atomic<long unsigned int>’ to ‘tbb::interface4::internal::hash_map_base::size_type’ in initialization
/usr/include/tbb/concurrent_hash_map.h:317:58: error: cannot convert ‘tbb::atomic<long unsigned int>’ to ‘tbb::interface4::internal::hash_map_base::size_type’ in assignment
/usr/include/tbb/concurrent_hash_map.h: In member function ‘bool tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>::empty() const’:
/usr/include/tbb/concurrent_hash_map.h:833:44: error: no match for ‘operator==’ in ‘((const tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>*)this)->tbb::interface4::internal::hash_map_base::my_size == 0’
/usr/include/tbb/concurrent_hash_map.h: In member function ‘tbb::interface4::concurrent_hash_map::size_type tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>::bucket_count() const’:
/usr/include/tbb/concurrent_hash_map.h:839:53: error: no match for ‘operator+’ in ‘((const tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>*)this)->tbb::interface4::internal::hash_map_base::my_mask + 1’
/usr/include/tbb/concurrent_hash_map.h: In member function ‘bool tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>::exclude(tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>::const_accessor&, bool)’:
/usr/include/tbb/concurrent_hash_map.h:1119:16: error: no ‘operator--(int)’ declared for postfix ‘--’
/usr/include/tbb/concurrent_hash_map.h: In member function ‘bool tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>::erase(const Key&)’:
/usr/include/tbb/concurrent_hash_map.h:1160:16: error: no ‘operator--(int)’ declared for postfix ‘--’
/usr/include/tbb/concurrent_hash_map.h: In member function ‘void tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>::internal_copy(const tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>&)’:
/usr/include/tbb/concurrent_hash_map.h:1310:20: error: no match for ‘operator==’ in ‘((tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>*)this)->tbb::interface4::internal::hash_map_base::my_mask == mask’
/usr/include/tbb/concurrent_hash_map.h:1323:19: error: no match for ‘operator++’ in ‘++((tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>*)this)->tbb::interface4::internal::hash_map_base::my_size’
/usr/include/tbb/concurrent_hash_map.h: In member function ‘void tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>::internal_copy(I, I)’:
/usr/include/tbb/concurrent_hash_map.h:1340:11: error: no match for ‘operator++’ in ‘++((tbb::interface4::concurrent_hash_map<Key, T, HashCompare, A>*)this)->tbb::interface4::internal::hash_map_base::my_size’
make: *** [out/Release/obj.target/DeDuplicator_addon/src/DeDuplicator_addon.o] Error 1
ERR! Error: `make` failed with exit code: 2
at Array.0 (/usr/local/lib/node_modules/node-gyp/lib/build.js:118:25)
at EventEmitter._tickCallback (node.js:192:40)
ERR! not ok
Can anyone suggest anything?
Edit:
Here is "Rk.h":
#ifndef RK_H_
#define RK_H_
#include <gmp.h>
#include "Definitions.h"
unsigned long int init_rkHash(char* str);
unsigned long int get_rkHash(unsigned long int prevHash,int prevAscii,int topAscii);
/*unsigned long int getFirstPrevHash(char* &buffer);*/
#endif /* RK_H_ */
and here is "Definitions.h":
#ifndef DEFINITIONS_H_
#define DEFINITIONS_H_
#define PORT 10002
#define CHUNKSIZE 512
#define PRIME 9223372036854775783
#define D 2
#endif /* DEFINITIONS_H_ */
#define macros are easy to use wrong. And giving them names like D calls for problems.
You defined D as
#define D 2
Now, if we look at atomic.h, we find e.g.
...
template<typename I, typename D, typename StepType>
struct atomic_impl_with_arithmetic: atomic_impl<I> {
...
value_type fetch_and_add( D addend ) {
...
template<memory_semantics M>
value_type fetch_and_decrement() {
return fetch_and_add<M>(__TBB_MINUS_ONE(D));
}
...
See the correlation?
What you get is:
...
template<typename I, typename 2, typename StepType>
struct atomic_impl_with_arithmetic: atomic_impl<I> {
...
value_type fetch_and_add( 2 addend ) {
...
template<memory_semantics M>
value_type fetch_and_decrement() {
return fetch_and_add<M>(__TBB_MINUS_ONE(2));
}
...
This is not valid C++.
Solution: Don't give macros a name that will probably clash. Rule of thumb: Every neat name clashes at least once in a lifetime and produce subtle and unreal error messages that might infect a poor maintainers (you?) nightly dreams with visions of indescribable demons. Therefore, only use macros if you absolutely must.
If D is supposed to be an integer (but who, except you, knows by that name?), you can do one of the following:
enum { D = 2 };
or
extern const int D; // in a header
const int D = 2; // in exactly one source file
or you may rethink your decision whether D needs to be constant at all and instead pass it as a parameter to your functions and classes.
Here is an excerpt from tbb/atomic.h
template<typename I, typename D, typename StepType>
struct atomic_impl_with_arithmetic: atomic_impl<I> {
public:
typedef I value_type;
template<memory_semantics M>
value_type fetch_and_add( D addend ) {
return value_type(internal::atomic_traits<sizeof(value_type),M>::fetch_and_add( &this->rep.value, addend*sizeof(StepType) ));
}
...
Now, if you substitute definition for D from Definitions.h you'll see what the issue is. In general it's a bad idea to make macro definitions with such names. If you've got too much code dependent on D you can fix the issue by undefining it befor including tbb headers, something like this:
#include "Definitions.h"
#include "Rk.h"
#pragma push_macro("D")
#undef D
#include "tbb/concurrent_hash_map.h"
#include <tbb/concurrent_vector.h>
#pragma pop_macro("D")
Tried google and searched here, but no luck.
I am trying to port some windows codes that use to Linux.
Then I get a huge amount of compilation errors.
All I did was
#include <emmintrin.h>
And then :
g++ -c -pipe -march=i686 -mtune=generic -O2 -pipe -D_REENTRANT -w -D__SSE__ -D__SSE2__ -D__MMX__ -I/usr/share/qt/mkspecs/linux-g++ -I. -o .obj/Test.o Test.cpp
In file included from /usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/xmmintrin.h:36:0,
from /usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/emmintrin.h:36,
from Test.cpp:33:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘void _mm_empty()’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:49:24: error: ‘__builtin_ia32_emms’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_cvtsi32_si64(int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:62:54: error: ‘__builtin_ia32_vec_init_v2si’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘int _mm_cvtsi64_si32(__vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:105:53: error: ‘__builtin_ia32_vec_ext_v2si’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_packs_pi16(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:144:69: error: ‘__builtin_ia32_packsswb’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_packs_pi32(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:159:69: error: ‘__builtin_ia32_packssdw’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_packs_pu16(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:174:69: error: ‘__builtin_ia32_packuswb’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_unpackhi_pi8(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:188:70: error: ‘__builtin_ia32_punpckhbw’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_unpackhi_pi16(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:202:70: error: ‘__builtin_ia32_punpckhwd’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_unpackhi_pi32(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:216:70: error: ‘__builtin_ia32_punpckhdq’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_unpacklo_pi8(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:230:70: error: ‘__builtin_ia32_punpcklbw’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_unpacklo_pi16(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:244:70: error: ‘__builtin_ia32_punpcklwd’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_unpacklo_pi32(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:258:70: error: ‘__builtin_ia32_punpckldq’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_add_pi8(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:271:66: error: ‘__builtin_ia32_paddb’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_add_pi16(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:284:66: error: ‘__builtin_ia32_paddw’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_add_pi32(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:297:66: error: ‘__builtin_ia32_paddd’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_add_si64(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:311:66: error: ‘__builtin_ia32_paddq’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_adds_pi8(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:320:67: error: ‘__builtin_ia32_paddsb’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_adds_pi16(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:334:67: error: ‘__builtin_ia32_paddsw’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_adds_pu8(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:348:68: error: ‘__builtin_ia32_paddusb’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_adds_pu16(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:362:68: error: ‘__builtin_ia32_paddusw’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_sub_pi8(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:375:66: error: ‘__builtin_ia32_psubb’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_sub_pi16(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:388:66: error: ‘__builtin_ia32_psubw’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_sub_pi32(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:401:66: error: ‘__builtin_ia32_psubd’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_sub_si64(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:415:66: error: ‘__builtin_ia32_psubq’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_subs_pi8(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:424:67: error: ‘__builtin_ia32_psubsb’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_subs_pi16(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:438:67: error: ‘__builtin_ia32_psubsw’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_subs_pu8(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:452:68: error: ‘__builtin_ia32_psubusb’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_subs_pu16(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:466:68: error: ‘__builtin_ia32_psubusw’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_madd_pi16(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:481:68: error: ‘__builtin_ia32_pmaddwd’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_mulhi_pi16(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:495:67: error: ‘__builtin_ia32_pmulhw’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_mullo_pi16(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:509:67: error: ‘__builtin_ia32_pmullw’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_sll_pi16(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:522:68: error: ‘__builtin_ia32_psllw’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_slli_pi16(__vector(2) int, int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:534:61: error: ‘__builtin_ia32_psllwi’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_sll_pi32(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:547:68: error: ‘__builtin_ia32_pslld’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_slli_pi32(__vector(2) int, int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:559:61: error: ‘__builtin_ia32_pslldi’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_sll_si64(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:572:68: error: ‘__builtin_ia32_psllq’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_slli_si64(__vector(2) int, int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:584:61: error: ‘__builtin_ia32_psllqi’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_sra_pi16(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:597:68: error: ‘__builtin_ia32_psraw’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_srai_pi16(__vector(2) int, int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:609:61: error: ‘__builtin_ia32_psrawi’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_sra_pi32(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:622:68: error: ‘__builtin_ia32_psrad’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_srai_pi32(__vector(2) int, int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:634:61: error: ‘__builtin_ia32_psradi’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_srl_pi16(__vector(2) int, __vector(2) int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:647:68: error: ‘__builtin_ia32_psrlw’ was not declared in this scope
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h: In function ‘__vector(2) int _mm_srli_pi16(__vector(2) int, int)’:
/usr/lib/gcc/i686-pc-linux-gnu/4.5.2/include/mmintrin.h:659:61: error: ‘__builtin_ia32_psrlwi’ was not declared in this scope
Am I missing some compiler option here ? Or I need to include some other headers ?
I believe you need to allow SSE instructions using -msse.