Errors while compiling DeSiNe - c++

While I run make build for the project DeSiNe [Click to go to github page], I am getting the error ‘Topology’ does not name a type
$ make build
mkdir -m 755 -p obj/Algorithm
g++ -Wall -DNO_TIMER -DNO_TRACES -O3 -funroll-loops -finline-functions -fexpensive-optimizations -Isrc -o obj/Algorithm/Algorithm.o -c src/Algorithm/Algorithm.cpp
In file included from src/Network/TopologyFactory.h:21:0,
from src/Network/Topology.h:25,
from src/Network/Flow.h:20,
from src/Algorithm/Algorithm.h:20,
from src/Algorithm/Algorithm.cpp:14:
src/RandomVariables/RandomNumberGenerator.h: In member function ‘double RandomNumberGenerator::generate()’:
src/RandomVariables/RandomNumberGenerator.h:158:43: warning: dereferencing type-punned pointer will break strict-aliasing rules [-Wstrict-aliasing]
return (double) 2.0 - (*(float*) &itemp);
^
In file included from src/Network/Topology.h:25:0,
from src/Network/Flow.h:20,
from src/Algorithm/Algorithm.h:20,
from src/Algorithm/Algorithm.cpp:14:
src/Network/TopologyFactory.h: At global scope:
src/Network/TopologyFactory.h:76:5: error: ‘Topology’ does not name a type
Topology* create(const TString &description);
^
src/Network/TopologyFactory.h:84:48: error: ‘Topology’ has not been declared
void build(const NodePairDeque &nodepairs, Topology* topology);
^
src/Network/TopologyFactory.h:92:5: error: ‘Topology’ does not name a type
Topology* createTopologyAdjacency(const TString &description);
^
src/Network/TopologyFactory.h:103:5: error: ‘Topology’ does not name a type
Topology* createTopologyBarabasi(const TString &description);
^
src/Network/TopologyFactory.h:112:5: error: ‘Topology’ does not name a type
Topology* createTopologyErdos(const TString &description);
^
src/Network/TopologyFactory.h:120:5: error: ‘Topology’ does not name a type
Topology* createTopologyFile(const TString &description);
^
src/Network/TopologyFactory.h:129:5: error: ‘Topology’ does not name a type
Topology* createTopologyFull(const TString &description);
^
src/Network/TopologyFactory.h:138:5: error: ‘Topology’ does not name a type
Topology* createTopologyGrid2D(const TString &description);
^
src/Network/TopologyFactory.h:147:5: error: ‘Topology’ does not name a type
Topology* createTopologyRandom(const TString &description);
^
make: *** [Algorithm/Algorithm] Error 1
but the included Topology.h does contain
class Topology : public AbstractNetworkElement
{
// Friend(s)
How to resolve?
EDIT:
Adding forward declaration for class Topology gives further error:
In file included from src/Algorithm/SamcraBAlgorithm.h:22:0,
from src/Algorithm/SamcraBAlgorithm.cpp:17:
src/Utils/TString.h:25:7: error: using typedef-name ‘Types::TString’ after ‘class’
class TString
^
In file included from src/LinkStateUpdate/LinkStateUpdateVisitor.h:23:0,
from src/Network/Link.h:19,
from src/Network/Topology.h:23,
from src/Network/Flow.h:20,
from src/Algorithm/Algorithm.h:22,
from src/Algorithm/SamcraBAlgorithm.cpp:16:
src/Utils/Types.h:65:24: note: ‘Types::TString’ has a previous declaration here
typedef deque<string> TString;
^
make: *** [Algorithm/SamcraBAlgorithm] Error 1

Basically the project has four main compilation problems:
Circular include dependency between TopologyFactory and Topology classes.
Including TString.h header directly when is meant to be used as a typedef.
Missing cstdlib/cstdio includes.
Member initialization in class definition (not available until C++11).
The fix for the first one involves removing TopologyFactory from the Topology header, thus breaking the circular include dependency. Then including the TopologyFactory header where is needed.
The second one is easy to fix: just remove the TString header includes so it uses the definition at Utils/Types.h by default.
Third fix is trivial: just add the cstdio/cstdlib includes where needed.
The last fix involves moving the static initialization to the definition file (maybe the author was using an old compiler with an extension who allowed this type of initialization).
I made a patch on this gist so you can see the changes. The project compiles with g++ 5.2.1 on Ubuntu 15.10.

There is a cross-reference in the code.
Topology.h includes TopologyFactory.h and vice versa TopologyFactory.h included Topology.h
The most easy way to fix it add forward declaration for class Topology into TopologyFactory.h:
#ifndef TOPOLOGYFACTORY_H
#define TOPOLOGYFACTORY_H
...
class Topology;
class TopologyFactory
{
More correct approach would be try to solve these dependencies, i.e. don't include TopologyNetwork.h in Topology.h and then in all cpp files which using TopologyNetwork and Topology add two include directives:
/*
source file DesineModel.cpp for class: DesineModel
...
*/
...
#include "Network/Topology.h"
#include "Network/TopologyFactory.h"
...

Related

Error with Protobuf while compiling Tensorflow

I am currently trying use Tensorflow's shared libraries in a non-bazel project.
So I built the .so file using:
bazel build //tensorflow:libtensorflow.so
Then I loaded the dependencies as described here.
I added the following flags to my Makefile:
CFLAGS += -I/home/alpy/tensorflow/bazel-genfiles
CFLAGS += -I/home/alpy/tensorflow/
CFLAGS += -I/home/alpy/tensorflow/tensorflow/contrib/makefile/downloads/eigen-latest/
LDFLAGS += -L../resources/
LDFLAGS += -ltensorflow.so
When I do this, I get this rather strange error:
In file included from /home/alpy/tensorflow/tensorflow/core/public/session.h:22:0,
from ../src/conversion.h:14,
from ../src/conversion.cpp:1:
/home/alpy/tensorflow/bazel-genfiles/tensorflow/core/framework/graph.pb.h:143:3: error: ‘PROTOBUF_DEPRECATED_ATTR’ does not name a type
PROTOBUF_DEPRECATED_ATTR void clear_version();
^
/home/alpy/tensorflow/bazel-genfiles/tensorflow/core/framework/graph.pb.h:144:3: error: ‘PROTOBUF_DEPRECATED_ATTR’ does not name a type
PROTOBUF_DEPRECATED_ATTR static const int kVersionFieldNumber = 3;
^
/home/alpy/tensorflow/bazel-genfiles/tensorflow/core/framework/graph.pb.h:145:3: error: ‘PROTOBUF_DEPRECATED_ATTR’ does not name a type
PROTOBUF_DEPRECATED_ATTR ::google::protobuf::int32 version() const;
^
/home/alpy/tensorflow/bazel-genfiles/tensorflow/core/framework/graph.pb.h:146:3: error: ‘PROTOBUF_DEPRECATED_ATTR’ does not name a type
PROTOBUF_DEPRECATED_ATTR void set_version(::google::protobuf::int32 value);
^
/home/alpy/tensorflow/bazel-genfiles/tensorflow/core/framework/graph.pb.h:273:37: error: no ‘void tensorflow::GraphDef::clear_version()’ member function declared in class ‘tensorflow::GraphDef’
inline void GraphDef::clear_version() {
^
/home/alpy/tensorflow/bazel-genfiles/tensorflow/core/framework/graph.pb.h:276:54: error: no ‘google::protobuf::int32 tensorflow::GraphDef::version() const’ member function declared in class ‘tensorflow::GraphDef’
inline ::google::protobuf::int32 GraphDef::version() const {
^
/home/alpy/tensorflow/bazel-genfiles/tensorflow/core/framework/graph.pb.h:280:66: error: no ‘void tensorflow::GraphDef::set_version(google::protobuf::int32)’ member function declared in class ‘tensorflow::GraphDef’
inline void GraphDef::set_version(::google::protobuf::int32 value) {
BTW, I loaded protobuf as it was described on the page I linked above.
I think the problem is resolved as described here: Google Groups discussion
Just add a new CFLAG:
-DPROTOBUF_DEPRECATED_ATTR=""

How to compile a program from .cpp files and a makefile

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.

Qt requires C++11 support" make error

I tried Compile the latest tiled from source code following the instructions in README.md.
My working environment:
tiled source code: tiled-0.16.1
Mac OS: 10.11.1
Xcode : 7.1
QMake: 3.0
Qt: 5.7.0
Apple LLVM: 7.0.0
But the make failed with the following error:
In file included from pythonplugin.cpp:21:
In file included from ./pythonplugin.h:30:
In file included from ../../libtiled/logginginterface.h:33:
In file included from ../../libtiled/tiled_global.h:32:
In file included from /Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qglobal.h:1145:
In file included from /Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qatomic.h:46:
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:61:4: error: "Qt requires C++11 support"
# error "Qt requires C++11 support"
^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:90:13: error: unknown type name 'QAtomicOps'
typedef QAtomicOps<T> Ops;
^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:90:23: error: expected member name or ';' after declaration
specifiers
typedef QAtomicOps<T> Ops;
~~~~~~~~~~~~~~~~~~^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:93:23: error: use of undeclared identifier 'QAtomicOpsSupport'
Q_STATIC_ASSERT_X(QAtomicOpsSupport<sizeof(T)>::IsSupported, "template parameter is an integral of a size not supported on this platform");
^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qglobal.h:746:66: note: expanded from macro 'Q_STATIC_ASSERT_X'
#define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
^
In file included from pythonplugin.cpp:21:
In file included from ./pythonplugin.h:30:
In file included from ../../libtiled/logginginterface.h:33:
In file included from ../../libtiled/tiled_global.h:32:
In file included from /Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qglobal.h:1145:
In file included from /Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qatomic.h:46:
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:93:53: error: no member named 'IsSupported' in the global
namespace
Q_STATIC_ASSERT_X(QAtomicOpsSupport<sizeof(T)>::IsSupported, "template parameter is an integral of a size not supported on this platform");
~~^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qglobal.h:746:66: note: expanded from macro 'Q_STATIC_ASSERT_X'
#define Q_STATIC_ASSERT_X(Condition, Message) static_assert(bool(Condition), Message)
^
In file included from pythonplugin.cpp:21:
In file included from ./pythonplugin.h:30:
In file included from ../../libtiled/logginginterface.h:33:
In file included from ../../libtiled/tiled_global.h:32:
In file included from /Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qglobal.h:1145:
In file included from /Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qatomic.h:46:
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:95:14: error: use of undeclared identifier 'Ops'
typename Ops::Type _q_value;
^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:95:19: error: expected a qualified name after 'typename'
typename Ops::Type _q_value;
^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:95:23: error: expected ';' at end of declaration list
typename Ops::Type _q_value;
^
;
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:99:44: error: use of undeclared identifier 'Ops'
T load() const Q_DECL_NOTHROW { return Ops::load(_q_value); }
^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:99:54: error: use of undeclared identifier '_q_value'
T load() const Q_DECL_NOTHROW { return Ops::load(_q_value); }
^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:100:45: error: use of undeclared identifier 'Ops'
void store(T newValue) Q_DECL_NOTHROW { Ops::store(_q_value, newValue); }
^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:100:56: error: use of undeclared identifier '_q_value'
void store(T newValue) Q_DECL_NOTHROW { Ops::store(_q_value, newValue); }
^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:102:51: error: use of undeclared identifier 'Ops'
T loadAcquire() const Q_DECL_NOTHROW { return Ops::loadAcquire(_q_value); }
^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:102:68: error: use of undeclared identifier '_q_value'
T loadAcquire() const Q_DECL_NOTHROW { return Ops::loadAcquire(_q_value); }
^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:103:52: error: use of undeclared identifier 'Ops'
void storeRelease(T newValue) Q_DECL_NOTHROW { Ops::storeRelease(_q_value, newValue); }
^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:103:70: error: use of undeclared identifier '_q_value'
void storeRelease(T newValue) Q_DECL_NOTHROW { Ops::storeRelease(_q_value, newValue); }
^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:107:86: error: use of undeclared identifier 'Ops'
static Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return Ops::isReferenceCountingNative(); }
^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:107:34: error: no return statement in constexpr function
static Q_DECL_CONSTEXPR bool isReferenceCountingNative() Q_DECL_NOTHROW { return Ops::isReferenceCountingNative(); }
^
/Users/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers/qbasicatomic.h:108:88: error: use of undeclared identifier 'Ops'
static Q_DECL_CONSTEXPR bool isReferenceCountingWaitFree() Q_DECL_NOTHROW { return Ops::isReferenceCountingWaitFree(); }
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[3]: *** [pythonplugin.o] Error 1
make[2]: *** [sub-python-make_first] Error 2
make[1]: *** [sub-plugins-make_first-ordered] Error 2
make: *** [sub-src-make_first-ordered] Error 2
After doing some research, I tried to add a line CONFIG+= c++11 to the tiled.pro file and then make clean , qmake, make but still I am having the same error ......
tiled.pro :
# Check the Qt version. If QT_VERSION is not set, it is probably Qt 3.
isEmpty(QT_VERSION) {
error("QT_VERSION not defined. Tiled does not work with Qt 3.")
}
include(tiled.pri)
!minQtVersion(5, 1, 0) {
message("Cannot build Tiled with Qt version $${QT_VERSION}")
error("Use at least Qt 5.1.0.")
}
TEMPLATE = subdirs
CONFIG += ordered
CONFIG += c++11
SUBDIRS = src translations
Not sure what goes wrong here.
Any advice will be appreciated, thanks :)
UPDATE:
Tried
QMAKE_CXXFLAGS += -std=c++11
and
QMAKE_CXXFLAGS += -std=c++0x
Still have the same error ......
I thought it might be in the C++ compile the make command use, here is some information :
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -c `python-config --cflags` -O2 -std=gnu++11 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -mmacosx-version-min=10.8 -fvisibility=hidden -fvisibility-inlines-hidden -Wall -W -fPIC -DPYTHON_LIBRARY -DQT_NO_DEBUG -DQT_PLUGIN -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I../../libtiled -I/Users/supersuraccoon/Qt5.7.0/5.7/clang_64/lib/QtWidgets.framework/Headers -I/Users/supersuraccoon/Qt5.7.0/5.7/clang_64/lib/QtGui.framework/Headers -I/Users/supersuraccoon/Qt5.7.0/5.7/clang_64/lib/QtCore.framework/Headers -I. -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/OpenGL.framework/Headers -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/AGL.framework/Headers -I/Users/supersuraccoon/Qt5.7.0/5.7/clang_64/mkspecs/macx-clang -F/Users/supersuraccoon/Qt5.7.0/5.7/clang_64/lib -o pythonplugin.o pythonplugin.cpp
I had a similar problem building poppler with Qt wrappers and got the same error: "Qt requires C++11 support".
My setup is:
Mac OS: 10.11.5
Xcode : 7.3.1
QMake: 3.0
Qt: 5.7.0
Apple LLVM: 7.3.0
All I did was:
export CXXFLAGS=-std=c++11
./configure
make
and it worked.
I know it has been a while.
How I finally solve this problem is adding in CMakeLists.txt the following line just after project(MyProject):
add_compile_options(-std=c++11)
That says to cmake, to create a Makefile that will use c++11 solving issues.

Building C++ application with pre-build library gives compile errors

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)

Compiling C++ Thrift code to interface Cassandra results in following errors. What are we missing here?

$ g++ -lthrift -Wall thriftfs.cpp cassandra_constants.cpp Cassandra.cpp cassandra_types.cpp -o thriftfs -I/usr/local/include/thrift -L/usr/local/lib
In file included from /usr/local/include/thrift/protocol/TProtocol.h:23:0,
from /usr/local/include/thrift/TProcessor.h:24,
from Cassandra.h:10,
from t`enter code here`hriftfs.cpp:4:
/usr/local/include/thrift/transport/TTransport.h:34:1: error: ‘uint32_t’ does not name a type
/usr/local/include/thrift/transport/TTransport.h:156:29: error: ISO C++ forbids declaration of ‘buf’ with no type [-fpermissive]
In file included from /usr/local/include/thrift/TProcessor.h:24:0,
from Cassandra.h:10,
from thriftfs.cpp:4:
/usr/local/include/thrift/protocol/TProtocol.h:184:1: error: ‘uint32_t’ does not name a type
In file included from Cassandra.h:10:0,
from thriftfs.cpp:4:
/usr/local/include/thrift/TProcessor.h:72:57: error: ‘uint32_t’ has not been declared
In file included from cassandra_types.h:11:0,
from Cassandra.h:11,
from thriftfs.cpp:4:
/usr/local/include/thrift/TApplicationException.h:94:3: error: ‘uint32_t’ does not name a type
In file included from Cassandra.h:11:0,
from thriftfs.cpp:4:
cassandra_types.h:85:16: error: ‘uint8_t’ does not name a type
In file included from Cassandra.h:11:0,
from thriftfs.cpp:4:
cassandra_types.h:142:3: error: ‘uint32_t’ does not name a type
In file included from Cassandra.h:11:0,
from thriftfs.cpp:4:
cassandra_types.h:1478:16: error: ‘uint8_t’ does not name a type
In file included from Cassandra.h:11:0,
from thriftfs.cpp:4:
cassandra_types.h:1812:3: error: ‘uint32_t’ does not name a type
In file included from thriftfs.cpp:4:0:
Cassandra.h:217:3: error: ‘uint32_t’ does not name a type
Cassandra.h:4857:35: error: ‘org::apache::thrift’ has not been declared
Cassandra.h:4857:62: error: expected ‘,’ or ‘...’ before ‘*’ token
Cassandra.h:4859:71: error: cannot declare pointer to ‘void’ member
Cassandra.h:4859:145: error: template argument 2 is invalid
Cassandra.h:4859:145: error: template argument 4 is invalid
Cassandra.h:4860:45: error: ‘org::apache::thrift’ has not been declared
Cassandra.h:4860:72: error: expected ‘,’ or ‘...’ before ‘*’ token
Cassandra.h:4935:42: error: ‘thrift’ is not a member of ‘org::apache’
Cassandra.h:4935:42: note: suggested alternative:
/usr/local/include/thrift/Thrift.h:75:37: note: ‘apache::thrift’
Cassandra.h:4935:42: error: ‘thrift’ is not a member of ‘org::apache’
Cassandra.h:4935:42: note: suggested alternative:
/usr/local/include/thrift/Thrift.h:75:37: note: ‘apache::thrift’
Cassandra.h:4935:77: error: template argument 1 is invalid
Cassandra.h:4935:105: error: ‘thrift’ is not a member of ‘org::apache’
Cassandra.h:4935:105: note: suggested alternative:
/usr/local/include/thrift/Thrift.h:75:37: note: ‘apache::thrift’
Cassandra.h:4935:105: error: ‘thrift’ is not a member of ‘org::apache’
Cassandra.h:4935:105: note: suggested alternative:
/usr/local/include/thrift/Thrift.h:75:37: note: ‘apache::thrift’
Cassandra.h:4935:140: error: template argument 1 is invalid
Cassandra.h: In constructor ‘org::apache::cassandra::CassandraProcessor::CassandraProcessor(boost::shared_ptr)’:
Cassandra.h:4898:49: error: assignment of read-only location ‘"login"[((org::apache::cassandra::CassandraProcessor*)this)->org::apache::cassandra::CassandraProcessor::processMap_]’
Cassandra.h:4898:49: error: cannot convert ‘void (org::apache::cassandra::CassandraProcessor::*)(int32_t, int) {aka void (org::apach
Add the following defines:
g++ -DHAVE_NETINET_IN_H -DHAVE_INTTYPES_H ...
Or add #include <stdint.h> before including Thrift.h in your code.
See the discussion at THRIFT-1326. The issue is suppposedly fixed in thrift 0.9.
It looks like your problem is a compiler issue.
It can't find the type "uint32_t"
There is another question on SO regarding this:
'uint32_t' identifier not found error
Quoted from user templatetypedef
This type is defined in the C header which is not currently
a part of the C++ standard. According to the Wikipedia page on the
header, it hasn't shipped with Visual Studio until VS2010.
In the meantime, you could probably fake up your own version of the
header by adding typedefs that map Microsoft's custom integer types to
the types expected by C. For example:
typedef __int32 int32_t; typedef unsigned __int32 uint32_t; /* ...
etc. ... */ Hope this helps!