Undefined reference to glow::Stats()

Ubuntu 16.0.4 version
LLVM 8.0.1
sudo ninja all
[0/1] Re-running CMake…
– Found glog with new-style glog target.
– Found LLVM 8.0.1
– Using LLVMConfig.cmake in: /usr/local/lib/cmake/llvm
Adding CPU backend.
Adding CMakeFiles backend.
Adding Interpreter backend.

– ******** Summary ********
– CMake version : 3.5.1
– CMake command : /usr/bin/cmake
– System : Linux
– C++ compiler : /usr/bin/c++
– C++ compiler version : 5.5.0
– CXX flags : -Wall -Wnon-virtual-dtor -fno-exceptions -fno-rtti -Wno-psabi -Wnon-virtual-dtor
– Build type : Release
– CMAKE_PREFIX_PATH : /usr/bin
– CMAKE_MODULE_PATH : ~glow/cmake/modules

– ONNX version : 1.5.0
– ONNX NAMESPACE : glow_onnx

– Protobuf compiler : /usr/bin/protoc
– Protobuf includes : /usr/include
– Protobuf libraries : optimized;/usr/lib/x86_64-linux-gnu/libprotobuf.so;debug;/usr/lib/x86_64-linux-gnu/libprotobuf.so;-pthread
– Failed to find LLVM FileCheck
– git Version: v1.5.0
– Version: 1.5.0
– Performing Test HAVE_STD_REGEX – success
– Performing Test HAVE_GNU_POSIX_REGEX – failed to compile
– Performing Test HAVE_POSIX_REGEX – success
– Performing Test HAVE_STEADY_CLOCK – success
Skipping adding test en2gr_cpu_test because it requires a models directory. Configure with -DGLOW_MODELS_DIR.
Skipping adding test en2gr_quantization_test because it requires a models directory. Configure with -DGLOW_MODELS_DIR.
Skipping adding test en2gr_cpu_partition_test because it requires a models directory. Configure with -DGLOW_MODELS_DIR.
Skipping adding test en2gr_cpu_config_test because it requires a models directory. Configure with -DGLOW_MODELS_DIR.
Skipping adding test resnet_runtime_test because it requires a models directory. Configure with -DGLOW_MODELS_DIR.
– Configuring done
– Generating done
– Build files have been written to: ~/glow
[1/111] Linking CXX executable bin/resnet-verify
FAILED: bin/resnet-verify
: && /usr/bin/c++ -Wall -Wnon-virtual-dtor -fno-exceptions -fno-rtti -Wno-psabi -O3 -DNDEBUG -march=native -ffast-math -fno-finite-math-only examples/CMakeFiles/resnet-verify.dir/resnet-verify.cpp.o -o bin/resnet-verify lib/ExecutionEngine/libExecutionEngine.a lib/Graph/libGraph.a lib/Importer/libImporter.a lib/Runtime/HostManager/libHostManager.a lib/Partitioner/libPartitioner.a lib/Runtime/Provisioner/libProvisioner.a lib/Runtime/Executor/libExecutor.a lib/Optimizer/GraphOptimizer/libGraphOptimizer.a lib/Backends/libBackends.a lib/Quantization/libQuantization.a lib/Backend/libBackend.a lib/ExecutionContext/libExecutionContext.a lib/CodeGen/libCodeGen.a lib/IR/libIR.a lib/Optimizer/GraphOptimizerPipeline/libGraphOptimizerPipeline.a /usr/local/lib/libLLVMCore.a /usr/local/lib/libLLVMBinaryFormat.a lib/Converter/libConverter.a lib/Graph/libGraph.a lib/Quantization/Base/libQuantizationBase.a lib/Support/TensorPool/libTensorPool.a lib/Base/libBase.a /usr/lib/x86_64-linux-gnu/libpng.so lib/Support/libSupport.a /usr/local/lib/libglog.a /usr/local/lib/libLLVMSupport.a -lz -lrt -ldl -ltinfo -lpthread -lm /usr/local/lib/libLLVMDemangle.a lib/Importer/build_onnx/libonnx_proto.a -pthread /usr/lib/x86_64-linux-gnu/libprotobuf.so && :
lib/Runtime/HostManager/libHostManager.a(HostManager.cpp.o): In function glow::runtime::HostManager::exportMemoryCounters()': HostManager.cpp:(.text+0x601): undefined reference toglow::Stats()’
HostManager.cpp:(.text+0x618): undefined reference to glow::StatsExporterRegistry::setCounter(llvm::StringRef, long)' HostManager.cpp:(.text+0x61d): undefined reference toglow::Stats()’
HostManager.cpp:(.text+0x634): undefined reference to glow::StatsExporterRegistry::setCounter(llvm::StringRef, long)' HostManager.cpp:(.text+0x639): undefined reference toglow::Stats()’
HostManager.cpp:(.text+0x650): undefined reference to glow::StatsExporterRegistry::setCounter(llvm::StringRef, long)' lib/Runtime/HostManager/libHostManager.a(HostManager.cpp.o): In functionglow::runtime::HostManager::clearHost()’:
HostManager.cpp:(.text+0x3521): undefined reference to glow::Stats()' HostManager.cpp:(.text+0x3537): undefined reference toglow::StatsExporterRegistry::setCounter(llvm::StringRef, long)’
HostManager.cpp:(.text+0x353c): undefined reference to glow::Stats()' HostManager.cpp:(.text+0x3552): undefined reference toglow::StatsExporterRegistry::setCounter(llvm::StringRef, long)’
HostManager.cpp:(.text+0x3557): undefined reference to glow::Stats()' HostManager.cpp:(.text+0x356d): undefined reference toglow::StatsExporterRegistry::setCounter(llvm::StringRef, long)’
lib/Base/libBase.a(Image.cpp.o): In function glow::getPngInfo(char const*)': Image.cpp:(.text+0x1b5): undefined reference topng_set_longjmp_fn’
lib/Base/libBase.a(Image.cpp.o): In function glow::writePngImage(glow::Tensor*, char const*, std::pair<float, float>, llvm::ArrayRef<float>, llvm::ArrayRef<float>)': Image.cpp:(.text+0x5e6): undefined reference topng_set_longjmp_fn’
Image.cpp:(.text+0x641): undefined reference to png_set_longjmp_fn' Image.cpp:(.text+0x6c8): undefined reference topng_set_longjmp_fn’
Image.cpp:(.text+0x8a6): undefined reference to png_set_longjmp_fn' lib/Base/libBase.a(Image.cpp.o):Image.cpp:(.text+0xa4f): more undefined references topng_set_longjmp_fn’ follow
collect2: error: ld returned 1 exit status
I am getting this error please help me to fix this!

