gpt4 book ai didi

c++ - 如何在linux下基于caffe编译cpp

转载 作者:太空宇宙 更新时间:2023-11-04 05:51:15 26 4
gpt4 key购买 nike

我得到了一个关于 Visualize-features 函数的 cpp。我想编译它,但有一些错误。我将 Visualize_features.cpp 移动到 CAFFE_ROOT/build/tools/并使用以下命令:外壳命令:

    g++ -v visualize_features.cpp -o visualize_features

visualize_feature.cpp:

    // Copyright 2013 Yangqing Jia
//
// This is a simple script that allows one to quickly test a network whose
// structure is specified by text format protocol buffers, and whose parameter
// are loaded from a pre-trained network.
// Usage:
// test_net net_proto pretrained_net_proto iterations [CPU/GPU]

#include <cuda_runtime.h>
#include <fstream>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <utility>
#include "caffe/caffe.hpp"
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/highgui/highgui_c.h>
#include <opencv2/imgproc/imgproc.hpp>

using std::make_pair;
using std::pair;
using namespace caffe; // NOLINT(build/namespaces)
using namespace std;

vector<string> fileNames;
char * filelist;

/*
* 读入的文件的内容格式类似这样子的:全局id 类名_所在类的id.jpg
0 一步裙_0.jpg
1 一步裙_1.jpg
2 一步裙_10.jpg

*/
void readFile()
{
if(fileNames.empty())
{
ifstream read(filelist);
//"/home/linger/linger/testfile/test_attachment/image_filename"
// "/home/linger/imdata/test_files_collar.txt"
// "/home/linger/linger/testfile/testfilename"
if(read.is_open())
{
while(!read.eof())
{
string name;
int id;
read>>id>>name;
fileNames.push_back(name);
}
}
}
}

/*
* 根据图片id获取类名
*/
string getClassNameById(int id)
{
readFile();
int index = fileNames[id].find_last_of('_') ;
return fileNames[id].substr(0, index);
}



void writeBatch(const float* data,int num,int channels,int width,int height,int startID,const char*dir)
{
for(int id = 0;id<num;id++)
{
for(int channel=0;channel<channels;channel++)
{
cv::Mat mat(height,width, CV_8UC1);//高宽
vector<vector<float> > vec;
vec.resize(height);
float max = -1;
float min = 999999;
for(int row=0;row<height;row++)
{
vec[row].resize(width);
for(int col=0;col<width;col++)
{
vec[row][col] =
data[id*channels*width*height+channel*width*height+row*width+col];
if(max<vec[row][col])
{
max = vec[row][col];
}
if(min>vec[row][col])
{
min = vec[row][col];
}


}
}

for(int row=0;row<height;row++)
{
for(int col=0;col<width;col++)
{
vec[row][col] = 255*((float)(vec[row][col]-min))/(max-min);
uchar& img = mat.at<uchar>(row,col);
img= vec[row][col];

}
}
char filename[100];
string label = getClassNameById(startID+id);
string file_reg =dir;
file_reg+="%s%05d_%05d.png";
snprintf(filename, 100, file_reg.c_str(), label.c_str(),startID+id,channel);
//printf("%s\n",filename);
cv::imwrite(filename, mat);
}

}
}

int main(int argc, char** argv)
{
if (argc < 4)
{
LOG(ERROR) << "visualize_features.bin net_proto pretrained_net_proto iterations "
<< "[CPU/GPU] img_list_file dstdir laydepth";
return 0;
}
/*

//visualize_features.bin /home/linger/linger/caffe-action/caffee-ext/Caffe_MM/prototxt/triplet/triplet_test_simple.prototxt /home/linger/linger/caffe-action/caffee-ext/Caffe_MM/snapshorts/_iter_100000 8 GPU /home/linger/linger/testfile/test_attachment/image_filename /home/linger/linger/testfile/innerproduct/ 6

*/

filelist = argv[5];
cudaSetDevice(0);
//Caffe::set_phase(Caffe::TEST);
//Phase phase = TEST;
if (argc == 5 && strcmp(argv[4], "GPU") == 0)
{
LOG(ERROR) << "Using GPU";
Caffe::set_mode(Caffe::GPU);
}
else
{
LOG(ERROR) << "Using CPU";
Caffe::set_mode(Caffe::CPU);
}

NetParameter test_net_param;
ReadProtoFromTextFile(argv[1], &test_net_param);
//Net<float> caffe_test_net(&test_net_param,TEST);
shared_ptr<Net<float> > caffe_test_net;
caffe_test_net.reset(new Net<float>(argv[1],TEST));
NetParameter trained_net_param;
ReadProtoFromBinaryFile(argv[2], &trained_net_param);
caffe_test_net->CopyTrainedLayersFrom(argv[2]);

int total_iter = atoi(argv[3]);
LOG(ERROR) << "Running " << total_iter << " Iterations.";

double test_accuracy = 0;
vector<Blob<float>*> dummy_blob_input_vec;

int startID = 0;
int nums;
int dims;
int batchsize = test_net_param.layers(0).layer().batchsize();

int laynum = caffe_test_net->bottom_vecs().size();
printf("num of layers:%d\n",laynum);

for (int i = 0; i < total_iter; ++i)
{
const vector<Blob<float>*>& result =
caffe_test_net->Forward(dummy_blob_input_vec);

int laydepth = atoi(argv[7]);

Blob<float>* features = (*(caffe_test_net->bottom_vecs().begin()+laydepth))[0];//调整第几层即可

nums = features->num();
dims= features->count()/features->num();

int num = features->num();
int channels = features->channels();
int width = features->width();
int height = features->height();
printf("channels:%d,width:%d,height:%d\n",channels,width,height);
writeBatch(features->cpu_data(),num,channels,width,height,startID,argv[6]);
startID += nums;

}

return 0;
}

