How to compile a program from .cpp files and a makefile - c++

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.

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.

Eigen Half.h compilation error: ‘struct Eigen::half’ has no member named ‘x’

I'm trying to compile some code that uses the same version of Eigen as TensorFlow 2.2 (https://gitlab.com/libeigen/eigen/-/tree/52a2fbbb008a47c5e3fb8ac1c65c2feecb0c511c). The abbreviated command line I'm using to do so is:
tools/cc/gcc74/bin/nvcc-wrapper -nostdinc -isystem external/gcc_7_4/usr/include/c++/7 ...
'-D_GLIBCXX_USE_CXX11_ABI=0' -DBOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS -g1 -O2 '-std=c++14' ...
-fPIC -DEIGEN_MPL2_ONLY '-DEIGEN_MAX_ALIGN_BYTES=16' '-DEIGEN_MAX_STATIC_ALIGN_BYTES=16'
'-D__CUDACC_VER_MAJOR__=10' '-D__CUDACC_VER_MINOR__=0' -DEIGEN_HAS_CUDA_FP16 -iquote ...
This results in a number of compilation errors:
In file included from external/eigen/Eigen/Core:165:0,
from external/eigen/Eigen/Dense:1,
from ...:
external/eigen/Eigen/src/Core/arch/Default/Half.h: In member function ‘Eigen::half::operator bool() const’:
external/eigen/Eigen/src/Core/arch/Default/Half.h:139:13: error: ‘x’ was not declared in this scope
return (x & 0x7fff) != 0;
^
In file included from external/eigen/Eigen/Core:165:0,
from external/eigen/Eigen/Dense:1,
from ...:
external/eigen/Eigen/src/Core/arch/Default/Half.h: In function ‘Eigen::half Eigen::half_impl::operator-(const Eigen::half&)’:
external/eigen/Eigen/src/Core/arch/Default/Half.h:342:10: error: ‘struct Eigen::half’ has no member named ‘x’
result.x = a.x ^ 0x8000;
^
external/eigen/Eigen/src/Core/arch/Default/Half.h:342:16: error: ‘const struct Eigen::half’ has no member named ‘x’
result.x = a.x ^ 0x8000;
^
external/eigen/Eigen/src/Core/arch/Default/Half.h: In function ‘Eigen::half_impl::__half_raw Eigen::half_impl::raw_uint16_to_half(short unsigned int)’:
external/eigen/Eigen/src/Core/arch/Default/Half.h:398:5: error: ‘Eigen::half_impl::__half_raw {aka struct __half}’ has no member named ‘x’
h.x = x;
^
external/eigen/Eigen/src/Core/arch/Default/Half.h: In function ‘Eigen::half_impl::__half_raw Eigen::half_impl::float_to_half_rtne(float)’:
external/eigen/Eigen/src/Core/arch/Default/Half.h:426:5: error: ‘Eigen::half_impl::__half_raw {aka struct __half}’ has no member named ‘x’
o.x = static_cast<unsigned short>(0x0u);
^
Removing -DEIGEN_HAS_CUDA_FP16 causes these errors to go away, but then other code that expects a valid __half stops working. What am I doing wrong?

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++ for Python using Swig

