Undefined reference to glow::Stats()

username: ponnam_sairam
cooked: <h2>Ubuntu 16.0.4 version<br>
LLVM 8.0.1<br>
CLANG 8<br>
sudo ninja all<br>
[0/1] Re-running CMake…<br>
– Found glog with new-style glog target.<br>
– Found LLVM 8.0.1<br>
– Using LLVMConfig.cmake in: /usr/local/lib/cmake/llvm<br>
Adding CPU backend.<br>
Adding CMakeFiles backend.<br>
Adding Interpreter backend.</h2>
<h2>– ******** Summary ********<br>
–   CMake version         : 3.5.1<br>
–   CMake command         : /usr/bin/cmake<br>
–   System                : Linux<br>
–   C++ compiler          : /usr/bin/c++<br>
–   C++ compiler version  : 5.5.0<br>
–   CXX flags             :  -Wall -Wnon-virtual-dtor -fno-exceptions -fno-rtti -Wno-psabi -Wnon-virtual-dtor<br>
–   Build type            : Release<br>
–   Compile definitions   : GIT_SHA1=“ef7f916”;GIT_DATE=“2019-09-12”;WITH_PNG;GLOW_WITH_LLVMIRCODEGEN=1;GLOW_WITH_CPU=1;GOOGLE_PROTOBUF_NO_RTTI;ONNX_NAMESPACE=glow_onnx<br>
–   CMAKE_PREFIX_PATH     : /usr/bin<br>
–   CMAKE_INSTALL_PREFIX  : /usr/local<br>
–   CMAKE_MODULE_PATH     : ~glow/cmake/modules</h2>
<h2>–   ONNX version          : 1.5.0<br>
–   ONNX NAMESPACE        : glow_onnx<br>
–   ONNX_BUILD_TESTS      : OFF<br>
–   ONNX_BUILD_BENCHMARKS : OFF<br>
–   ONNX_USE_LITE_PROTO   : OFF<br>
–   ONNXIFI_DUMMY_BACKEND : OFF<br>
–   ONNXIFI_ENABLE_EXT    : OFF</h2>
<p>–   Protobuf compiler     : /usr/bin/protoc<br>
–   Protobuf includes     : /usr/include<br>
–   Protobuf libraries    : optimized;/usr/lib/x86_64-linux-gnu/libprotobuf.so;debug;/usr/lib/x86_64-linux-gnu/libprotobuf.so;-pthread<br>
–   BUILD_ONNX_PYTHON     : OFF<br>
– Failed to find LLVM FileCheck<br>
– git Version: v1.5.0<br>
– Version: 1.5.0<br>
– Performing Test HAVE_STD_REGEX – success<br>
– Performing Test HAVE_GNU_POSIX_REGEX – failed to compile<br>
– Performing Test HAVE_POSIX_REGEX – success<br>
– Performing Test HAVE_STEADY_CLOCK – success<br>
Skipping adding test en2gr_cpu_test because it requires a models directory. Configure with -DGLOW_MODELS_DIR.<br>
Skipping adding test en2gr_quantization_test because it requires a models directory. Configure with -DGLOW_MODELS_DIR.<br>
Skipping adding test en2gr_cpu_partition_test because it requires a models directory. Configure with -DGLOW_MODELS_DIR.<br>
Skipping adding test en2gr_cpu_config_test because it requires a models directory. Configure with -DGLOW_MODELS_DIR.<br>
Skipping adding test resnet_runtime_test because it requires a models directory. Configure with -DGLOW_MODELS_DIR.<br>
– Configuring done<br>
– Generating done<br>
– Build files have been written to: ~/glow<br>
[1/111] Linking CXX executable bin/resnet-verify<br>
FAILED: bin/resnet-verify<br>
: &amp;&amp; /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 &amp;&amp; :<br>
lib/Runtime/HostManager/libHostManager.a(HostManager.cpp.o): In function <code>glow::runtime::HostManager::exportMemoryCounters()': HostManager.cpp:(.text+0x601): undefined reference to</code>glow::Stats()’<br>
HostManager.cpp:(.text+0x618): undefined reference to <code>glow::StatsExporterRegistry::setCounter(llvm::StringRef, long)' HostManager.cpp:(.text+0x61d): undefined reference to</code>glow::Stats()’<br>
HostManager.cpp:(.text+0x634): undefined reference to <code>glow::StatsExporterRegistry::setCounter(llvm::StringRef, long)' HostManager.cpp:(.text+0x639): undefined reference to</code>glow::Stats()’<br>
HostManager.cpp:(.text+0x650): undefined reference to <code>glow::StatsExporterRegistry::setCounter(llvm::StringRef, long)' lib/Runtime/HostManager/libHostManager.a(HostManager.cpp.o): In function</code>glow::runtime::HostManager::clearHost()’:<br>
HostManager.cpp:(.text+0x3521): undefined reference to <code>glow::Stats()' HostManager.cpp:(.text+0x3537): undefined reference to</code>glow::StatsExporterRegistry::setCounter(llvm::StringRef, long)’<br>
HostManager.cpp:(.text+0x353c): undefined reference to <code>glow::Stats()' HostManager.cpp:(.text+0x3552): undefined reference to</code>glow::StatsExporterRegistry::setCounter(llvm::StringRef, long)’<br>
HostManager.cpp:(.text+0x3557): undefined reference to <code>glow::Stats()' HostManager.cpp:(.text+0x356d): undefined reference to</code>glow::StatsExporterRegistry::setCounter(llvm::StringRef, long)’<br>
lib/Base/libBase.a(Image.cpp.o): In function <code>glow::getPngInfo(char const*)': Image.cpp:(.text+0x1b5): undefined reference to</code>png_set_longjmp_fn’<br>
lib/Base/libBase.a(Image.cpp.o): In function <code>glow::writePngImage(glow::Tensor*, char const*, std::pair&lt;float, float&gt;, llvm::ArrayRef&lt;float&gt;, llvm::ArrayRef&lt;float&gt;)': Image.cpp:(.text+0x5e6): undefined reference to</code>png_set_longjmp_fn’<br>
Image.cpp:(.text+0x641): undefined reference to <code>png_set_longjmp_fn' Image.cpp:(.text+0x6c8): undefined reference to</code>png_set_longjmp_fn’<br>
Image.cpp:(.text+0x8a6): undefined reference to <code>png_set_longjmp_fn' lib/Base/libBase.a(Image.cpp.o):Image.cpp:(.text+0xa4f): more undefined references to</code>png_set_longjmp_fn’ follow<br>
collect2: error: ld returned 1 exit status<br>
I am getting this error please help me to fix this!</p>

