Repository: pytorch
Issue: Adding new module to caffe2
Labels: caffe2

Hi,
  I am adding a new module to caffe 2 for some development. A new dir is added under caffe2/contrib. So the CMakeList.txt file was modified to add the dir using a conditional if (USE_XXX). The CMakeLists.txt under caffe2 was modified to add libraries to be linked as below.

link_directories(AFTER /home/fpgauser/<xxx>/linux64/lib /home/fpgauser/<xxx>/linux64/host/linux64/lib )
set (EXTRA_LIBS ${EXTRA_LIBS} OpenCL alteracl)

target_link_libraries (caffe2 PUBLIC ${EXTRA_LIBS})

The build/rebuild fails with this for a different module. The error message is below. Any help appreciated.
==========================================================================
[ 93%] Built target c10d
[ 93%] Building CXX object caffe2/torch/lib/c10d/test/CMakeFiles/ProcessGroupGlooTest.dir/ProcessGroupGlooTest.cpp.o
[ 93%] Linking CXX executable ../bin/blob_test
CMakeFiles/blob_test.dir/core/blob_test.cc.o: In function `caffe2::(anonymous namespace)::TypedTensorTest_BigTensorSerialization_Test<double>::TestBody()':
blob_test.cc:(.text+0x4043c): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
[ 93%] Built target blob_test
[ 93%] Building CXX object caffe2/torch/lib/c10d/test/CMakeFiles/TCPStoreTest.dir/TCPStoreTest.cpp.o
[ 93%] Building CXX object caffe2/torch/lib/c10d/test/CMakeFiles/FileStoreTest.dir/FileStoreTest.cpp.o
[ 93%] Linking CXX executable ../../../../../bin/FileStoreTest
../../../../../lib/libcaffe2.so: undefined reference to `testing::Test::~Test()'
../../../../../lib/libcaffe2.so: undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
../../../../../lib/libcaffe2.so: undefined reference to `typeinfo for testing::Test'
../../../../../lib/libcaffe2.so: undefined reference to `testing::internal::GetTestTypeId()'
../../../../../lib/libcaffe2.so: undefined reference to `testing::Test::SetUp()'
../../../../../lib/libcaffe2.so: undefined reference to `testing::Test::TearDown()'
../../../../../lib/libcaffe2.so: undefined reference to `testing::Test::Test()'
collect2: error: ld returned 1 exit status
make[2]: *** [caffe2/torch/lib/c10d/test/CMakeFiles/FileStoreTest.dir/build.make:96: bin/FileStoreTest] Error 1
make[1]: *** [CMakeFiles/Makefile2:7500: caffe2/torch/lib/c10d/test/CMakeFiles/FileStoreTest.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 93%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/autograd/generated/VariableType_4.cpp.o
[ 93%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/autograd/grad_mode.cpp.o
[ 93%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/autograd/input_buffer.cpp.o
[ 93%] Linking CXX shared library ../../lib/libcaffe2_detectron_ops.so
[ 93%] Linking CXX executable ../../../../../bin/TCPStoreTest
../../../../../lib/libcaffe2.so: undefined reference to `testing::Test::~Test()'
../../../../../lib/libcaffe2.so: undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
../../../../../lib/libcaffe2.so: undefined reference to `typeinfo for testing::Test'
../../../../../lib/libcaffe2.so: undefined reference to `testing::internal::GetTestTypeId()'
../../../../../lib/libcaffe2.so: undefined reference to `testing::Test::SetUp()'
../../../../../lib/libcaffe2.so: undefined reference to `testing::Test::TearDown()'
../../../../../lib/libcaffe2.so: undefined reference to `testing::Test::Test()'
collect2: error: ld returned 1 exit status
make[2]: *** [caffe2/torch/lib/c10d/test/CMakeFiles/TCPStoreTest.dir/build.make:96: bin/TCPStoreTest] Error 1
make[1]: *** [CMakeFiles/Makefile2:7459: caffe2/torch/lib/c10d/test/CMakeFiles/TCPStoreTest.dir/all] Error 2
[ 93%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/autograd/profiler.cpp.o
[ 93%] Built target caffe2_detectron_ops
[ 93%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/autograd/saved_variable.cpp.o
[ 93%] Linking CXX executable ../../../../../bin/ProcessGroupGlooTest
../../../../../lib/libcaffe2.so: undefined reference to `testing::Test::~Test()'
../../../../../lib/libcaffe2.so: undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
../../../../../lib/libcaffe2.so: undefined reference to `typeinfo for testing::Test'
../../../../../lib/libcaffe2.so: undefined reference to `testing::internal::GetTestTypeId()'
../../../../../lib/libcaffe2.so: undefined reference to `testing::Test::SetUp()'
../../../../../lib/libcaffe2.so: undefined reference to `testing::Test::TearDown()'
../../../../../lib/libcaffe2.so: undefined reference to `testing::Test::Test()'
collect2: error: ld returned 1 exit status
make[2]: *** [caffe2/torch/lib/c10d/test/CMakeFiles/ProcessGroupGlooTest.dir/build.make:97: bin/ProcessGroupGlooTest] Error 1
make[1]: *** [CMakeFiles/Makefile2:7418: caffe2/torch/lib/c10d/test/CMakeFiles/ProcessGroupGlooTest.dir/all] Error 2
[ 93%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/autograd/variable.cpp.o
[ 93%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/autograd/VariableTypeManual.cpp.o
[ 93%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/cuda/comm.cpp.o
[ 93%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/autodiff.cpp.o
[ 93%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/export.cpp.o
[ 93%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/generated/register_aten_ops_0.cpp.o
[ 93%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/generated/register_aten_ops_1.cpp.o
[ 94%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/generated/register_aten_ops_2.cpp.o
[ 94%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/graph_executor.cpp.o
[ 94%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/import.cpp.o
[ 94%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/interpreter.cpp.o
[ 94%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/constants.cpp.o
[ 94%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/node_hashing.cpp.o
[ 95%] Linking CXX shared module python/caffe2_pybind11_state.cpython-35m-x86_64-linux-gnu.so
[ 95%] Built target caffe2_pybind11_state
[ 95%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/ir.cpp.o
[ 95%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/operator.cpp.o
[ 95%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/batch_mm.cpp.o
[ 95%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/canonicalize.cpp.o
[ 95%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/constant_propagation.cpp.o
[ 95%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/constant_pooling.cpp.o
[ 95%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/common_subexpression_elimination.cpp.o
[ 95%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/create_autodiff_subgraphs.cpp.o
[ 95%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/inline_autodiff_subgraphs.cpp.o
[ 95%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/dead_code_elimination.cpp.o
[ 96%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/canonicalize_ops.cpp.o
[ 96%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/erase_number_types.cpp.o
[ 96%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/graph_fuser.cpp.o
[ 96%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/inplace_check.cpp.o
[ 96%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/loop_unrolling.cpp.o
[ 96%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/lower_grad_of.cpp.o
[ 96%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/lower_tuples.cpp.o
[ 96%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/peephole.cpp.o
[ 96%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/remove_expands.cpp.o
[ 96%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/remove_inplace_ops.cpp.o
[ 96%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/shape_analysis.cpp.o
[ 96%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/requires_grad_analysis.cpp.o
[ 96%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/specialize_undef.cpp.o
[ 96%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/passes/pretty_print.cpp.o
[ 96%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/fuser/interface.cpp.o
[ 97%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/register_prim_ops.cpp.o
[ 97%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/register_special_ops.cpp.o
[ 97%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/scope.cpp.o
[ 97%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/script/compiler.cpp.o
[ 97%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/script/builtin_functions.cpp.o
[ 97%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/script/lexer.cpp.o
[ 97%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/script/module.cpp.o
[ 97%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/tracer.cpp.o
[ 97%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/torch.cpp.o
[ 97%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/utils/tensor_flatten.cpp.o
[ 97%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/utils/variadic.cpp.o
[ 97%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/__/test/cpp/jit/no-gtest.cpp.o
[ 97%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/fuser/kernel_cache.cpp.o
/home/fpgauser/FB/pytorch/pytorch/torch/csrc/torch.cpp: In function ‘at::TypeExtendedInterface& torch::CPU(at::ScalarType)’:
/home/fpgauser/FB/pytorch/pytorch/torch/csrc/torch.cpp:11:17: warning: ‘at::TypeExtendedInterface& torch::getVariableType(at::Backend, at::ScalarType)’ is deprecated [-Wdeprecated-declarations]
   return torch::getVariableType(at::Backend::CPU, type);
                 ^~~~~~~~~~~~~~~
/home/fpgauser/FB/pytorch/pytorch/torch/csrc/torch.cpp:6:28: note: declared here
 at::TypeExtendedInterface& getVariableType(at::Backend backend, at::ScalarType type) {
                            ^~~~~~~~~~~~~~~
/home/fpgauser/FB/pytorch/pytorch/torch/csrc/torch.cpp:11:55: warning: ‘at::TypeExtendedInterface& torch::getVariableType(at::Backend, at::ScalarType)’ is deprecated [-Wdeprecated-declarations]
   return torch::getVariableType(at::Backend::CPU, type);
                                                       ^
/home/fpgauser/FB/pytorch/pytorch/torch/csrc/torch.cpp:6:28: note: declared here
 at::TypeExtendedInterface& getVariableType(at::Backend backend, at::ScalarType type) {
                            ^~~~~~~~~~~~~~~
/home/fpgauser/FB/pytorch/pytorch/torch/csrc/torch.cpp: In function ‘at::TypeExtendedInterface& torch::CUDA(at::ScalarType)’:
/home/fpgauser/FB/pytorch/pytorch/torch/csrc/torch.cpp:15:17: warning: ‘at::TypeExtendedInterface& torch::getVariableType(at::Backend, at::ScalarType)’ is deprecated [-Wdeprecated-declarations]
   return torch::getVariableType(at::Backend::CUDA, type);
                 ^~~~~~~~~~~~~~~
/home/fpgauser/FB/pytorch/pytorch/torch/csrc/torch.cpp:6:28: note: declared here
 at::TypeExtendedInterface& getVariableType(at::Backend backend, at::ScalarType type) {
                            ^~~~~~~~~~~~~~~
/home/fpgauser/FB/pytorch/pytorch/torch/csrc/torch.cpp:15:56: warning: ‘at::TypeExtendedInterface& torch::getVariableType(at::Backend, at::ScalarType)’ is deprecated [-Wdeprecated-declarations]
   return torch::getVariableType(at::Backend::CUDA, type);
                                                        ^
/home/fpgauser/FB/pytorch/pytorch/torch/csrc/torch.cpp:6:28: note: declared here
 at::TypeExtendedInterface& getVariableType(at::Backend backend, at::ScalarType type) {
                            ^~~~~~~~~~~~~~~
[ 97%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/fuser/compiler.cpp.o
[ 97%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/fuser/executor.cpp.o
[ 97%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/fuser/codegen.cpp.o
[ 98%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/fuser/fallback.cpp.o
[ 98%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/jit/fuser/cpu/fused_kernel.cpp.o
[ 98%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/cuda.cpp.o
[ 98%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/data/datasets/mnist.cpp.o
[ 98%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/data/samplers/random.cpp.o
[ 98%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/data/samplers/sequential.cpp.o
[ 98%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/data/samplers/stream.cpp.o
[ 98%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/jit.cpp.o
[ 98%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/nn/init.cpp.o
[ 98%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/nn/module.cpp.o
[ 98%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/nn/modules/batchnorm.cpp.o
[ 98%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/nn/modules/conv.cpp.o
[ 98%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/nn/modules/dropout.cpp.o
[ 98%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/nn/modules/embedding.cpp.o
[ 98%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/nn/modules/functional.cpp.o
[ 99%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/nn/modules/linear.cpp.o
[ 99%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/nn/modules/rnn.cpp.o
[ 99%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/optim/adagrad.cpp.o
[ 99%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/optim/adam.cpp.o
[ 99%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/optim/lbfgs.cpp.o
[ 99%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/optim/optimizer.cpp.o
[ 99%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/optim/rmsprop.cpp.o
[ 99%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/optim/serialize.cpp.o
[ 99%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/optim/sgd.cpp.o
[ 99%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/serialize/input-archive.cpp.o
[ 99%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/serialize/output-archive.cpp.o
[ 99%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/serialize/tensor.cpp.o
[ 99%] Building CXX object caffe2/torch/CMakeFiles/torch.dir/csrc/api/src/utils.cpp.o
[ 99%] Linking CXX shared library ../../lib/libtorch.so
[ 99%] Built target torch
make: *** [Makefile:141: all] Error 2
===================================================================