I have successfully generated the .py and .cpp files needed using:
swig -c++ -python sf_c_api.i
but now I'm trying to make the shared object (.so) and I'm getting swamped with errors.
g++ -Wall -g -fPIC -I/usr/include/python2.6 -c atob.c fish.c maby_swap.c pwd_file.c pwd.c setup_fish.c shs.c sf_c_api.cpp sha1.cpp sf_c_api_wrap.cpp
Can anyone make heads or tails of this g++ output?
In file included from /usr/include/python2.6/Python.h:8,
from sf_c_api_wrap.cpp:149:
/usr/include/python2.6/pyconfig.h:1038:1: warning: "_XOPEN_SOURCE" redefined
<built-in>: warning: this is the location of the previous definition
In file included from /usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/bits/postypes.h:42,
from /usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/bits/char_traits.h:42,
from /usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/string:42,
from /usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/stdexcept:39,
from sf_c_api_wrap.cpp:3024:
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:143: error: ‘::btowc’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:148: error: ‘::fwide’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:149: error: ‘::fwprintf’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:150: error: ‘::fwscanf’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:153: error: ‘::mbrlen’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:154: error: ‘::mbrtowc’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:155: error: ‘::mbsinit’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:156: error: ‘::mbsrtowcs’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:159: error: ‘::swprintf’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:160: error: ‘::swscanf’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:162: error: ‘::vfwprintf’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:166: error: ‘::vswprintf’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:170: error: ‘::vwprintf’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:174: error: ‘::wcrtomb’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:185: error: ‘::wcsrtombs’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:195: error: ‘::wctob’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:196: error: ‘::wmemcmp’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:197: error: ‘::wmemcpy’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:198: error: ‘::wmemmove’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:199: error: ‘::wmemset’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:200: error: ‘::wprintf’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:201: error: ‘::wscanf’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:205: error: ‘::wcsstr’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:206: error: ‘::wmemchr’ has not been declared
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar: In function ‘wchar_t* std::wcsstr(wchar_t*, const wchar_t*)’:
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:223: error: invalid conversion from ‘const wchar_t*’ to ‘wchar_t*’
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:223: error: initializing argument 1 of ‘wchar_t* std::wcsstr(wchar_t*, const wchar_t*)’
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar: In function ‘wchar_t* std::wmemchr(wchar_t*, wchar_t, size_t)’:
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:227: error: invalid conversion from ‘const wchar_t*’ to ‘wchar_t*’
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/cwchar:227: error: initializing argument 1 of ‘wchar_t* std::wmemchr(wchar_t*, wchar_t, size_t)’
In file included from /usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/string:42,
from /usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/stdexcept:39,
from sf_c_api_wrap.cpp:3024:
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/bits/char_traits.h: In static member function ‘static int std::char_traits<wchar_t>::compare(const wchar_t*, const wchar_t*, size_t)’:
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/bits/char_traits.h:330: error: ‘wmemcmp’ was not declared in this scope/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/bits/char_traits.h: In static member function ‘static const wchar_t* std::char_traits<wchar_t>::find(const wchar_t*, size_t, const wchar_t&)’:
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/bits/char_traits.h:338: error: initializing argument 1 of ‘wchar_t* std::wmemchr(wchar_t*, wchar_t, size_t)’
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/bits/char_traits.h: In static member function ‘static wchar_t* std::char_traits<wchar_t>::move(wchar_t*, const wchar_t*, size_t)’:
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/bits/char_traits.h:342: error: ‘wmemmove’ was not declared in this scope
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/bits/char_traits.h: In static member function ‘static wchar_t* std::char_traits<wchar_t>::copy(wchar_t*, const wchar_t*, size_t)’:
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/bits/char_traits.h:346: error: ‘wmemcpy’ was not declared in this scope
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/bits/char_traits.h: In static member function ‘static wchar_t* std::char_traits<wchar_t>::assign(wchar_t*, size_t, wchar_t)’:
/usr/gcc/4.4/lib/gcc/i386-pc-solaris2.11/4.4.4/../../../../include/c++/4.4.4/bits/char_traits.h:350: error: ‘wmemset’ was not declared in this scope
/../include/c++/4.4.4/bits/char_traits.h:338: error: invalid conversion from ‘const wchar_t*’ to ‘wchar_t*’
I found a solution.
The problem is that under solaris:
If -D_XOPEN_SOURCE_EXTENDED=1, g++ cannot compile even an empty body
that #includes <iostream>. If it's undefined, then gcc cannot compile
C code.
[source]
and from /usr/include/python2.6/pyconfig.h:
/* Define to activate Unix95-and-earlier features */
#define _XOPEN_SOURCE_EXTENDED 1
Removing the XOPEN definitions fixed my problem.

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!