Я не могу заставить мою программу на C ++ компилироваться.Как видите, я пишу аддон Node.js.Вот код (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);
}
Все прекрасно работает, когда я удаляю строку #include "tbb/concurrent_hash_map.h"
.
Вот мой файл make gyp:
{
'targets': [
{
'target_name':'Eamorr_addon',
'sources':['src/Eamorr_addon.cpp'],
'include_dirs': ['/usr/include','/usr/local/include/'],
'cflags': ['-Wall','-fopenmp'],
'ldflags': ['-ltbb','-lgmp']
}
]
}
Когда я делаю node-gyp build
, я получаю следующий поток ошибок, которые я не могу до конца понять:
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
Может кто-нибудь что-нибудь предложить?
Редактировать:
Вот "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_ */
, а вот "Definitions.h":
#ifndef DEFINITIONS_H_
#define DEFINITIONS_H_
#define PORT 10002
#define CHUNKSIZE 512
#define PRIME 9223372036854775783
#define D 2
#endif /* DEFINITIONS_H_ */