username: Bert_Maher
cooked: <p>What’s your CMake command line?</p>

username: Bert_Maher
cooked: <p>Actually, I think this is a straight-up bug in our CMake.  I dunno why it works in CI.  <a href="https://github.com/pytorch/glow/pull/3517" rel="nofollow noopener">https://github.com/pytorch/glow/pull/3517</a> should fix it.</p>

username: Compiler-team-1
cooked: <pre><code>								GLOW INSTALLATION STEPS On Ubuntu (16.04)
</code></pre>
<hr>
<p>Glow Compiler Prerequisites:</p>
<pre><code>	Operating system	:	Ubuntu 16.04LTS

	RAM			:	Minimum 16GB

	SWAP MEMORY		:	Minimum 12GB to 20GB

	Memory Needed		:	70GB

	Total Memory needed 	:	Minimum 150GB(LLVM&amp;GLOW)
</code></pre>
<hr>
<p>Glow Compiler Dependencies:</p>
<pre><code>	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		
</code></pre>
<hr>
<p>Glow Compiler Process</p>
<p>Step1:</p>
<pre><code>Download glow repository from git hub

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

	$cd glow
</code></pre>
<p>Step2:</p>
<pre><code>#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
</code></pre>
<p>Step3:</p>
<pre><code>#If Protobuf is not installed install it by using shell script

#version should be 2.6.1 

#PATH: glow/utils/

#run shell script 

	$./install_protobuf.sh
</code></pre>
<p>Step4:</p>
<pre><code>#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
</code></pre>
<p>step5:</p>
<pre><code>#run make command to compile the source code

	$make
</code></pre>
<p>Step6:</p>
<pre><code>#run make install to install the library

	$make install
</code></pre>
<hr>
<p>Testing Glow:</p>
<pre><code>#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.

	$./bin/mnist	

	$./bin/cifar10

	$./bin/fr2en

	$./bin/ptb

	$./bin/char-rnn

#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
</code></pre>
<p>These steps worked and installed Glow compiler in my ubuntu system.</p>

username: Compiler-team-1
cooked: <p>Glow Compiler Dependencies:</p>
<pre><code>	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</code></pre>