I am trying to modify a C++ program by including POCO to be able to do a HTTP request and receive a result. Basically, I just need within another C++ program to give a username and password and get a plain "OK" or "ERROR" response.
I am not familiar with C++ at all (use Java mainly). I build the POCO project and installed it without any problems, but when I add it to the project I get a while pile of compiler errors when building:
In file included from ../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:30:
In file included from /usr/local/include/Poco/Net/HTTPClientSession.h:44:
In file included from /usr/local/include/Poco/Net/HTTPSession.h:44:
In file included from /usr/local/include/Poco/Net/StreamSocket.h:44:
In file included from /usr/local/include/Poco/Net/Socket.h:44:
In file included from /usr/local/include/Poco/Net/SocketImpl.h:47:
In file included from /usr/local/include/Poco/Timespan.h:44:
/usr/local/include/Poco/Timestamp.h:50:1: error: declaration of anonymous class must be a definition
class Foundation_API Timestamp
^
/usr/local/include/Poco/Timestamp.h:149:24: error: expected identifier
inline bool Timestamp::operator == (const Timestamp& ts) const
^
/usr/local/include/Poco/Timestamp.h:149:13: error: declaration of anonymous struct must be a definition
inline bool Timestamp::operator == (const Timestamp& ts) const
^
../crtmpserver/sources/common/include/platform/osx/osxplatform.h:109:19: note: expanded from macro 'Timestamp'
#define Timestamp struct tm
^
In file included from ../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:30:
In file included from /usr/local/include/Poco/Net/HTTPClientSession.h:44:
In file included from /usr/local/include/Poco/Net/HTTPSession.h:44:
In file included from /usr/local/include/Poco/Net/StreamSocket.h:44:
In file included from /usr/local/include/Poco/Net/Socket.h:44:
In file included from /usr/local/include/Poco/Net/SocketImpl.h:47:
In file included from /usr/local/include/Poco/Timespan.h:44:
/usr/local/include/Poco/Timestamp.h:262:1: error: expected unqualified-id
} // namespace Poco
^
In file included from ../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:30:
In file included from /usr/local/include/Poco/Net/HTTPClientSession.h:44:
In file included from /usr/local/include/Poco/Net/HTTPSession.h:44:
In file included from /usr/local/include/Poco/Net/StreamSocket.h:44:
In file included from /usr/local/include/Poco/Net/Socket.h:44:
In file included from /usr/local/include/Poco/Net/SocketImpl.h:47:
/usr/local/include/Poco/Timespan.h:54:21: error: no struct named 'TimeDiff' in 'tm'
typedef Timestamp::TimeDiff TimeDiff;
~~~~~~~~~~~^
In file included from ../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:30:
In file included from /usr/local/include/Poco/Net/HTTPClientSession.h:44:
In file included from /usr/local/include/Poco/Net/HTTPSession.h:47:
/usr/local/include/Poco/Any.h:123:46: error: cannot use typeid with -fno-rtti
return _content ? _content->type() : typeid(void);
^
/usr/local/include/Poco/Any.h:149:20: error: cannot use typeid with -fno-rtti
return typeid(ValueType);
^
/usr/local/include/Poco/Any.h:180:42: error: cannot use typeid with -fno-rtti
return operand && operand->type() == typeid(ValueType)
^
In file included from ../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:30:
/usr/local/include/Poco/Net/HTTPClientSession.h:291:8: error: expected member name or ';' after declaration specifiers
Poco::Timestamp _lastRequest;
~~~~ ^
../crtmpserver/sources/common/include/platform/osx/osxplatform.h:109:19: note: expanded from macro 'Timestamp'
#define Timestamp struct tm
^
../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:94:10: error: expected expression
form.add(<D2>entry1<D3>, <D2>value1<D3>);
^
../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:97:25: error: variable has incomplete type 'Poco::Net::HTTPResponse'
Poco::Net::HTTPResponse response;
^
/usr/local/include/Poco/Net/HTTPClientSession.h:55:7: note: forward declaration of 'Poco::Net::HTTPResponse'
class HTTPResponse;
^
../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:99:41: error: no member named 'cout' in namespace 'std'; did you mean 'count'?
Poco::StreamCopier::copyStream(rs, std::cout);
~~~~~^~~~
count
/usr/include/c++/4.2.1/bits/stl_algo.h:424:5: note: 'count' declared here
count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
^
../crtmpserver/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp:99:36: error: address of overloaded function 'count' does not match required type 'std::basic_ostream<char>'
Poco::StreamCopier::copyStream(rs, std::cout);
^~~~~~~~~
/usr/include/c++/4.2.1/bits/stl_algo.h:424:5: note: candidate function
count(_InputIterator __first, _InputIterator __last, const _Tp& __value)
^
/usr/local/include/Poco/StreamCopier.h:57:73: note: passing argument to parameter 'ostr' here
static std::streamsize copyStream(std::istream& istr, std::ostream& ostr, std::size_t bufferSize = 8192);
^
13 errors generated.
make[2]: *** [applications/idomsconnector/CMakeFiles/idomsconnector.dir/Users/[...]/sources/applications/idomsconnector/src/rtmpappprotocolhandler.cpp.o] Error 1
make[1]: *** [applications/idomsconnector/CMakeFiles/idomsconnector.dir/all] Error 2
make: *** [all] Error 2
build failed
My code fragment is as follows:
#include <Poco/Net/HTTPRequest.h>
#include <Poco/Net/HTTPClientSession.h>
#include <Poco/Net/HTMLForm.h>
#include <Poco/StreamCopier.h>
string RTMPAppProtocolHandler::GetAuthPassword(string user) {
INFO("Testing auth: %s", STR(user));
Poco::Net::HTTPClientSession s("www.somehost.com");
//s.setProxy("localhost", srv.port());
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, "/large");
Poco::Net::HTMLForm form;
form.add(“entry1”, “value1”);
form.prepareSubmit(request);
s.sendRequest(request);
Poco::Net::HTTPResponse response;
std::istream& rs = s.receiveResponse(response);
Poco::StreamCopier::copyStream(rs, std::cout);
return user;
}
Am I doing something stupid? It is only this little interaction with a HTTP server which I need to modify, so I am just looking for a very simple solution but find it hard to find something that works easy (mainly because I am not familiar with C++ though)
Related
I have made the 'mistake' to update few things in my MacOS Monterey Intel-based and now I cannot source any cpp file as I used to do with Rcpp.
I tried to understand how others have resolved similar issues, but my problem seem to still remain.
Below you can find the error message, which perhaps may help to point me out to the possible solution:
In file included from file1851d7b0603f9.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/RcppCommon.h:30:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/r/headers.h:62:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/platform/compiler.h:100:
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:642:26: error: no template named 'numeric_limits'
bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:642:60: error: no template named 'numeric_limits'
bool _FloatBigger = (numeric_limits<_FloatT>::digits > numeric_limits<_IntT>::digits),
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:643:18: error: no template named 'numeric_limits'
int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:643:50: error: no template named 'numeric_limits'
int _Bits = (numeric_limits<_IntT>::digits - numeric_limits<_FloatT>::digits)>
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:648:17: error: no template named 'numeric_limits'
static_assert(numeric_limits<_FloatT>::radix == 2, "FloatT has incorrect radix");
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:651:25: error: no template named 'numeric_limits'
return _FloatBigger ? numeric_limits<_IntT>::max() : (numeric_limits<_IntT>::max() >> _Bits << _Bits);
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:651:58: error: no template named 'numeric_limits'
return _FloatBigger ? numeric_limits<_IntT>::max() : (numeric_limits<_IntT>::max() >> _Bits << _Bits);
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:661:16: error: no template named 'numeric_limits'
using _Lim = numeric_limits<_IntT>;
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:664:12: error: use of undeclared identifier '_Lim'
return _Lim::max();
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:665:21: error: use of undeclared identifier '_Lim'
} else if (__r <= _Lim::lowest()) {
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:666:12: error: use of undeclared identifier '_Lim'
return _Lim::min();
^
In file included from file1851d7b0603f9.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/RcppCommon.h:30:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/r/headers.h:62:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp/platform/compiler.h:153:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/unordered_map:437:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/__hash_table:16:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/algorithm:653:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/functional:490:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/__algorithm/search.h:15:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/__iterator/iterator_traits.h:14:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/__iterator/incrementable_traits.h:14:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/concepts:134:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/__functional_base:22:
In file included from /usr/local/opt/llvm/bin/../include/c++/v1/exception:83:
/usr/local/opt/llvm/bin/../include/c++/v1/cstdlib:138:9: error: target of using declaration conflicts with declaration already in scope
using ::abs _LIBCPP_USING_IF_EXISTS;
^
/usr/local/include/stdlib.h:132:6: note: target of using declaration
int abs(int) __pure2;
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:338:1: note: conflicting declaration
using ::abs _LIBCPP_USING_IF_EXISTS;
^
In file included from file1851d7b0603f9.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/RcppCommon.h:65:
/usr/local/opt/llvm/bin/../include/c++/v1/complex:853:1: error: declaration conflicts with target of using declaration already in scope
abs(const complex<_Tp>& __c)
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:338:1: note: target of using declaration
using ::abs _LIBCPP_USING_IF_EXISTS;
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:338:9: note: using declaration
using ::abs _LIBCPP_USING_IF_EXISTS;
^
In file included from file1851d7b0603f9.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/RcppCommon.h:65:
/usr/local/opt/llvm/bin/../include/c++/v1/complex:910:16: error: reference to unresolved using declaration
return abs(__c.real());
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
using ::abs _LIBCPP_USING_IF_EXISTS;
^
In file included from file1851d7b0603f9.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/RcppCommon.h:65:
/usr/local/opt/llvm/bin/../include/c++/v1/complex:912:16: error: reference to unresolved using declaration
return abs(__c.imag());
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
using ::abs _LIBCPP_USING_IF_EXISTS;
^
In file included from file1851d7b0603f9.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/RcppCommon.h:65:
/usr/local/opt/llvm/bin/../include/c++/v1/complex:969:16: error: reference to unresolved using declaration
__re = abs(__re);
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
using ::abs _LIBCPP_USING_IF_EXISTS;
^
In file included from file1851d7b0603f9.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/RcppCommon.h:65:
/usr/local/opt/llvm/bin/../include/c++/v1/complex:1022:29: error: reference to unresolved using declaration
return complex<_Tp>(log(abs(__x)), arg(__x));
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
using ::abs _LIBCPP_USING_IF_EXISTS;
^
In file included from file1851d7b0603f9.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/RcppCommon.h:65:
/usr/local/opt/llvm/bin/../include/c++/v1/complex:1049:23: error: reference to unresolved using declaration
return polar(sqrt(abs(__x)), arg(__x) / _Tp(2));
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
using ::abs _LIBCPP_USING_IF_EXISTS;
^
In file included from file1851d7b0603f9.cpp:1:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/Rcpp.h:27:
In file included from /Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include/RcppCommon.h:65:
/usr/local/opt/llvm/bin/../include/c++/v1/complex:1174:33: error: reference to unresolved using declaration
return complex<_Tp>(abs(__x.real()), __x.imag());
^
/usr/local/opt/llvm/bin/../include/c++/v1/cmath:338:1: note: using declaration annotated with 'using_if_exists' here
using ::abs _LIBCPP_USING_IF_EXISTS;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [file1851d7b0603f9.o] Error 1
/usr/local/opt/llvm/bin/clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Library/Frameworks/R.framework/Versions/4.1/Resources/library/Rcpp/include" -I"/private/var/folders/pq/hxwd9my563q_qpy4rbrlgkmw0000gn/T/RtmpYPQ7or/sourceCpp-x86_64-apple-darwin17.0-1.0.8.3" -I/usr/local/include -fPIC -I/usr/local/opt/llvm/include -c file1851d7b0603f9.cpp -o file1851d7b0603f9.o
Error in sourceCpp(code = code, env = env, rebuild = rebuild, cacheDir = cacheDir, :
Error 1 occurred building shared library.
Hello and thank you for your help in advance (I'm a bit of a newbie). I am on ubuntu 18.
I am trying to install an older version of some software called HepMC (need older version for project) and I had no problem installing the slightly newer version. When I try to build from source I get an error on the make command. I've seen this "all-recurive failed" error all over the web, but the solutions I've seen for other people have seemed to be very software specific and have not helped me.
I am not really sure how to interpret this error and I haven't been able to find a good answer. Any tips or suspicions on what might be going on here would be greatly appreciated. Been bashing my head against this for awhile
Before running make I did
autoreconf -i configure.ac
./configure
and this ran with no errors or warnings.
Here's the snippet where the error seems to begin, I'll attach the full printout from "make" down below.
In file included from ../HepMC/CommonIO.h:15:0,
from CommonIO.cc:11:
../HepMC/GenEvent.h:408:80: error: template argument 3 is invalid
public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{
^
../HepMC/GenEvent.h:459:71: error: ‘ptrdiff_t’ was not declared in this scope
public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{
^~~~~~~~~
../HepMC/GenEvent.h:459:71: note: suggested alternatives:
In file included from /usr/include/c++/7/string:38:0,
from CommonIO.cc:8:
/usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:232:28: note: ‘std::ptrdiff_t’
typedef __PTRDIFF_TYPE__ ptrdiff_t;
^~~~~~~~~
/usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:232:28: note: ‘std::ptrdiff_t’
In file included from ../HepMC/CommonIO.h:15:0,
from CommonIO.cc:11:
../HepMC/GenEvent.h:459:80: error: template argument 3 is invalid
public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{
^
CommonIO.cc: In member function ‘HepMC::HeavyIon* HepMC::CommonIO::read_heavy_ion(std::istream*)’:
CommonIO.cc:318:9: warning: converting ‘false’ to pointer type ‘HepMC::HeavyIon*’ [-Wconversion-null]
return false;
^~~~~
CommonIO.cc:328:26: warning: converting ‘false’ to pointer type ‘HepMC::HeavyIon*’ [-Wconversion-null]
if( nh == 0 ) return false;
^~~~~
CommonIO.cc: In member function ‘HepMC::PdfInfo* HepMC::CommonIO::read_pdf_info(std::istream*)’:
CommonIO.cc:344:9: warning: converting ‘false’ to pointer type ‘HepMC::PdfInfo*’ [-Wconversion-null]
return false;
^~~~~
CommonIO.cc:356:27: warning: converting ‘false’ to pointer type ‘HepMC::PdfInfo*’ [-Wconversion-null]
if( id1 == 0 ) return false;
^~~~~
CommonIO.cc: In member function ‘HepMC::GenVertex* HepMC::CommonIO::read_vertex(std::istream*, HepMC::TempParticleMap&)’:
CommonIO.cc:374:9: warning: converting ‘false’ to pointer type ‘HepMC::GenVertex*’ [-Wconversion-null]
return false;
^~~~~
CommonIO.cc: In member function ‘HepMC::GenParticle* HepMC::CommonIO::read_particle(std::istream*, HepMC::TempParticleMap&)’:
CommonIO.cc:411:9: warning: converting ‘false’ to pointer type ‘HepMC::GenParticle*’ [-Wconversion-null]
return false;
^~~~~
Makefile:478: recipe for target 'CommonIO.lo' failed
make[1]: *** [CommonIO.lo] Error 1
make[1]: Leaving directory '/home/maxfieg/Desktop/FelixResearch/junk/hep_build2/HepMC2.04/src'
Makefile:397: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
and here's the full return of make
make
Making all in HepMC
make[1]: Entering directory '/home/maxfieg/Desktop/FelixResearch/junk/hep_build2/HepMC2.04/HepMC'
make all-am
make[2]: Entering directory '/home/maxfieg/Desktop/FelixResearch/junk/hep_build2/HepMC2.04/HepMC'
make[2]: Leaving directory '/home/maxfieg/Desktop/FelixResearch/junk/hep_build2/HepMC2.04/HepMC'
make[1]: Leaving directory '/home/maxfieg/Desktop/FelixResearch/junk/hep_build2/HepMC2.04/HepMC'
Making all in src
make[1]: Entering directory '/home/maxfieg/Desktop/FelixResearch/junk/hep_build2/HepMC2.04/src'
/bin/bash ../libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I. -I../HepMC -I.. -I.. -ansi -pedantic -Wall -g -O2 -MT CommonIO.lo -MD -MP -MF .deps/CommonIO.Tpo -c -o CommonIO.lo CommonIO.cc
libtool: compile: g++ -DHAVE_CONFIG_H -I. -I../HepMC -I.. -I.. -ansi -pedantic -Wall -g -O2 -MT CommonIO.lo -MD -MP -MF .deps/CommonIO.Tpo -c CommonIO.cc -fPIC -DPIC -o .libs/CommonIO.o
In file included from ../HepMC/GenEvent.h:123:0,
from ../HepMC/CommonIO.h:15,
from CommonIO.cc:11:
../HepMC/GenVertex.h:173:71: error: ‘ptrdiff_t’ was not declared in this scope
public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{
^~~~~~~~~
../HepMC/GenVertex.h:173:71: note: suggested alternatives:
In file included from /usr/include/c++/7/string:38:0,
from CommonIO.cc:8:
/usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:232:28: note: ‘std::ptrdiff_t’
typedef __PTRDIFF_TYPE__ ptrdiff_t;
^~~~~~~~~
/usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:232:28: note: ‘std::ptrdiff_t’
In file included from ../HepMC/GenEvent.h:123:0,
from ../HepMC/CommonIO.h:15,
from CommonIO.cc:11:
../HepMC/GenVertex.h:173:80: error: template argument 3 is invalid
public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{
^
../HepMC/GenVertex.h:237:69: error: ‘ptrdiff_t’ was not declared in this scope
public std::iterator<std::forward_iterator_tag,HepMC::GenVertex*,ptrdiff_t>{
^~~~~~~~~
../HepMC/GenVertex.h:237:69: note: suggested alternatives:
In file included from /usr/include/c++/7/string:38:0,
from CommonIO.cc:8:
/usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:232:28: note: ‘std::ptrdiff_t’
typedef __PTRDIFF_TYPE__ ptrdiff_t;
^~~~~~~~~
/usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:232:28: note: ‘std::ptrdiff_t’
In file included from ../HepMC/GenEvent.h:123:0,
from ../HepMC/CommonIO.h:15,
from CommonIO.cc:11:
../HepMC/GenVertex.h:237:78: error: template argument 3 is invalid
public std::iterator<std::forward_iterator_tag,HepMC::GenVertex*,ptrdiff_t>{
^
../HepMC/GenVertex.h:307:64: error: ‘ptrdiff_t’ was not declared in this scope
public std::iterator<std::forward_iterator_tag,GenParticle*,ptrdiff_t>{
^~~~~~~~~
../HepMC/GenVertex.h:307:64: note: suggested alternatives:
In file included from /usr/include/c++/7/string:38:0,
from CommonIO.cc:8:
/usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:232:28: note: ‘std::ptrdiff_t’
typedef __PTRDIFF_TYPE__ ptrdiff_t;
^~~~~~~~~
/usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:232:28: note: ‘std::ptrdiff_t’
In file included from ../HepMC/GenEvent.h:123:0,
from ../HepMC/CommonIO.h:15,
from CommonIO.cc:11:
../HepMC/GenVertex.h:307:73: error: template argument 3 is invalid
public std::iterator<std::forward_iterator_tag,GenParticle*,ptrdiff_t>{
^
In file included from ../HepMC/CommonIO.h:15:0,
from CommonIO.cc:11:
../HepMC/GenEvent.h:289:69: error: ‘ptrdiff_t’ was not declared in this scope
public std::iterator<std::forward_iterator_tag,HepMC::GenVertex*,ptrdiff_t>{
^~~~~~~~~
../HepMC/GenEvent.h:289:69: note: suggested alternatives:
In file included from /usr/include/c++/7/string:38:0,
from CommonIO.cc:8:
/usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:232:28: note: ‘std::ptrdiff_t’
typedef __PTRDIFF_TYPE__ ptrdiff_t;
^~~~~~~~~
/usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:232:28: note: ‘std::ptrdiff_t’
In file included from ../HepMC/CommonIO.h:15:0,
from CommonIO.cc:11:
../HepMC/GenEvent.h:289:78: error: template argument 3 is invalid
public std::iterator<std::forward_iterator_tag,HepMC::GenVertex*,ptrdiff_t>{
^
../HepMC/GenEvent.h:341:69: error: ‘ptrdiff_t’ was not declared in this scope
public std::iterator<std::forward_iterator_tag,HepMC::GenVertex*,ptrdiff_t>{
^~~~~~~~~
../HepMC/GenEvent.h:341:69: note: suggested alternatives:
In file included from /usr/include/c++/7/string:38:0,
from CommonIO.cc:8:
/usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:232:28: note: ‘std::ptrdiff_t’
typedef __PTRDIFF_TYPE__ ptrdiff_t;
^~~~~~~~~
/usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:232:28: note: ‘std::ptrdiff_t’
In file included from ../HepMC/CommonIO.h:15:0,
from CommonIO.cc:11:
../HepMC/GenEvent.h:341:78: error: template argument 3 is invalid
public std::iterator<std::forward_iterator_tag,HepMC::GenVertex*,ptrdiff_t>{
^
../HepMC/GenEvent.h:408:71: error: ‘ptrdiff_t’ was not declared in this scope
public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{
^~~~~~~~~
../HepMC/GenEvent.h:408:71: note: suggested alternatives:
In file included from /usr/include/c++/7/string:38:0,
from CommonIO.cc:8:
/usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:232:28: note: ‘std::ptrdiff_t’
typedef __PTRDIFF_TYPE__ ptrdiff_t;
^~~~~~~~~
/usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:232:28: note: ‘std::ptrdiff_t’
In file included from ../HepMC/CommonIO.h:15:0,
from CommonIO.cc:11:
../HepMC/GenEvent.h:408:80: error: template argument 3 is invalid
public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{
^
../HepMC/GenEvent.h:459:71: error: ‘ptrdiff_t’ was not declared in this scope
public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{
^~~~~~~~~
../HepMC/GenEvent.h:459:71: note: suggested alternatives:
In file included from /usr/include/c++/7/string:38:0,
from CommonIO.cc:8:
/usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:232:28: note: ‘std::ptrdiff_t’
typedef __PTRDIFF_TYPE__ ptrdiff_t;
^~~~~~~~~
/usr/include/x86_64-linux-gnu/c++/7/bits/c++config.h:232:28: note: ‘std::ptrdiff_t’
In file included from ../HepMC/CommonIO.h:15:0,
from CommonIO.cc:11:
../HepMC/GenEvent.h:459:80: error: template argument 3 is invalid
public std::iterator<std::forward_iterator_tag,HepMC::GenParticle*,ptrdiff_t>{
^
CommonIO.cc: In member function ‘HepMC::HeavyIon* HepMC::CommonIO::read_heavy_ion(std::istream*)’:
CommonIO.cc:318:9: warning: converting ‘false’ to pointer type ‘HepMC::HeavyIon*’ [-Wconversion-null]
return false;
^~~~~
CommonIO.cc:328:26: warning: converting ‘false’ to pointer type ‘HepMC::HeavyIon*’ [-Wconversion-null]
if( nh == 0 ) return false;
^~~~~
CommonIO.cc: In member function ‘HepMC::PdfInfo* HepMC::CommonIO::read_pdf_info(std::istream*)’:
CommonIO.cc:344:9: warning: converting ‘false’ to pointer type ‘HepMC::PdfInfo*’ [-Wconversion-null]
return false;
^~~~~
CommonIO.cc:356:27: warning: converting ‘false’ to pointer type ‘HepMC::PdfInfo*’ [-Wconversion-null]
if( id1 == 0 ) return false;
^~~~~
CommonIO.cc: In member function ‘HepMC::GenVertex* HepMC::CommonIO::read_vertex(std::istream*, HepMC::TempParticleMap&)’:
CommonIO.cc:374:9: warning: converting ‘false’ to pointer type ‘HepMC::GenVertex*’ [-Wconversion-null]
return false;
^~~~~
CommonIO.cc: In member function ‘HepMC::GenParticle* HepMC::CommonIO::read_particle(std::istream*, HepMC::TempParticleMap&)’:
CommonIO.cc:411:9: warning: converting ‘false’ to pointer type ‘HepMC::GenParticle*’ [-Wconversion-null]
return false;
^~~~~
Makefile:478: recipe for target 'CommonIO.lo' failed
make[1]: *** [CommonIO.lo] Error 1
make[1]: Leaving directory '/home/maxfieg/Desktop/FelixResearch/junk/hep_build2/HepMC2.04/src'
Makefile:397: recipe for target 'all-recursive' failed
make: *** [all-recursive] Error 1
I changed from using Dev-c++ to visual studio code. But it seems i can't compile the minGW because of this bug, i got this bug if i use sublime too. Please help me with this.
*sorry for my bad english
C:\MinGW\lib\gcc\mingw32\6.3.0\include\c++\locale.h:36:13: warning: #pragma system_header ignored outside include file
#pragma GCC system_header
^~~~~~~~~~~~~
In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\mingw32\bits\c++locale.h:41:0,
from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\localefwd.h:40,
from C:\MinGW\lib\gcc\mingw32\6.3.0\include\c++\locale.h:38:
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\clocale:53:11: error: '::lconv' has not been declared
using ::lconv;
^~~~~
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\clocale:54:11: error: '::setlocale' has not been declared
using ::setlocale;
^~~~~~~~~
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\clocale:55:11: error: '::localeconv' has not been declared
using ::localeconv;
^~~~~~~~~~
In file included from c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\bits\localefwd.h:40:0,
from C:\MinGW\lib\gcc\mingw32\6.3.0\include\c++\locale.h:38:
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\mingw32\bits\c++locale.h: In function 'int std::__convert_from_v(int* const&, char*, int, const char*, ...)':
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\mingw32\bits\c++locale.h:60:19: error: 'setlocale' is not a member of 'std'
char* __old = std::setlocale(LC_NUMERIC, 0);
^~~
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\mingw32\bits\c++locale.h:60:34: error: 'LC_NUMERIC' was not declared in this scope
char* __old = std::setlocale(LC_NUMERIC, 0);
^~~~~~~~~~
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\mingw32\bits\c++locale.h:67:2: error: 'setlocale' is not a member of 'std'
std::setlocale(LC_NUMERIC, "C");
^~~
c:\mingw\lib\gcc\mingw32\6.3.0\include\c++\mingw32\bits\c++locale.h:83:2: error: 'setlocale' is not a member of 'std'
std::setlocale(LC_NUMERIC, __sav);
^~~
System information
Have I written custom code: Custom project
OS Platform and Distribution: macOS Sierra (10.12.6)
TensorFlow installed from: Source
TensorFlow version: Git tagged at 1.3 and master at d27ed9c
Python version: Python 2.7.13 :: Anaconda 4.4.0
Bazel version: 0.5.3_1-homebrew
Protobuf version: 3.3.2-homebrew
CUDA/cuDNN version: N/A
GPU model and memory: N/A
Exact command to reproduce:
Problem description
I compiled TensorFlow source code for Python & C++ API bindings following the steps shown in http://www.blitzblit.com/2017/06/11/creating-tensorflow-c-headers-and-libraries/ (We have to take into account that this tutorial is not updated). After compiling the TF source code I include the TF library in the C++ project:
#include <tensorflow/core/public/session.h>
Finally, I compile the C++ project (Until here everything seems fine). Then, when I try to launch the C++ code I get the following message:
/Applications/CLion.app/Contents/bin/cmake/bin/cmake --build /Users/arcadillanzacarmona/Desktop/FaceSDK/ cmake-build-debug --target FaceSDK -- -j 2
[ 96%] Built target dlib
[ 96%] Building CXX object CMakeFiles/FaceSDK.dir/main.cpp.o
clang: warning: -lcurl: 'linker' input unused [-Wunused-command-line-argument]
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:328:33: error: expected a qualified name after 'typename'
template <typename It, typename VoidPtr> class RepeatedPtrOverPtrsIterator;
^
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:328:33: error: expected ',' or '>' in template-parameter-list
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:864:59: error: template argument for non-type template parameter must be an expression
typedef internal::RepeatedPtrOverPtrsIterator<Element*, void*>
^~~~~
/usr/local/include/google/protobuf/repeated_field.h:328:33: note: template parameter is declared here
template <typename It, typename VoidPtr> class RepeatedPtrOverPtrsIterator;
^
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:867:55: error: template argument for non-type template parameter must be an expression
const void* const>
^~~~~
/usr/local/include/google/protobuf/repeated_field.h:328:33: note: template parameter is declared here
template <typename It, typename VoidPtr> class RepeatedPtrOverPtrsIterator;
^
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:2258:38: error: expected a qualified name after 'typename'
template <typename Element, typename VoidPtr>
^
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:2258:38: error: expected ',' or '>' in template-parameter-list
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:2262:48: error: template argument for non-type template parameter must be an expression
typedef RepeatedPtrOverPtrsIterator<Element, VoidPtr> iterator;
^~~~~~~
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^~~~~~
/usr/local/include/google/protobuf/repeated_field.h:2258:38: note: template parameter is declared here
template <typename Element, typename VoidPtr>
^
/opt/local/include/gif_lib.h:286:17: note: expanded from macro 'VoidPtr'
#define VoidPtr void *
^
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:22:
In file included from /usr/local/include/tensorflow/core/framework/device_attributes.pb.h:29:
/usr/local/include/google/protobuf/repeated_field.h:2289:61: error: member reference base type 'const iterator' ( aka 'const int') is not a structure or union
bool operator==(const iterator& x) const { return it_ == x.it_; }
~^~~~
/usr/local/include/google/protobuf/repeated_field.h:2290:61: error: member reference base type 'const iterator' ( aka 'const int') is not a structure or union
bool operator!=(const iterator& x) const { return it_ != x.it_; }
~^~~~
/usr/local/include/google/protobuf/repeated_field.h:2293:59: error: member reference base type 'const iterator' ( aka 'const int') is not a structure or union
bool operator<(const iterator& x) const { return it_ < x.it_; }
~^~~~
/usr/local/include/google/protobuf/repeated_field.h:2294:61: error: member reference base type 'const iterator' ( aka 'const int') is not a structure or union
bool operator<=(const iterator& x) const { return it_ <= x.it_; }
~^~~~
/usr/local/include/google/protobuf/repeated_field.h:2295:59: error: member reference base type 'const iterator' ( aka 'const int') is not a structure or union
bool operator>(const iterator& x) const { return it_ > x.it_; }
~^~~~
/usr/local/include/google/protobuf/repeated_field.h:2296:61: error: member reference base type 'const iterator' ( aka 'const int') is not a structure or union
bool operator>=(const iterator& x) const { return it_ >= x.it_; }
~^~~~
/usr/local/include/google/protobuf/repeated_field.h:2324:70: error: member reference base type 'const iterator' ( aka 'const int') is not a structure or union
difference_type operator-(const iterator& x) const { return it_ - x.it_; }
~^~~~
In file included from /Users/arcadillanzacarmona/Desktop/FaceSDK/main.cpp:33:
In file included from /usr/local/include/tensorflow/core/public/session.h:24:
In file included from /usr/local/include/tensorflow/core/framework/tensor.h:21:
In file included from /usr/local/include/tensorflow/core/framework/allocator.h:26:
In file included from /usr/local/include/tensorflow/core/framework/variant.h:30:
In file included from /usr/local/include/tensorflow/core/platform/mutex.h:31:
/usr/local/include/tensorflow/core/platform/default/mutex.h:25:10: fatal error: 'nsync_cv.h' file not found
#include "nsync_cv.h"
^
15 errors generated.
gmake[3]: *** [CMakeFiles/FaceSDK.dir/build.make:63: CMakeFiles/FaceSDK.dir/main.cpp.o] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:68: CMakeFiles/FaceSDK.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:80: CMakeFiles/FaceSDK.dir/rule] Error 2
gmake: *** [Makefile:118: FaceSDK] Error 2
Can anyone help me? Seems that the main problem is in the google/protobuf.
The problem is that gif_lib.h and that protobuf header file are incompatible. More specifically, the problem is that gif_lib.h uses the preprocessor to define a macro called VoidPtr, and then the protobuf header uses VoidPtr as an identifier. The fault firmly lays with gif_lib, not protobuf! Preprocessor macros, by convention, are usually uppercase, should include the library name, and should be avoided entirely if possible (in this case, wouldn't a typedef have done?).
Here are some possible workarounds:
Include the protobuf header (or something that includes it, like a TensorFlow header) before the gif_lib.h one (or, again, something that includes it).
After including gif_lib.h, write #undef VoidPtr on a separate line (but this might cause other mysterious problems, depending on how gif_lib.h is implemented.
Do not #include those both of those two headers from any one of your files; hide them behind your own interfaces.
File a bug with whoever wrote gif_lib and get them to stop using the proprocessor in such a dangerous way.
Use a better designed library in place of gif_lib.
I had the similar issue which is solved by changing compiler and using a different version of C++(i.e. from clang to g++-5, g++-7, etc.). I suggest that you can try to solve it in this way. Sorry for not able to give a direct solution.
For the error about nsync_cv, alc1218's solution on this post may help, which is changing the file mutex.h as follows:
/* Copyright 2015 The TensorFlow Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_PLATFORM_DEFAULT_MUTEX_H_
#define TENSORFLOW_PLATFORM_DEFAULT_MUTEX_H_
// IWYU pragma: private, include "third_party/tensorflow/core/platform/mutex.h"
// IWYU pragma: friend third_party/tensorflow/core/platform/mutex.h
#include <chrono>
#include <condition_variable>
#include <mutex>
#include "tensorflow/core/platform/thread_annotations.h"
namespace tensorflow {
#undef mutex_lock
enum LinkerInitialized { LINKER_INITIALIZED };
// A class that wraps around the std::mutex implementation, only adding an
// additional LinkerInitialized constructor interface.
class LOCKABLE mutex : public std::mutex {
public:
mutex() {}
// The default implementation of std::mutex is safe to use after the linker
// initializations
explicit mutex(LinkerInitialized x) {}
void lock() ACQUIRE() { std::mutex::lock(); }
bool try_lock() EXCLUSIVE_TRYLOCK_FUNCTION(true) {
return std::mutex::try_lock();
};
void unlock() RELEASE() { std::mutex::unlock(); }
};
class SCOPED_LOCKABLE mutex_lock : public std::unique_lock<std::mutex> {
public:
mutex_lock(class mutex& m) ACQUIRE(m) : std::unique_lock<std::mutex>(m) {}
mutex_lock(class mutex& m, std::try_to_lock_t t) ACQUIRE(m)
: std::unique_lock<std::mutex>(m, t) {}
mutex_lock(mutex_lock&& ml) noexcept
: std::unique_lock<std::mutex>(std::move(ml)) {}
~mutex_lock() RELEASE() {}
};
// Catch bug where variable name is omitted, e.g. mutex_lock (mu);
#define mutex_lock(x) static_assert(0, "mutex_lock_decl_missing_var_name");
using std::condition_variable;
inline ConditionResult WaitForMilliseconds(mutex_lock* mu,
condition_variable* cv, int64 ms) {
std::cv_status s = cv->wait_for(*mu, std::chrono::milliseconds(ms));
return (s == std::cv_status::timeout) ? kCond_Timeout : kCond_MaybeNotified;
}
} // namespace tensorflow
#endif // TENSORFLOW_PLATFORM_DEFAULT_MUTEX_H_
or simply find where your "nsync_cv" is and include the whole path.
I recently downloaded a program. A patient specific survival prediction CLI, http://pssp.srv.ualberta.ca/
The readme included states:
"1 Compilation
The code should compile on Linux without any modification. To compile, just type ’make’. There should
be 2 executables after compilation, mtlr train and mtlr test."
I download an extracted the folder to my location, when I go into the directory and type make I get:
x#x-laptop:/pssp_source$ make
g++ -c -O3 DenseVector.cpp -o DenseVector.o
In file included from DenseVector.cpp:1:0:
DenseVector.h:9:2: error: ‘size_t’ does not name a type
size_t m_dim;
^
DenseVector.h:18:21: error: expected ‘)’ before ‘n’
DenseVector(size_t n);
^
DenseVector.h:26:33: error: ‘size_t’ does not name a type
double const& operator[](const size_t i) const
^
DenseVector.h:26:40: error: ISO C++ forbids declaration of ‘i’ with no type [-fpermissive]
double const& operator[](const size_t i) const
^
DenseVector.h:31:27: error: ‘size_t’ does not name a type
double& operator[](const size_t i)
^
DenseVector.h:31:34: error: ISO C++ forbids declaration of ‘i’ with no type [-fpermissive]
double& operator[](const size_t i)
^
DenseVector.h:38:2: error: ‘size_t’ does not name a type
size_t dim() const
^
DenseVector.h: In member function ‘void DenseVector::push_back(double)’:
DenseVector.h:23:3: error: ‘m_dim’ was not declared in this scope
m_dim++;
^
DenseVector.cpp: At global scope:
DenseVector.cpp:6:1: error: prototype for ‘DenseVector::DenseVector(size_t)’ does not match any in class ‘DenseVector’
DenseVector::DenseVector(size_t n): m_dim(n)
^
In file included from DenseVector.cpp:1:0:
DenseVector.h:5:7: error: candidates are: DenseVector::DenseVector(const DenseVector&)
class DenseVector
^
DenseVector.h:12:2: error: DenseVector::DenseVector()
DenseVector(void);
^
DenseVector.cpp: In constructor ‘DenseVector::DenseVector()’:
DenseVector.cpp:16:2: error: class ‘DenseVector’ does not have any field named ‘m_dim’
:m_dim(0)
^
DenseVector.cpp: In member function ‘void DenseVector::clear()’:
DenseVector.cpp:27:22: error: ‘m_dim’ was not declared in this scope
for (size_t i=0; i<m_dim; i++)
^
In file included from /usr/include/c++/4.8/cassert:43:0,
from DenseVector.cpp:3:
DenseVector.cpp: In function ‘double sprod_nn(const DenseVector&, const DenseVector&)’:
DenseVector.cpp:37:11: error: ‘const class DenseVector’ has no member named ‘dim’
assert(a.dim() == b.dim());
^
DenseVector.cpp:37:22: error: ‘const class DenseVector’ has no member named ‘dim’
assert(a.dim() == b.dim());
^
DenseVector.cpp:38:15: error: ‘const class DenseVector’ has no member named ‘dim’
size_t n = a.dim();
^
In file included from /usr/include/c++/4.8/cassert:43:0,
from DenseVector.cpp:3:
DenseVector.cpp: In function ‘void multadd_nn(DenseVector&, const DenseVector&, double)’:
DenseVector.cpp:49:11: error: ‘class DenseVector’ has no member named ‘dim’
assert(w.dim()==a.dim());
^
DenseVector.cpp:49:20: error: ‘const class DenseVector’ has no member named ‘dim’
assert(w.dim()==a.dim());
^
DenseVector.cpp:50:15: error: ‘class DenseVector’ has no member named ‘dim’
size_t n = w.dim();
^
DenseVector.cpp: In function ‘void smult_n(DenseVector&, double)’:
DenseVector.cpp:62:15: error: ‘class DenseVector’ has no member named ‘dim’
size_t n = w.dim();
^
make: *** [DenseVector.o] Error 1
The contents of the folder look like:
x#x-laptop:/pssp_source$ ls
common.cpp data_type_api.h DenseVector.h Main.cpp Makefile Sparm.cpp Sparm.o SparseVector.h test_model.mltr Util.h
common.h DenseVector.cpp example_data Main.o readme.pdf Sparm.h SparseVector.cpp Test.cpp test_model.mlty
I looked up the basic packages needed for compiling c++ code, as well as basics on how to run it and none have gotten me past this issue. It looks as if it has a problem with size_t not having a type.
The start of DenseVector.cpp is :
#include "DenseVector.h"
#include <cassert>
#include <iostream>
DenseVector::DenseVector(size_t n): m_dim(n)
{
m_dvector.reserve(n);
for (size_t i=0; i<n; i++)
{
m_dvector.push_back(0);
}
}
I have never compiled code like this before, so I am probably missing something obvious. If its needed I am running ubuntu 14.04, g++ version is
4.8.4.
Thanks
It sounds like the README lied. Probably it happened to work with a different version of the standard library.
Try adding
#include <stddef.h>
near the top of DenseVector.h.
Open the file DenseVector.h in the root directory of the program and modify it, inserting
#pragma once
#include <vector>
#include <cstddef> // <--- Add this line to the file
class DenseVector
{
protected:
// ...
Save it and try again!
I don't think you are using the correct version of C; I think you need C11. Instead of using the -03 flag, use -11 or -std=c11. Then recompile it.