Error in a ns-3 simulation? - c++

I am trying to run a simulation but I keep getting some kind of error. I am not an expert on C++, but I think it's due to header file include. I am getting the following error:
error: ISO C++ forbids declaration of ‘type name’ with no type [-fpermissive]
void OutInterest(Ptr<const ns3::ndn::InterestHeader> interestHeader,Ptr<const ns3::ndn::Face> face) {
^
../scratch/vndn_simulation.cc:87:52: error: template argument 1 is invalid
void OutInterest(Ptr<const ns3::ndn::InterestHeader> interestHeader,Ptr<const ns3::ndn::Face> face) {
^
../scratch/vndn_simulation.cc:87:28: error: ISO C++ forbids declaration of ‘type name’ with no type [-fpermissive]
void OutInterest(Ptr<const ns3::ndn::InterestHeader> interestHeader,Ptr<const ns3::ndn::Face> face) {
Any idea on how to solve this error?

It says here:
class NameComponents;
^
In file included from ./ns3/ndn-v2v-net-device-face.h:31:0,
from ../scratch/vndn_simulation.cc:15:
./ns3/ndn-header-helper.h:34:21: note: ‘ns3::ndn::NameComponents’ has a previous declaration here
typedef Name NameComponents;
^
that you cannot forward declare NameComponents because the compiler has already seen that it is a typedef and not a class.

Related

Compile errors in Tensorflow Lite Micro framework when trying to integrate Tensorflow Lite Micro to my ESP32 Arduino project

Hi stackoverflow community,
I am trying to get a project leveraging Tensorflow Lite Micro to run on my ESP32 using PlatformIO and the Arduino framework (not ESP-IDF). Basically, I followed the guide in this medium post https://towardsdatascience.com/tensorflow-meet-the-esp32-3ac36d7f32c7 and then included everything in my already existing ESP32 project.
My project was compiling fine prior to the integration of Tensorflow Lite Micro but since integrating it, I am getting the following compile errors which seem to be related to the Tensorflow framework itself. When I uncomment everything related to Tensorflow, it compiles fine. But just when only including the following header files, it breaks:
#include "tensorflow/lite/micro/kernels/micro_ops.h"
#include "tensorflow/lite/micro/micro_error_reporter.h"
#include "tensorflow/lite/micro/micro_interpreter.h"
#include "tensorflow/lite/micro/micro_mutable_op_resolver.h"
#include "tensorflow/lite/schema/schema_generated.h"
#include "tensorflow/lite/version.h"
Does someone know where these errors come from and what I can do to solve those?
Here is the error trace:
In file included from /Users/XXX/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFiClient.h:24:0,
from /Users/XXX/.platformio/packages/framework-arduinoespressif32/libraries/WiFi/src/WiFi.h:37,
from src/main.cpp:3:
/Users/XXX/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:64:17: error: expected identifier before numeric constant
#define DEFAULT 1
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:31:5: note: in expansion of macro 'DEFAULT'
DEFAULT = 1,
^
/Users/XXX/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:64:17: error: expected '}' before numeric constant
#define DEFAULT 1
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:31:5: note: in expansion of macro 'DEFAULT'
DEFAULT = 1,
^
/Users/XXX/.platformio/packages/framework-arduinoespressif32/cores/esp32/Arduino.h:64:17: error: expected unqualified-id before numeric constant
#define DEFAULT 1
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:31:5: note: in expansion of macro 'DEFAULT'
DEFAULT = 1,
^
In file included from lib/tfmicro/tensorflow/lite/micro/micro_interpreter.h:24:0,
from src/main.cpp:12:
lib/tfmicro/tensorflow/lite/core/api/profiler.h:51:21: error: declaration of '~tflite::Profiler' as non-member
virtual ~Profiler() {}
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:61:48: error: 'EventType' has not been declared
virtual uint32_t BeginEvent(const char* tag, EventType event_type,
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:63:54: error: 'virtual' outside class declaration
int64_t event_metadata2) = 0;
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:63:58: error: function 'uint32_t tflite::BeginEvent(const char*, int, int64_t, int64_t)' is initialized like a variable
int64_t event_metadata2) = 0;
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:65:40: error: 'EventType' has not been declared
uint32_t BeginEvent(const char* tag, EventType event_type,
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:74:48: error: 'virtual' outside class declaration
int64_t event_metadata2) {}
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:76:46: error: 'virtual' outside class declaration
virtual void EndEvent(uint32_t event_handle) = 0;
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:76:50: error: function 'void tflite::EndEvent(uint32_t)' is initialized like a variable
virtual void EndEvent(uint32_t event_handle) = 0;
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:85:34: error: 'EventType' has not been declared
void AddEvent(const char* tag, EventType event_type, uint64_t start,
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h: In function 'void tflite::AddEvent(const char*, int, uint64_t, uint64_t, int64_t)':
lib/tfmicro/tensorflow/lite/core/api/profiler.h:88:35: error: too many arguments to function 'void tflite::AddEvent(const char*, int, uint64_t, uint64_t, int64_t)'
/*event_metadata2*/ 0);
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:85:8: note: declared here
void AddEvent(const char* tag, EventType event_type, uint64_t start,
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h: At global scope:
lib/tfmicro/tensorflow/lite/core/api/profiler.h:91:42: error: 'EventType' has not been declared
virtual void AddEvent(const char* tag, EventType event_type, uint64_t start,
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:93:48: error: 'virtual' outside class declaration
int64_t event_metadata2) {}
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:95:2: error: expected unqualified-id before 'protected'
protected:
^
lib/tfmicro/tensorflow/lite/core/api/profiler.h:105:25: error: expected ')' before '*' token
ScopedProfile(Profiler* profiler, const char* tag,
^
src/main.cpp:202:1: error: expected '}' at end of input
}
^
src/main.cpp:202:1: error: expected unqualified-id at end of input
*** [.pio/build/esp32cam/src/main.cpp.o] Error 1
Today I faced a similar problem. I solved it by using TensorFlowLite_ESP32 library instead of Arduino_TensorFlowLite. You need to download this library and add the line #include <TensorFlowLite_ESP32.h>. I hope this helps you too
I resolved this for now by switching from the Arduino framework to the ESP-IDF framework. With this, it works like a charm.

Building iotivity on mac

According to the docs, Mac should be supported but when attempting to build iotivity some headers are used that I think are posix specific.
➜ iotivity git:(master) ✗ scons SYS_VERSION=10.12
scons: Reading SConscript files ...
Checking for POSIX Thread Support...(cached) yes
HEAD is now at acf202a Fix stack corruption due to calling convention mismatch
*********************************** Info: *****************************************
* Using FORKED copy of libCoap located in: *
* resource/csdk/connectivity/lib/libcoap-4.1.1 *
***********************************************************************************
Given Transport is ALL
Given OS is darwin
BUILD_SAMPLE is ON
MQ flag is OFF
Reading ca script ALL
Reading common folder script
Reading util folder script
Copied IoTivity version of config.h to /Users/zcourts/projects/iotivity/extlibs/mbedtls/mbedtls/include/mbedtls/config.h
Reading IP adapter script
Reading IP adapter script
Include path is ['../api', '/usr/local/include', '/Users/zcourts/projects/iotivity/deps/darwin/include', '/Users/zcourts/projects/iotivity/extlibs/tinycbor/tinycbor/src', '/Users/zcourts/projects/iotivity/resource/c_common', '/Users/zcourts/projects/iotivity/out/darwin/x86_64/release/resource/c_common/oic_malloc/include', '/Users/zcourts/projects/iotivity/out/darwin/x86_64/release/resource/c_common/oic_string/include', '/Users/zcourts/projects/iotivity/out/darwin/x86_64/release/resource/c_common/oic_time/include', '/Users/zcourts/projects/iotivity/out/darwin/x86_64/release/resource/c_common/ocatomic/include', '/Users/zcourts/projects/iotivity/out/darwin/x86_64/release/resource/c_common/ocrandom/include', '/Users/zcourts/projects/iotivity/out/darwin/x86_64/release/resource/c_common/octhread/include', '/Users/zcourts/projects/iotivity/out/darwin/x86_64/release/resource/c_common/oic_platform/include', '/Users/zcourts/projects/iotivity/out/darwin/x86_64/release/resource/c_common/octimer/include', '#/extlibs/mbedtls/mbedtls/include', '/Users/zcourts/projects/iotivity/out/darwin/x86_64/release/resource/csdk/logger/include', '#/resource/c_common', '#resource/csdk/connectivity/lib/libcoap-4.1.1/include', '../inc', '/Users/zcourts/projects/iotivity/resource/csdk/logger/include', '../common/inc', '../util/inc', '#resource/c_common/octhread/include/', '#resource/csdk/connectivity/common/inc/', '#resource/csdk/logger/include/', '#extlibs/mbedtls/mbedtls/include', '#/resource/c_common/octimer/include', '/Users/zcourts/projects/iotivity/resource/csdk/security/include', '../external/inc']
Files path is ['/Users/zcourts/projects/iotivity/resource/csdk/connectivity/common/src/uarraylist.c', '/Users/zcourts/projects/iotivity/resource/csdk/connectivity/common/src/ulinklist.c', '/Users/zcourts/projects/iotivity/resource/csdk/connectivity/common/src/uqueue.c', '/Users/zcourts/projects/iotivity/resource/csdk/connectivity/common/src/caremotehandler.c', '/Users/zcourts/projects/iotivity/resource/csdk/connectivity/common/src/cathreadpool_pthreads.c', '/Users/zcourts/projects/iotivity/resource/csdk/connectivity/util/src/cautilinterface.c', './adapter_util/caadapterutils.c', './adapter_util/cafragmentation.c', './adapter_util/ca_adapter_net_ssl.c', './cablockwisetransfer.c', './caconnectivitymanager.c', './cainterfacecontroller.c', './camessagehandler.c', './canetworkconfigurator.c', './caprotocolmessage.c', './caqueueingthread.c', './caretransmission.c', '/Users/zcourts/projects/iotivity/resource/csdk/connectivity/src/ip_adapter/caipadapter.c', '/Users/zcourts/projects/iotivity/resource/csdk/connectivity/src/ip_adapter/caipserver.c', '/Users/zcourts/projects/iotivity/resource/csdk/connectivity/src/ip_adapter/linux/caipnwmonitor.c']
*** Checking for installation of google unit test 1.7.0 ***
scons: done reading SConscript files.
scons: Building targets ...
scons: building associated VariantDir targets: out/darwin/x86_64/release
Compiling out/darwin/x86_64/release/resource/c_common/octhread/src/posix/octhread.o
resource/c_common/octhread/src/posix/octhread.c:90:5: error: unknown type name 'pthread_mutex_t'; did you mean 'pthread_attr_t'?
pthread_mutex_t mutex;
^~~~~~~~~~~~~~~
pthread_attr_t
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk//usr/include/sys/_pthread/_pthread_attr_t.h:30:33: note: 'pthread_attr_t' declared here
typedef __darwin_pthread_attr_t pthread_attr_t;
^
resource/c_common/octhread/src/posix/octhread.c:103:5: error: unknown type name 'pthread_cond_t'; did you mean 'pthread_attr_t'?
pthread_cond_t cond;
^~~~~~~~~~~~~~
pthread_attr_t
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk//usr/include/sys/_pthread/_pthread_attr_t.h:30:33: note: 'pthread_attr_t' declared here
typedef __darwin_pthread_attr_t pthread_attr_t;
^
resource/c_common/octhread/src/posix/octhread.c:104:5: error: unknown type name 'pthread_condattr_t'; did you mean 'pthread_attr_t'?
pthread_condattr_t condattr;
^~~~~~~~~~~~~~~~~~
pthread_attr_t
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk//usr/include/sys/_pthread/_pthread_attr_t.h:30:33: note: 'pthread_attr_t' declared here
typedef __darwin_pthread_attr_t pthread_attr_t;
^
resource/c_common/octhread/src/posix/octhread.c:109:5: error: unknown type name 'pthread_t'
pthread_t thread;
^
resource/c_common/octhread/src/posix/octhread.c:128:22: warning: implicit declaration of function 'pthread_create' is invalid in C99 [-Wimplicit-function-declaration]
int result = pthread_create(&threadInfo->thread, NULL, start_routine, arg);
^
resource/c_common/octhread/src/posix/octhread.c:170:19: warning: implicit declaration of function 'pthread_join' is invalid in C99 [-Wimplicit-function-declaration]
int joinres = pthread_join(threadInfo->thread, NULL);
^
resource/c_common/octhread/src/posix/octhread.c:187:17: warning: implicit declaration of function 'pthread_mutex_init' is invalid in C99 [-Wimplicit-function-declaration]
int ret=pthread_mutex_init(&(mutexInfo->mutex), PTHREAD_MUTEX_DEFAULT);
^
resource/c_common/octhread/src/posix/octhread.c:187:57: error: use of undeclared identifier 'PTHREAD_MUTEX_DEFAULT'
int ret=pthread_mutex_init(&(mutexInfo->mutex), PTHREAD_MUTEX_DEFAULT);
^
resource/c_common/octhread/src/posix/octhread.c:215:19: warning: implicit declaration of function 'pthread_mutex_destroy' is invalid in C99 [-Wimplicit-function-declaration]
int ret = pthread_mutex_destroy(&mutexInfo->mutex);
^
resource/c_common/octhread/src/posix/octhread.c:239:19: warning: implicit declaration of function 'pthread_mutex_lock' is invalid in C99 [-Wimplicit-function-declaration]
int ret = pthread_mutex_lock(&mutexInfo->mutex);
^
resource/c_common/octhread/src/posix/octhread.c:273:19: warning: implicit declaration of function 'pthread_mutex_unlock' is invalid in C99 [-Wimplicit-function-declaration]
int ret = pthread_mutex_unlock(&mutexInfo->mutex);
^
resource/c_common/octhread/src/posix/octhread.c:314:19: warning: implicit declaration of function 'pthread_condattr_init' is invalid in C99 [-Wimplicit-function-declaration]
int ret = pthread_condattr_init(&(eventInfo->condattr));
^
resource/c_common/octhread/src/posix/octhread.c:342:15: warning: implicit declaration of function 'pthread_cond_init' is invalid in C99 [-Wimplicit-function-declaration]
ret = pthread_cond_init(&(eventInfo->cond), &(eventInfo->condattr));
^
resource/c_common/octhread/src/posix/octhread.c:350:13: warning: implicit declaration of function 'pthread_condattr_destroy' is invalid in C99 [-Wimplicit-function-declaration]
pthread_condattr_destroy(&(eventInfo->condattr));
^
resource/c_common/octhread/src/posix/octhread.c:367:19: warning: implicit declaration of function 'pthread_cond_destroy' is invalid in C99 [-Wimplicit-function-declaration]
int ret = pthread_cond_destroy(&(eventInfo->cond));
^
resource/c_common/octhread/src/posix/octhread.c:390:19: warning: implicit declaration of function 'pthread_cond_signal' is invalid in C99 [-Wimplicit-function-declaration]
int ret = pthread_cond_signal(&(eventInfo->cond));
^
resource/c_common/octhread/src/posix/octhread.c:407:19: warning: implicit declaration of function 'pthread_cond_broadcast' is invalid in C99 [-Wimplicit-function-declaration]
int ret = pthread_cond_broadcast(&(eventInfo->cond));
^
resource/c_common/octhread/src/posix/octhread.c:431:17: error: incomplete result type 'struct timespec' in function definition
struct timespec oc_get_current_time()
^
resource/c_common/octhread/src/posix/octhread.c:431:8: note: forward declaration of 'struct timespec'
struct timespec oc_get_current_time()
^
resource/c_common/octhread/src/posix/octhread.c:439:5: warning: implicit declaration of function 'gettimeofday' is invalid in C99 [-Wimplicit-function-declaration]
gettimeofday(&tv, NULL);
^
resource/c_common/octhread/src/posix/octhread.c:440:21: error: variable has incomplete type 'struct timespec'
struct timespec ts;
^
resource/c_common/octhread/src/posix/octhread.c:431:8: note: forward declaration of 'struct timespec'
struct timespec oc_get_current_time()
^
resource/c_common/octhread/src/posix/octhread.c:448:5: error: unknown type name 'time_t'; did you mean 'size_t'?
time_t secPart = microseconds/USECS_PER_SEC;
^~~~~~
size_t
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk//usr/include/sys/_types/_size_t.h:30:32: note: 'size_t' declared here
typedef __darwin_size_t size_t;
^
resource/c_common/octhread/src/posix/octhread.c:450:26: error: incomplete definition of type 'struct timespec'
uint64_t totalNs = ts->tv_nsec + nsecPart;
~~^
resource/c_common/octhread/src/posix/octhread.c:431:8: note: forward declaration of 'struct timespec'
struct timespec oc_get_current_time()
^
resource/c_common/octhread/src/posix/octhread.c:451:5: error: unknown type name 'time_t'; did you mean 'size_t'?
time_t secOfNs = totalNs/NANOSECS_PER_SEC;
^~~~~~
size_t
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk//usr/include/sys/_types/_size_t.h:30:32: note: 'size_t' declared here
typedef __darwin_size_t size_t;
^
resource/c_common/octhread/src/posix/octhread.c:453:7: error: incomplete definition of type 'struct timespec'
ts->tv_nsec = (totalNs)% NANOSECS_PER_SEC;
~~^
resource/c_common/octhread/src/posix/octhread.c:431:8: note: forward declaration of 'struct timespec'
struct timespec oc_get_current_time()
^
resource/c_common/octhread/src/posix/octhread.c:454:7: error: incomplete definition of type 'struct timespec'
ts->tv_sec += secPart + secOfNs;
~~^
resource/c_common/octhread/src/posix/octhread.c:431:8: note: forward declaration of 'struct timespec'
struct timespec oc_get_current_time()
^
resource/c_common/octhread/src/posix/octhread.c:479:25: error: variable has incomplete type 'struct timespec'
struct timespec abstime = { .tv_sec = 0 };
^
resource/c_common/octhread/src/posix/octhread.c:431:8: note: forward declaration of 'struct timespec'
struct timespec oc_get_current_time()
^
resource/c_common/octhread/src/posix/octhread.c:495:19: warning: implicit declaration of function 'pthread_cond_timedwait' is invalid in C99 [-Wimplicit-function-declaration]
ret = pthread_cond_timedwait(&(eventInfo->cond), &(mutexInfo->mutex), &abstime);
^
resource/c_common/octhread/src/posix/octhread.c:520:19: warning: implicit declaration of function 'pthread_cond_wait' is invalid in C99 [-Wimplicit-function-declaration]
int ret = pthread_cond_wait(&eventInfo->cond, &mutexInfo->mutex);
^
15 warnings and 13 errors generated.
scons: *** [out/darwin/x86_64/release/resource/c_common/octhread/src/posix/octhread.o] Error 1
scons: building terminated because of errors.
➜ iotivity git:(master) ✗
I'm following the instructions at https://wiki.iotivity.org/macosx_build_instructions pointed to by https://wiki.iotivity.org/build_for_your_system
had a look but can't see any flags that'd enable mac support explicitly. Anyone know if this is actually supported and just been broken in recent commits? I building master checked out two days ago.
There is a windows-port branch but no mac named branches. remotes/origin/1.3-rel has the same issue.
Found this https://stackoverflow.com/a/24947106/400048 which lead me to my assertion about the posix specific headers being used.
So, anyone know if this can be built on mac and if so, how?
It's not an "officially supported" platform or target at this point, I gather its health was better in the past. Some people have had decent luck building for Mac, I have not. Changes to improve it will certainly considered, and there's an opening for a "Mac port maintainer" to make sure it doesn't rot again (and there's a github project which has added Mac buildability along with other build system reorgs - but I believe compared to iotivity that's rather out of date - however one could start picking fixes from there: https://github.com/OpenOCF/iochibity)

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.

CppCMS build constructor & declaration

From http://cppcms.com/wikipp/en/page/cppcms_1x_forms,
According to this,
A declaration introduces one or more names into a program.....
Therefore, classes, structures, enumerated types, and other
user-defined types can be declared for each compilation unit
AFAIK, constructor should be in myapp.cpp, while declaration should be in content.h. So I put
There are 5 fields on the form. In CppCMS, the form built using 3 codes (the 4th codes are restriction for the fields)
1st codes:
name.message("Your Name");
sex.message("Sex");
marital.message("Marital Status");
age.message("Your Age");
submit.value("Send");
2nd codes:
add(name);
add(sex);
add(marital);
add(age);
add(submit);
3rd codes:
sex.add("Male","male");
sex.add("Female","female");
marital.add("Single","single");
marital.add("Married","married");
marital.add("Divorced","divorced");
4th codes, are restriction for the fields:
name.non_empty();
age.range(0,120);
I'm quite confused which one should be declaration
------------------added
I've tried add all above codes in myapp.cpp like below:
class myapp : public cppcms::application {
public:
myapp(cppcms::service &srv) : cppcms::application(srv)
{
dispatcher().assign("",&myapp::info_form,this);
mapper().assign("");
}
void info_form()
{
name.message("Your Name");
sex.message("Sex");
marital.message("Marital Status");
age.message("Your Age");
submit.value("Send");
add(name);
add(sex);
add(marital);
add(age);
add(submit);
sex.add("Male","male");
sex.add("Female","female");
marital.add("Single","single");
marital.add("Married","married");
marital.add("Divorced","divorced");
name.non_empty();
age.range(0,120);
}
};
But it still giving error:
myapp.cpp: In member function ‘void myapp::info_form()’:
myapp.cpp:20:9: error: ‘name’ was not declared in this scope
myapp.cpp:21:9: error: ‘sex’ was not declared in this scope
myapp.cpp:22:9: error: ‘marital’ was not declared in this scope
myapp.cpp:23:9: error: ‘age’ was not declared in this scope
myapp.cpp:24:9: error: ‘submit’ was not declared in this scope
myapp.cpp:24:9: note: suggested alternative:
/usr/local/include/cppcms/form.h:1574:20: note: ‘cppcms::widgets::submit’
myapp.cpp: At global scope:
myapp.cpp:43:37: error: no ‘void myapp::main(std::string)’ member function declared in class ‘myapp’
my_skin.tmpl:4:2: error: expected unqualified-id before ‘if’
my_skin.tmpl:8:3: error: expected unqualified-id before ‘else’
my_skin.tmpl:12:8: error: expected constructor, destructor, or type conversion before ‘<<’ token
my_skin.tmpl:13:2: error: expected unqualified-id before ‘{’ token

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!