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=""
Related
I am getting the following error while building aquasim
In file included from ./ns3/object-base.h:23:0,
from ./ns3/object.h:29,
from ./ns3/energy-source.h:30,
from ../src/aqua-sim-ng/model/aqua-sim-energy-model.cc:21:
./ns3/type-id.h: In instantiation of ‘static ns3::ObjectBase* ns3::TypeId::AddConstructor()::Maker::Create() [with T = ns3::AquaSimEnergyModel]’:
./ns3/type-id.h:659:3: required from ‘ns3::TypeId ns3::TypeId::AddConstructor() [with T = ns3::AquaSimEnergyModel]’
../src/aqua-sim-ng/model/aqua-sim-energy-model.cc:42:42: required from here
./ns3/type-id.h:656:27: error: invalid new-expression of abstract class type ‘ns3::AquaSimEnergyModel’
ObjectBase * base = new T ();
^~~~~~~~
In file included from ../src/aqua-sim-ng/model/aqua-sim-energy-model.cc:26:0:
../src/aqua-sim-ng/model/aqua-sim-energy-model.h:45:7: note: because the following virtual functions are pure within ‘ns3::AquaSimEnergyModel’:
class AquaSimEnergyModel : public DeviceEnergyModel
^~~~~~~~~~~~~~~~~~
In file included from ./ns3/device-energy-model-container.h:26:0,
from ./ns3/energy-source.h:34,
from ../src/aqua-sim-ng/model/aqua-sim-energy-model.cc:21:
./ns3/device-energy-model.h:106:16: note: virtual void ns3::DeviceEnergyModel::HandleEnergyChanged()
virtual void HandleEnergyChanged (void) = 0;
^~~~~~~~~~~~~~~~~~~
Waf: Leaving directory `/home/udit/ns-allinone-3.30.1/ns-3.30.1/build'
Build failed
-> task in 'ns3-aqua-sim-ng' failed with exit status 1 (run with -v to display more information)
try to build ns3 according to this, https://www.nsnam.org/wiki/HOWTO_build_old_versions_of_ns-3_on_newer_compilers
or please provide more details of your NS3 version and GCC compiler.
I am trying to create a class which calls one of it's functions when created, but I am getting the following error when compiling:
g++ -std=c++11 -Wall -Wextra -Werror -pedantic-errors -DNDEBUG -c src/PuzzleSolution.cpp
src/PuzzleSolution.cpp:7:32: error: definition of implicitly-declared 'PuzzleSolution::PuzzleSolution()'
PuzzleSolution::PuzzleSolution()
^
src/PuzzleSolution.cpp:12:6: error: prototype for 'void PuzzleSolution::addRow()' does not match any in class 'PuzzleSolution'
void PuzzleSolution::addRow()
^
src/PuzzleSolution.h:19:10: error: candidate is: void PuzzleSolution::addRow(std::vector<unsigned int>&)
explicit PuzzleSolution();
^
src/PuzzleSolution.cpp:17:48: error: no 'void PuzzleSolution::addElement(unsigned int)' member function declared in class 'PuzzleSolution'
void PuzzleSolution::addElement(unsigned int id)
^
make: *** [PuzzleSolution.o] Error 1
Here is the header:
#include <vector>
using namespace std;
class PuzzleSolution {
private:
vector<vector<unsigned int>> sol;
public:
explicit PuzzleSolution();
void addRow();
};
Here is the cpp file:
#include "PuzzleSolution.h"
PuzzleSolution::PuzzleSolution()
{
addRow();
}
void PuzzleSolution::addRow()
{
this->sol.emplace_back();
}
What am I doing wrong?
The code as it is has no error. It compiles with GCC 4.8.2
Be sure that your header file is indeed what you have linked to. Most likely the header being included is different than the one you have actually posted here.
Side Note: Generally it is considered as a bad practice to put using namespace std; in a header file.
Found the issue:
There was a file in the src folder called PuzzleSolution.h.gch
#Quatin and #StoryTeller helped me to understand that this is a pre-compiled header, which the compiler kept using.
Once deleted, the project compiled and executed
I am not able to build RAFT implementation of LogCabin (C++) using scons and protobuf3 in Ubuntu.
Errors be like
usr/local/include/google/protobuf/repeated_field.h: In member function ‘int google::protobuf::RepeatedPtrField<Element>::SpaceUsedExcludingSelf() const’:
/usr/local/include/google/protobuf/repeated_field.h:888:12: error: ‘ToIntSize’ is not a member of ‘google::protobuf::internal’
return internal::ToIntSize(SpaceUsedExcludingSelfLong());
^
In file included from /usr/local/include/google/protobuf/map.h:48:0,from /usr/local/include/google/protobuf/generated_message_table_driven.h:34, from ./build/Protocol/ServerStats.pb.h:25, from build/Tree/Tree.cc:19:
/usr/local/include/google/protobuf/map_type_handler.h: In static member function ‘static void google::protobuf::internal::MapTypeHandler<(google::protobuf::internal::WireFormatLite::FieldType)9u, Type>::Clear(google::protobuf::internal::MapTypeHandler<(google::protobuf::internal::WireFormatLite::FieldType)9u, Type>::TypeOnMemory*, google::protobuf::Arena*)’:
/usr/local/include/google/protobuf/map_type_handler.h:638:1: error: ‘GetEmptyStringAlreadyInited’ is not a member of ‘google::protobuf::internal’
STRING_OR_BYTES_HANDLER_FUNCTIONS(STRING)
Please suggest how do I proceed.!
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.
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"
...