What’s your CMake command line?

Actually, I think this is a straight-up bug in our CMake. I dunno why it works in CI. https://github.com/pytorch/glow/pull/3517 should fix it.

1 Like
								GLOW INSTALLATION STEPS On Ubuntu (16.04)

Glow Compiler Prerequisites:

	Operating system	:	Ubuntu 16.04LTS

	RAM			:	Minimum 16GB

	SWAP MEMORY		:	Minimum 12GB to 20GB

	Memory Needed		:	70GB

	Total Memory needed 	:	Minimum 150GB(LLVM&GLOW)

Glow Compiler Dependencies:

	LLVM 8.0.1

	Clang 8.0.1

	Anaconda 3
	Pytorch if GPU is used need to install CUDA 10.1 and cuDNN 7.1		

Glow Compiler Process


Download glow repository from git hub

	$git clone https://github.com/pytorch/glow.git

	$cd glow


#Glow depends on a few submodules: googletest, onnx, and a library for FP16 conversions.

#To get them, from the glow directory, run:

	$git submodule update --init --recursive


#If Protobuf is not installed install it by using shell script

#version should be 2.6.1 

#PATH: glow/utils/

#run shell script 



#Create a build directory in glow

	$mkdir build

#Change working directory to build

	$cd build

#Now run cmake in Release mode providing Glow source directory as path

	$cmake -DCMAKE_BUILD_TYPE=Release ../

#This will build files into ......( It will take 4 to 8 hours or more based on RAM and SWAP memory)

#if cmake is not installed install it by running following command

	$sudo apt install cmake


#run make command to compile the source code



#run make install to install the library

	$make install

Testing Glow:

#A few test programs that use Glow's C++ API are found under the examples/ subdirectory. The mnist, cifar10, fr2en and ptb programs train and 	

run digit recognition, image classification and language modeling benchmarks, respectively.

#To run these programs, build Glow in Release mode, then run the following commands to download the cifar10, mnist and ptb databases.

$python ../glow/utils/download_datasets_and_models.py --all-datasets

#Now run the examples. Note that the databases should be in the current working directory.






#If everything goes well you should see:

	mnist: pictures from the mnist digits database
cifar10: image classifications that steadily improve
fr2en: an interactive French-to-English translator
ptb: decreasing perplexity on the dataset as the network trains
char-rnn: generates random text based on some document

These steps worked and installed Glow compiler in my ubuntu system.

Glow Compiler Dependencies:

	LLVM 8.0.1

	Clang 8.0.1

	Anaconda 3
	Pytorch if GPU is used need to install CUDA 10.1 and cuDNN 7.1