错误:

weilam@linux:~/soft/caffe-master/tools$ g++ -v visualize_features.cpp -o visualize_features
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1~14.04.1' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudflap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.8-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.8-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.1)
COLLECT_GCC_OPTIONS='-v' '-o' 'visualize_features' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-linux-gnu/4.8/cc1plus -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE visualize_features.cpp -quiet -dumpbase visualize_features.cpp -mtune=generic -march=x86-64 -auxbase visualize_features -version -fstack-protector -Wformat -Wformat-security -o /tmp/ccDLiCXS.s
GNU C++ (Ubuntu 4.8.4-2ubuntu1~14.04.1) version 4.8.4 (x86_64-linux-gnu)
compiled by GNU C version 4.8.4, GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/4.8"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../x86_64-linux-gnu/include"
ignoring duplicate directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/include
/home/weilam/soft/caffe-master/include
/home/weilam/soft/caffe-master/distribute/include
/usr/local/cuda/include
.
/usr/include/c++/4.8
/usr/include/x86_64-linux-gnu/c++/4.8
/usr/include/c++/4.8/backward
/usr/lib/gcc/x86_64-linux-gnu/4.8/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
/usr/include/x86_64-linux-gnu
End of search list.
GNU C++ (Ubuntu 4.8.4-2ubuntu1~14.04.1) version 4.8.4 (x86_64-linux-gnu)
compiled by GNU C version 4.8.4, GMP version 5.1.3, MPFR version 3.1.2-p3, MPC version 1.0.1
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 83f8d9bb238019ed17000f1b7e141e5a
COLLECT_GCC_OPTIONS='-v' '-o' 'visualize_features' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
as -v --64 -o /tmp/cctbPuju.o /tmp/ccDLiCXS.s
GNU assembler version 2.24 (x86_64-linux-gnu) using BFD version (GNU Binutils for Ubuntu) 2.24
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.8/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-o' 'visualize_features' '-shared-libgcc' '-mtune=generic' '-march=x86-64'
/usr/lib/gcc/x86_64-linux-gnu/4.8/collect2 --sysroot=/ --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro -o visualize_features /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.8/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.8 -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../lib -L/lib/x86_64-linux-gnu -L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.8/../../.. /tmp/cctbPuju.o -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.8/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/crtn.o
/tmp/cctbPuju.o: In function `writeBatch(float const*, int, int, int, int, int, char const*)':
visualize_features.cpp:(.text+0x6d8): undefined reference to `cv::_InputArray::_InputArray(cv::Mat const&)'
visualize_features.cpp:(.text+0x724): undefined reference to `cv::imwrite(std::string const&, cv::_InputArray const&, std::vector<int, std::allocator<int> > const&)'
/tmp/cctbPuju.o: In function `main':
visualize_features.cpp:(.text+0x8e7): undefined reference to `google::LogMessage::LogMessage(char const*, int, int)'
visualize_features.cpp:(.text+0x8f6): undefined reference to `google::LogMessage::stream()'
visualize_features.cpp:(.text+0x91f): undefined reference to `google::LogMessage::~LogMessage()'
visualize_features.cpp:(.text+0x945): undefined reference to `cudaSetDevice'
visualize_features.cpp:(.text+0x98b): undefined reference to `google::LogMessage::LogMessage(char const*, int, int)'
visualize_features.cpp:(.text+0x99a): undefined reference to `google::LogMessage::stream()'
visualize_features.cpp:(.text+0x9b6): undefined reference to `google::LogMessage::~LogMessage()'
visualize_features.cpp:(.text+0x9e0): undefined reference to `google::LogMessage::LogMessage(char const*, int, int)'
visualize_features.cpp:(.text+0x9ef): undefined reference to `google::LogMessage::stream()'
visualize_features.cpp:(.text+0xa0b): undefined reference to `google::LogMessage::~LogMessage()'
visualize_features.cpp:(.text+0xa24): undefined reference to `caffe::NetParameter::NetParameter()'
visualize_features.cpp:(.text+0xa44): undefined reference to `caffe::ReadProtoFromTextFile(char const*, google::protobuf::Message*)'
visualize_features.cpp:(.text+0xab2): undefined reference to `caffe::Net<float>::Net(std::string const&, caffe::Phase, caffe::Net<float> const*)'
visualize_features.cpp:(.text+0xaf1): undefined reference to `caffe::NetParameter::NetParameter()'
visualize_features.cpp:(.text+0xb11): undefined reference to `caffe::ReadProtoFromBinaryFile(char const*, google::protobuf::Message*)'
visualize_features.cpp:(.text+0xb68): undefined reference to `caffe::Net<float>::CopyTrainedLayersFrom(std::string)'
visualize_features.cpp:(.text+0xbc0): undefined reference to `google::LogMessage::LogMessage(char const*, int, int)'
visualize_features.cpp:(.text+0xbcf): undefined reference to `google::LogMessage::stream()'
visualize_features.cpp:(.text+0xc08): undefined reference to `google::LogMessage::~LogMessage()'
visualize_features.cpp:(.text+0xcc8): undefined reference to `caffe::Net<float>::Forward(std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> > const&, float*)'
visualize_features.cpp:(.text+0xe3c): undefined reference to `caffe::Blob<float>::cpu_data() const'
visualize_features.cpp:(.text+0xeb5): undefined reference to `caffe::NetParameter::~NetParameter()'
visualize_features.cpp:(.text+0xed3): undefined reference to `caffe::NetParameter::~NetParameter()'
visualize_features.cpp:(.text+0xeec): undefined reference to `google::LogMessage::~LogMessage()'
visualize_features.cpp:(.text+0xf09): undefined reference to `google::LogMessage::~LogMessage()'
visualize_features.cpp:(.text+0xf26): undefined reference to `google::LogMessage::~LogMessage()'
visualize_features.cpp:(.text+0xfa3): undefined reference to `google::LogMessage::~LogMessage()'
visualize_features.cpp:(.text+0xfcb): undefined reference to `caffe::NetParameter::~NetParameter()'
visualize_features.cpp:(.text+0xff3): undefined reference to `caffe::NetParameter::~NetParameter()'
/tmp/cctbPuju.o: In function `__static_initialization_and_destruction_0(int, int)':
visualize_features.cpp:(.text+0x104a): undefined reference to `boost::system::generic_category()'
visualize_features.cpp:(.text+0x1056): undefined reference to `boost::system::generic_category()'
visualize_features.cpp:(.text+0x1062): undefined reference to `boost::system::system_category()'
/tmp/cctbPuju.o: In function `caffe::Caffe::set_mode(caffe::Caffe::Brew)':
visualize_features.cpp:(.text._ZN5caffe5Caffe8set_modeENS0_4BrewE[_ZN5caffe5Caffe8set_modeENS0_4BrewE]+0xc): undefined reference to `caffe::Caffe::Get()'
/tmp/cctbPuju.o: In function `caffe::V1LayerParameter::layer() const':
visualize_features.cpp:(.text._ZNK5caffe16V1LayerParameter5layerEv[_ZNK5caffe16V1LayerParameter5layerEv]+0x28): undefined reference to `caffe::V1LayerParameter::default_instance_'
/tmp/cctbPuju.o: In function `cv::Mat::~Mat()':
visualize_features.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to `cv::fastFree(void*)'
/tmp/cctbPuju.o: In function `cv::Mat::create(int, int, int)':
visualize_features.cpp:(.text._ZN2cv3Mat6createEiii[_ZN2cv3Mat6createEiii]+0x8e): undefined reference to `cv::Mat::create(int, int const*, int)'
/tmp/cctbPuju.o: In function `cv::Mat::release()':
visualize_features.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x47): undefined reference to `cv::Mat::deallocate()'
/tmp/cctbPuju.o: In function `std::string* google::MakeCheckOpString<int, int>(int const&, int const&, char const*)':
visualize_features.cpp:(.text._ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc]+0x24): undefined reference to `google::base::CheckOpMessageBuilder::CheckOpMessageBuilder(char const*)'
visualize_features.cpp:(.text._ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc]+0x4b): undefined reference to `google::base::CheckOpMessageBuilder::ForVar2()'
visualize_features.cpp:(.text._ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc]+0x66): undefined reference to `google::base::CheckOpMessageBuilder::NewString()'
visualize_features.cpp:(.text._ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc]+0x75): undefined reference to `google::base::CheckOpMessageBuilder::~CheckOpMessageBuilder()'
visualize_features.cpp:(.text._ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc[_ZN6google17MakeCheckOpStringIiiEEPSsRKT_RKT0_PKc]+0x89): undefined reference to `google::base::CheckOpMessageBuilder::~CheckOpMessageBuilder()'
/tmp/cctbPuju.o: In function `google::protobuf::RepeatedPtrField<caffe::V1LayerParameter>::TypeHandler::Type const& google::protobuf::internal::RepeatedPtrFieldBase::Get<google::protobuf::RepeatedPtrField<caffe::V1LayerParameter>::TypeHandler>(int) const':
visualize_features.cpp:(.text._ZNK6google8protobuf8internal20RepeatedPtrFieldBase3GetINS0_16RepeatedPtrFieldIN5caffe16V1LayerParameterEE11TypeHandlerEEERKNT_4TypeEi[_ZNK6google8protobuf8internal20RepeatedPtrFieldBase3GetINS0_16RepeatedPtrFieldIN5caffe16V1LayerParameterEE11TypeHandlerEEERKNT_4TypeEi]+0x45): undefined reference to `google::protobuf::internal::LogMessage::LogMessage(google::protobuf::LogLevel, char const*, int)'
visualize_features.cpp:(.text._ZNK6google8protobuf8internal20RepeatedPtrFieldBase3GetINS0_16RepeatedPtrFieldIN5caffe16V1LayerParameterEE11TypeHandlerEEERKNT_4TypeEi[_ZNK6google8protobuf8internal20RepeatedPtrFieldBase3GetINS0_16RepeatedPtrFieldIN5caffe16V1LayerParameterEE11TypeHandlerEEERKNT_4TypeEi]+0x5b): undefined reference to `google::protobuf::internal::LogMessage::operator<<(char const*)'
visualize_features.cpp:(.text._ZNK6google8protobuf8internal20RepeatedPtrFieldBase3GetINS0_16RepeatedPtrFieldIN5caffe16V1LayerParameterEE11TypeHandlerEEERKNT_4TypeEi[_ZNK6google8protobuf8internal20RepeatedPtrFieldBase3GetINS0_16RepeatedPtrFieldIN5caffe16V1LayerParameterEE11TypeHandlerEEERKNT_4TypeEi]+0x73): undefined reference to `google::protobuf::internal::LogFinisher::operator=(google::protobuf::internal::LogMessage&)'
visualize_features.cpp:(.text._ZNK6google8protobuf8internal20RepeatedPtrFieldBase3GetINS0_16RepeatedPtrFieldIN5caffe16V1LayerParameterEE11TypeHandlerEEERKNT_4TypeEi[_ZNK6google8protobuf8internal20RepeatedPtrFieldBase3GetINS0_16RepeatedPtrFieldIN5caffe16V1LayerParameterEE11TypeHandlerEEERKNT_4TypeEi]+0x87): undefined reference to `google::protobuf::internal::LogMessage::~LogMessage()'
visualize_features.cpp:(.text._ZNK6google8protobuf8internal20RepeatedPtrFieldBase3GetINS0_16RepeatedPtrFieldIN5caffe16V1LayerParameterEE11TypeHandlerEEERKNT_4TypeEi[_ZNK6google8protobuf8internal20RepeatedPtrFieldBase3GetINS0_16RepeatedPtrFieldIN5caffe16V1LayerParameterEE11TypeHandlerEEERKNT_4TypeEi]+0xc2): undefined reference to `google::protobuf::internal::LogMessage::~LogMessage()'
/tmp/cctbPuju.o: In function `caffe::Blob<float>::LegacyShape(int) const':
visualize_features.cpp:(.text._ZNK5caffe4BlobIfE11LegacyShapeEi[_ZNK5caffe4BlobIfE11LegacyShapeEi]+0x74): undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int, google::CheckOpString const&)'
visualize_features.cpp:(.text._ZNK5caffe4BlobIfE11LegacyShapeEi[_ZNK5caffe4BlobIfE11LegacyShapeEi]+0x80): undefined reference to `google::LogMessage::stream()'
visualize_features.cpp:(.text._ZNK5caffe4BlobIfE11LegacyShapeEi[_ZNK5caffe4BlobIfE11LegacyShapeEi]+0x99): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
visualize_features.cpp:(.text._ZNK5caffe4BlobIfE11LegacyShapeEi[_ZNK5caffe4BlobIfE11LegacyShapeEi]+0xf8): undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int, google::CheckOpString const&)'
visualize_features.cpp:(.text._ZNK5caffe4BlobIfE11LegacyShapeEi[_ZNK5caffe4BlobIfE11LegacyShapeEi]+0x104): undefined reference to `google::LogMessage::stream()'
visualize_features.cpp:(.text._ZNK5caffe4BlobIfE11LegacyShapeEi[_ZNK5caffe4BlobIfE11LegacyShapeEi]+0x110): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
visualize_features.cpp:(.text._ZNK5caffe4BlobIfE11LegacyShapeEi[_ZNK5caffe4BlobIfE11LegacyShapeEi]+0x16f): undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int, google::CheckOpString const&)'
visualize_features.cpp:(.text._ZNK5caffe4BlobIfE11LegacyShapeEi[_ZNK5caffe4BlobIfE11LegacyShapeEi]+0x17b): undefined reference to `google::LogMessage::stream()'
visualize_features.cpp:(.text._ZNK5caffe4BlobIfE11LegacyShapeEi[_ZNK5caffe4BlobIfE11LegacyShapeEi]+0x187): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
visualize_features.cpp:(.text._ZNK5caffe4BlobIfE11LegacyShapeEi[_ZNK5caffe4BlobIfE11LegacyShapeEi]+0x1e1): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
visualize_features.cpp:(.text._ZNK5caffe4BlobIfE11LegacyShapeEi[_ZNK5caffe4BlobIfE11LegacyShapeEi]+0x1ed): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
visualize_features.cpp:(.text._ZNK5caffe4BlobIfE11LegacyShapeEi[_ZNK5caffe4BlobIfE11LegacyShapeEi]+0x1f9): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
/tmp/cctbPuju.o: In function `caffe::Blob<float>::CanonicalAxisIndex(int) const':
visualize_features.cpp:(.text._ZNK5caffe4BlobIfE18CanonicalAxisIndexEi[_ZNK5caffe4BlobIfE18CanonicalAxisIndexEi]+0x9b): undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int, google::CheckOpString const&)'
visualize_features.cpp:(.text._ZNK5caffe4BlobIfE18CanonicalAxisIndexEi[_ZNK5caffe4BlobIfE18CanonicalAxisIndexEi]+0xa7): undefined reference to `google::LogMessage::stream()'
visualize_features.cpp:(.text._ZNK5caffe4BlobIfE18CanonicalAxisIndexEi[_ZNK5caffe4BlobIfE18CanonicalAxisIndexEi]+0x100): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
visualize_features.cpp:(.text._ZNK5caffe4BlobIfE18CanonicalAxisIndexEi[_ZNK5caffe4BlobIfE18CanonicalAxisIndexEi]+0x18d): undefined reference to `google::LogMessageFatal::LogMessageFatal(char const*, int, google::CheckOpString const&)'
visualize_features.cpp:(.text._ZNK5caffe4BlobIfE18CanonicalAxisIndexEi[_ZNK5caffe4BlobIfE18CanonicalAxisIndexEi]+0x199): undefined reference to `google::LogMessage::stream()'
visualize_features.cpp:(.text._ZNK5caffe4BlobIfE18CanonicalAxisIndexEi[_ZNK5caffe4BlobIfE18CanonicalAxisIndexEi]+0x1f2): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
visualize_features.cpp:(.text._ZNK5caffe4BlobIfE18CanonicalAxisIndexEi[_ZNK5caffe4BlobIfE18CanonicalAxisIndexEi]+0x21c): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
visualize_features.cpp:(.text._ZNK5caffe4BlobIfE18CanonicalAxisIndexEi[_ZNK5caffe4BlobIfE18CanonicalAxisIndexEi]+0x242): undefined reference to `google::LogMessageFatal::~LogMessageFatal()'
collect2: error: ld returned 1 exit status

part of errors

最佳答案

由于您的源代码存在于 caffe-mastertools 文件夹中,因此您可以通过执行 caffe 的常规 make 命令来创建可执行文件,并且名为 visualize_features.bin 的可执行文件应存在于 build/tools 文件夹中。这对您来说是最简单的方法。

您当前使用的构建命令非常不完整,没有提到各种依赖项的包含文件夹和各种库的路径。我认为您必须学习如何编写 Makefile

关于c++ - 如何在linux下基于caffe编译cpp,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36821271/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com