> 类似的问题: ```undefined reference to 'pthread_create'``` 需要添加```-lpthread
异常示例2:
1 2 3 4 5
~/workplace/DiMLSys/third_party/root/lib/libdmlc.a(hdfs_filesys.o): In function `dmlc::io::HDFSFileSystem::HDFSFileSystem(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)': hdfs_filesys.cc:(.text+0xb1): undefined reference to `hdfsConnect' ~/workplace/DiMLSys/third_party/root/lib/libdmlc.a(hdfs_filesys.o): In function `dmlc::io::HDFSFileSystem::GetPathInfo(dmlc::io::URI const&)': hdfs_filesys.cc:(.text+0xcd0): undefined reference to `hdfsGetPathInfo' hdfs_filesys.cc:(.text+0x143a): undefined reference to `hdfsFreeFileInfo
编译dmlc-core时,发现是
1
异常示例3:
```c++
undefined reference to `omp_get_num_procs`
3. 检查对应的编译环境是否缺失,比如pthread, OpenMP都需要在g++编译时,添加对应的编译环境。
4. 查看对应的类是否是模版类。如果是模版类,不应该有对应的*.cc文件,因为g++不支持模版类的分离编译;
5. 如果头文件和库文件均存在,可尝试**调整库文件顺序**。
6. 依赖静态库编译失败,依赖动态库编译成功。解决方案:**静态库重新编译,并添加`-shared -fPIC`**。注意:可执行程序不可添加静态库编译选项。
<h2 id="2.error-while-loading-shared-libraries">2. error while loading shared libraries: *.so : cannot open shared object file</h2>
[... error while loading shared libraries: *.so : cannot open shared object file: No such file or directory](http://blog.csdn.net/sahusoft/article/details/7388617)
错误提示程序执行时无法加载共享库```*.so```,可能不存在或者没有找到。
解决方案:
1. 首先,用```locate *.so```命令检查共享库是否存在,如果不存在,需要网上下载和安装。如果存在,进入第二步
2. 将```*.so```所对应的目录加入```LD_LIBRARY_PATH```路径中,举例操作:
```sh
LD_LIBRARY_PATH=${JAVA_HOME}/jre/lib/amd64/servier:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH
上面的配置在MakeFile中可以直接找到对应的环境变量。在CMakeLists中如何使用呢? cmake使用环境变量,需要使用```ENV```关键词。即: ```$ENV{LD_LIBRARY_PATH}
在使用automake编译时,也出现类似的错误:
./openmit: error while loading shared libraries: libprotobuf.so.12: cannot open shared object file: No such file or directory
. automake下的解决方案是?
3. invalid initialization of non-const reference of type
~/workspace/openmit/openmit/include/openmit/data.h:24:41: error: invalid initialization of non-const reference of type ‘std::__cxx11::string& {aka std::__cxx11::basic_string<char>&}’ from an rvalue of type ‘std::__cxx11::string {aka std::__cxx11::basic_string<char>}’ std::string & data_format = "auto") {
CMakeFiles/openmit.dir/worker.cc.o: In function `mit::WorkerParam::__MANAGER__()': worker.cc:(.text+0x176): multiple definition of `mit::WorkerParam::__MANAGER__()' // worker.cc提示多次定义error CMakeFiles/openmit.dir/cli_main.cc.o:cli_main.cc:(.text+0x3b6): first defined here // 最早在cli_main.cc中被定义 collect2: error: ld returned 1 exit status
static B * Get(std::string type, int a) { //return new B(type, a); static B b(type, a); // stack space return & b; } ``` 如果改成下面的实现方式则成功: ```c++ static B * Get(std::string type, int a) { returnnew B(type, a); // heap space //static B b(type, a); //return & b; }
7. as ‘this’ argument discards qualifiers [-fpermissive] …
duplicate symbol __ZN6openmi4zeroE in: /var/folders/5v/rh3q6_sx62998l6x__3_zllr0000gn/T/log_stream_test-4dfdef.o /var/folders/5v/rh3q6_sx62998l6x__3_zllr0000gn/T/log_stream-5415a7.o ld: 1 duplicate symbol for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
openmit-common/tools/logging2.cc:40:23: error: member function 'Length' not viable: 'this' argument has type 'const openmi::LogStream::Buffer' (aka 'const DataBuffer<openmi::kSmallBuffer>'), but function is not marked const output_(buf.Data(), buf.Length());
问题:非const参数 传到了const参数上。
1 2
tensor_shape.cc:59:23: error: member function 'Shape' not viable: 'this' argument has type 'const openmi::TensorShape', but function is not marked const
/Users/zhouyong03/myhome/openmit/openmix/openmit-mix/unittest/core_framework_tensor_test.cc:13:21: error: no matching member function for call to 'TensorType' auto tt = tensor->TensorType<dsize>(); ~~~~~~~~^~~~~~~~~~~~~~~~~ /Users/zhouyong03/myhome/openmit/openmix/openmit-mix/graph_new/core/framework/tensor.h:28:37: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'NDIMS' typename TTypes<T, NDIMS>::Tensor TensorType();
openmi/core/common_runtime/local_device.cc:13:11: error: allocation of incomplete type 'Eigen::ThreadPoolDevice' new Eigen::ThreadPoolDevice( ^~~~~~~~~~~~~~~~~~~~~~~ openmi-base/base/device.h:7:8: note: forward declaration of 'Eigen::ThreadPoolDevice' struct ThreadPoolDevice; ^ openmi/core/common_runtime/local_device.cc:44:43: error: member access into incomplete type 'Eigen::ThreadPoolDevice' SetEigenCpuDevice(tp_info->eigen_device_->get());
23. [
malloc: *** error for object 0x7ff62a6010e8: incorrect checksum for freed object - object was probably modified after being freed.
]
具体错误信息:
1 2
core_framework_executor_test(87702,0x7fff7b20f000) malloc: *** error for object 0x7ff62a6010e8: incorrect checksum for freed object - object was probably modified after being freed. *** set a breakpoint in malloc_error_break to debug
24. [
'operator()' cannot be the name of a variable or data member
]
错误日志与代码
1 2 3 4 5 6 7 8 9
openmi/core/softmax_op.cc:10:17: error: expected ')' voidoperator(Device& d, typename TTypes<T>::ConstMatrix logits, ^ openmi/core/softmax_op.cc:10:16: note: to match this '(' voidoperator(Device& d, typename TTypes<T>::ConstMatrix logits, ^ openmi/core/softmax_op.cc:10:8: error: 'operator()' cannot be the name of a variable or data member voidoperator(Device& d, typename TTypes<T>::ConstMatrix logits, ^
25. [
Assertion failed: (dimensions_match(m_leftImpl.dimensions(), m_rightImpl.dimensions())), function evalSubExprsIfNeeded
]
错误日志与代码:
1
Assertion failed: (dimensions_match(m_leftImpl.dimensions(), m_rightImpl.dimensions())), function evalSubExprsIfNeeded, file /Users/zhouyong03/myhome/openmit/tech-stacks/ml_eigen/third_party/deps/eigen/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorAssign.h, line 122.
1 2
auto d = context->template eigen_device<Device>(); Y.device(d) = X.sum(depth_dim);
==29007== 144 bytes in1 blocks are possibly lost in loss record 5 of 7 ==29007== at 0x4C26E85: malloc (vg_replace_malloc.c:309) ==29007== by 0x4EEE746: __cxa_allocate_exception (in /usr/lib64/libstdc++.so.6.0.13) ==29007== by 0x4E94801: std::__throw_logic_error(char const*) (in /usr/lib64/libstdc++.so.6.0.13) ==29007== by 0x4ECFE58: ??? (in /usr/lib64/libstdc++.so.6.0.13) ==29007== by 0x4ECFF32: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) (in /usr/lib64/libstdc++.so.6.0.13) ==29007== by 0x4059F3: featurex::internal::SystemInfo::Hostname() (logging.cc:357) ==29007== by 0x4068FC: featurex::internal::LogFile::PrettyLogFileName(long*) (logging.cc:540) ==29007== by 0x40637A: featurex::internal::LogFile::RollFile() (logging.cc:494) ==29007== by 0x405ED9: featurex::internal::LogFile::LogFile(char const*, char const*, long, std::string, bool, int, int) (logging.cc:446) ==29007== by 0x40457B: featurex::LogDestination::LogDestination(long, int) (logging.cc:77) ==29007== by 0x404421: featurex::LogDestination::log_destination(int, long) (logging.cc:56) ==29007== by 0x404F5C: featurex::LogMessage::Flush() (logging.cc:208)
定位到获取HostName失败,代码返回NULL所致。错误代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
std::string SystemInfo::Hostname() { if (host_name_.empty()) { char hostname[32]; if (gethostname(hostname,sizeof(hostname)) != 0) { std::runtime_error("get host name error."); printf("[%s:%s:%d] host name get failed.\n", __FILE__, __func__, __LINE__); return NULL; // error code. } std::stringhost_name(hostname); //host_name.pop_back(); // drop '\n' in hostname host_name_ = host_name; } return host_name_; }
==6081== Conditional jump or move depends on uninitialised value(s) ==6081== at 0x1002770E5: featurex::internal::LogFile::WriteUnlocked(char const*, unsigned long) (logging.cc:480) ==6081== by 0x10027552D: featurex::LogMessage::Flush() (logging.cc:470) ==6081== by 0x100275762: featurex::LogMessage::~LogMessage() (logging.cc:151) ==6081== by 0x10026E093: featurex::Combine::InternalRun(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (combine.cc:82) ==6081== by 0x10026E3FE: featurex::Combine::InternalRun(featurex::FeatureValue*, featurex::FeatureValue*) (combine.cc:119) ==6081== by 0x10026D9D3: featurex::Combine::Compute(std::__1::shared_ptr<featurex::InputValue> const&) (combine.cc:62) ==6081== by 0x100264027: featurex::FeatureManager::Compute(std::__1::shared_ptr<featurex::FeatureInfo>&) (feature_manager.cc:251) ==6081== by 0x10026488D: featurex::FeatureManager::ExtractUniqueFeature(std::__1::shared_ptr<featurex::RawFeature> const&, std::__1::shared_ptr<featurex::RawFeature> const&, std::__1::shared_ptr<featurex::proto::FeatureResult>&) (feature_manager.cc:358) ==6081== by 0x100260010: featurex::FeatureExtractor::ExtractUniqueFeature() (feature_extractor.cc:263) ==6081== by 0x100260C62: featurex::FeatureExtractor::Extract(featurex::proto::RawFeature&) (feature_extractor.cc:349) ==6081== by 0x100002943: main (feature_extractor_valgrind_test.cc:61) ==6081== Uninitialised value was created by a heap allocation ==6081== at 0x10023FD11: malloc (vg_replace_malloc.c:302) ==6081== by 0x1006887DD: operator new(unsigned long) (in /usr/lib/libc++.1.dylib) ==6081== by 0x100274968: featurex::LogDestination::LogDestination(long long, int) (logging.cc:73) ==6081== by 0x1002754CE: featurex::LogMessage::Flush() (logging.cc:71) ==6081== by 0x100275762: featurex::LogMessage::~LogMessage() (logging.cc:151) ==6081== by 0x100259077: featurex::FeatureConf::LoadConf(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (feature_conf.cc:24) ==6081== by 0x10025EE1C: featurex::FeatureExtractor::Init(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) (feature_extractor.cc:84) ==6081== by 0x1000025EA: main (feature_extractor_valgrind_test.cc:28)
报
Uninitialised value was created by a heap allocation
/
Conditional jump or move depends on uninitialised value(s)
这类错误,表示有些变量未初始化。
Failed toread a valid object file image from memory. Core was generated by `/usr/local/java8/bin/java -server -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-'. Program terminated with signal 6, Aborted. #0 0x00007f1083a234f5 in ?? () (gdb) bt #0 0x00007f1083a234f5 in ?? () Cannot access memory at address 0x7f0ca4de1d08
Loaded symbols for /usr/local/jdk1.8.0_45/jre/lib/amd64/libawt.so Reading symbols from /usr/local/jdk1.8.0_45/jre/lib/amd64/libawt_headless.so...(no debugging symbols found)...done. Loaded symbols for /usr/local/jdk1.8.0_45/jre/lib/amd64/libawt_headless.so Reading symbols from /tmp/libidxdb-jni-c.so4690097535416358788...done. Loaded symbols for /tmp/libidxdb-jni-c.so4690097535416358788 Reading symbols from /opt/meituan/mobile/adsms/webroot/WEB-INF/classes/libgomp.so.1...done. Loaded symbols for /opt/meituan/mobile/adsms/webroot/WEB-INF/classes/libgomp.so.1 Reading symbols from /opt/meituan/mobile/adsms/webroot/WEB-INF/classes/libfeaturex.so...done. Loaded symbols for /opt/meituan/mobile/adsms/webroot/WEB-INF/classes/libfeaturex.so Core was generated by `/usr/local/java8/bin/java -server -Dfile.encoding=UTF-8 -Dsun.jnu.encoding=UTF-'. Program terminated with signal 6, Aborted. #0 0x00007f64168364f5 in raise () from /lib64/libc.so.6 Missing separate debuginfos, use: debuginfo-install glibc-2.12-1.212.el6_10.3.x86_64 jdk-1.8.0-45.x86_64 keyutils-libs-1.4-5.el6.x86_64 krb5-libs-1.10.3-37.el6_6.x86_64 libcom_err-1.41.12-21.el6.x86_64 libgcc-4.4.7-23.el6.x86_64 libselinux-2.0.94-5.8.el6.x86_64 libstdc++-4.4.7-23.el6.x86_64 openssl-1.0.1e-57.el6.x86_64 zlib-1.2.3-29.el6.x86_64 (gdb) bt #0 0x00007f64168364f5 in raise () from /lib64/libc.so.6 #1 0x00007f6416837cd5 in abort () from /lib64/libc.so.6 #2 0x00007f641614b6b5 in os::abort(bool) () from /usr/local/jdk1.8.0_45/jre/lib/amd64/server/libjvm.so #3 0x00007f64162e8da3 in VMError::report_and_die() () from /usr/local/jdk1.8.0_45/jre/lib/amd64/server/libjvm.so #4 0x00007f6416150bdf in JVM_handle_linux_signal () from /usr/local/jdk1.8.0_45/jre/lib/amd64/server/libjvm.so #5 0x00007f6416147493 in signalHandler(int, siginfo*, void*) () from /usr/local/jdk1.8.0_45/jre/lib/amd64/server/libjvm.so #6 <signal handler called> #7 0x00007f6416fbd64f in pthread_cond_wait@@GLIBC_2.3.2 () from /lib64/libpthread.so.0 #8 0x00007f61d85c32fc in std::condition_variable::wait(std::unique_lock<std::mutex>&) () from /usr/lib64/libstdc++.so.6 #9 0x00007f6049efde6b in wait<featurex::FeatureExtractor::ClearProtoObject()::<lambda()> > (this=0x7f62a6fe4980) at /opt/rh/devtoolset-3/root/usr/include/c++/4.9.2/condition_variable:98 #10 featurex::FeatureExtractor::ClearProtoObject (this=0x7f62a6fe4980) at /opt/meituan/zhouyong03/featurex/featurex/feature/feature_extractor.cc:575 #11 0x00007f61d85c3470 in ?? () from /usr/lib64/libstdc++.so.6 #12 0x00007f6416fb9aa1 in start_thread () from /lib64/libpthread.so.0 #13 0x00007f64168ecc4d in clone () from /lib64/libc.so.6
~/.openmi_deps/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h:39:7: error: class template partial specialization is not more specialized than the primary template [-Winvalid-partial-specialization] class TensorStorage<T, FixedDimensions, Options_> ^ ~/.openmi_deps/include/eigen3/unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h:34:63: note: template is declared here template<typename T, typename Dimensions, int Options_> class TensorStorage;
原因:mac升级至10.15,更高版本的clang对模版检查更智能。
1 2 3 4
将unsupported/Eigen/CXX11/src/Tensor/TensorStorage.h中的 template<typename T, typename Dimensions, int Options_, > class TensorStorage; 替换为 template<typename T, typename Dimensions, int Options_, typename empty = void> class TensorStorage;
This is acolon separated list ofdirectories that contain libraries. The dynamic linker searches these directoriesbeforeit searches the default locations for libraries. It allows you to test new versions of existing libraries. For each library that a program uses, the dynamic linker looks foritineachdirectoryin DYLD_LIBRARY_PATH in turn. If it still can't find the library, it then searches BACK_FRAMEWORK_PATH and DYLD_FALLBACK_LIBRARY_PATH in turn.