caffe - libcaffe error in cpp eclipse -
i want use cpp read leveldb features extracted caffe. use following code in eclipse:
// copyright 2014 bvlc , contributors. #include <glog/logging.h> #include <stdio.h> // snprintf #include <google/protobuf/text_format.h> #include <leveldb/db.h> #include <leveldb/write_batch.h> #include <string> #include <vector> #include <cassert> #include <iostream> #include <map> //#include "cpp/sample.pb.h" #include "caffe/proto/caffe.pb.h" // for: datum using namespace caffe; #define number_features_per_image 16 using namespace std; int main(int argc, char** argv) { //google::initgooglelogging(argv[0]); if (argc < 2) { printf("error! not enough arguments!\nusage: %s <feature_folder>", argv[0]); exit(1); } log(info) << "creating leveldb object\n"; leveldb::db* db; leveldb::options options; options.create_if_missing = true; leveldb::status status = leveldb::db::open(options, argv[1], &db); assert(status.ok()); leveldb::iterator* = db->newiterator(leveldb::readoptions()); int = 0; double count = 0.0f; (it->seektofirst(); it->valid(); it->next()) { datum d; d.clear_float_data(); d.clear_data(); d.parsefromstring(it->value().tostring()); (int j = 0; j < d.height(); ++j) count += d.float_data(j); i++; } assert(it->status().ok()); log(info) << "number of datums (or feature vectors): " << << "\n";; log(info) << "reduction of vectors scalar value: " << count << "\n"; delete it; }
it builds without error,but when running says: /home/deep/cuda-workspace/readleveldb/debug/readleveldb: error while loading shared libraries: libcaffe.so.1.0.0-rc3: cannot open shared object file: no such file or directory
what problem ?
you program fail find *.so. there 3 method:
- create links of *.so in /usr/lib:
ln -s /where/you/install/lib/*.so /usr/lib
sudo ldconfig
- modify ld_library_path:
export ld_library_path=/where/you/install/lib:$ld_library_path
sudo ldconfig
- modify /etc/ld.so.conf:
vim /etc/ld.so.conf
add /where/you/install/lib
sudo ldconfig
Comments
Post a Comment