szagoruyko / cvpr15deepcompare

Code and models for "Learning to Compare Image Patches via Convolutional Neural Networks"
http://imagine.enpc.fr/~zagoruys/deepcompare.html
Other
468 stars 169 forks source link

Error Linking THC When Building Matlab Interface #1

Closed siegeln closed 9 years ago

siegeln commented 9 years ago

Hi, I'm trying to compile the Matlab interface using mex. I followed the directions for installation and added -L/cutorch/lib/THC/build to make.m, but I'm getting a linking error. I've reproduced the error on OSX 10.10 using clang-602.0.53 and Ubuntu 14.04 using gcc 4.8.4. Using clang:

Undefined symbols for architecture x86_64:
   "_cunnrelease_Linear", referenced from:
      cunn::Linear::forward(THCudaTensor*) in libcunnproduction_static.a(cunn.cpp.o)
  "_cunnrelease_ReLUIP", referenced from:
      cunn::ReLU::forward(THCudaTensor*) in libcunnproduction_static.a(cunn.cpp.o)
  "_cunnrelease_SpatialAveragePooling", referenced from:
      cunn::SpatialAveragePooling::forward(THCudaTensor*) in libcunnproduction_static.a(cunn.cpp.o)
  "_cunnrelease_SpatialConvolution", referenced from:
      cunn::SpatialConvolutionMM::forward(THCudaTensor*) in libcunnproduction_static.a(cunn.cpp.o)
  "_cunnrelease_SpatialMaxPooling", referenced from:
      cunn::SpatialMaxPooling::forward(THCudaTensor*) in libcunnproduction_static.a(cunn.cpp.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

    mex: link of ' "deepcompare.mexmaci64"' failed.

Using gcc:

Error using mex
../build/cunnproduction/libcunnproduction_static.a(cunn.cpp.o): In function
`cunn::SpatialConvolutionMM::forward(THCudaTensor*)':
cunn.cpp:(.text+0x368): undefined reference to `cunnrelease_SpatialConvolution'
../build/cunnproduction/libcunnproduction_static.a(cunn.cpp.o): In function
`cunn::SpatialMaxPooling::forward(THCudaTensor*)':
cunn.cpp:(.text+0x523): undefined reference to `cunnrelease_SpatialMaxPooling'
../build/cunnproduction/libcunnproduction_static.a(cunn.cpp.o): In function
`cunn::SpatialAveragePooling::forward(THCudaTensor*)':
cunn.cpp:(.text+0x639): undefined reference to `cunnrelease_SpatialAveragePooling'
../build/cunnproduction/libcunnproduction_static.a(cunn.cpp.o): In function `cunn::ReLU::forward(THCudaTensor*)':
cunn.cpp:(.text+0x6cf): undefined reference to `cunnrelease_ReLUIP'
../build/cunnproduction/libcunnproduction_static.a(cunn.cpp.o): In function `cunn::Linear::forward(THCudaTensor*)':
cunn.cpp:(.text+0x866): undefined reference to `cunnrelease_Linear'
collect2: error: ld returned 1 exit status

Am I linking the wrong library?

szagoruyko commented 9 years ago

Hi, should be fixed by https://github.com/szagoruyko/cvpr15deepcompare/commit/988d60efbcb92185e08775bb956cf0fa527d1bfd, please try again

siegeln commented 9 years ago

Compiles now, thanks!

qqrsqqq commented 7 years ago

same error with you, but i use 988d60e how could that happen?

system123 commented 7 years ago

I am having the same issue. Everything builds fine, I then run my make.m file, which looks as follows:

mex -I../src...
    -I/home/lloyd/torch/install/include...
    -L/home/lloyd/torch/install/lib...
    -L/usr/local/cuda/lib64...
    -L/usr/local/MATLAB/R2016b/bin/glnxa64...
        CXXFLAGS='-std=c++11 -fPIC'...
    ../build/libwrapper_static.a...
    ../build/libloader_static.a...
    ../build/cunnproduction/libcunnproduction_static.a...
    ../build/cunnproduction/libcunn.a...
    -lcudart -lTH -lTHC -lmex -lmat -lmx...
    deepcompare.cpp

But I receive the following errors:

../build/cunnproduction/libcunnproduction_static.a(cunn.cpp.o): In function `cunn::SpatialConvolutionMM::forward(THCudaTensor*)':
cunn.cpp:(.text+0x352): undefined reference to `THNN_CudaSpatialConvolutionMM_updateOutput'
../build/cunnproduction/libcunnproduction_static.a(cunn.cpp.o): In function `cunn::SpatialMaxPooling::forward(THCudaTensor*)':
cunn.cpp:(.text+0x574): undefined reference to `THNN_CudaSpatialMaxPooling_updateOutput'
../build/cunnproduction/libcunnproduction_static.a(cunn.cpp.o): In function `cunn::SpatialAveragePooling::forward(THCudaTensor*)':
cunn.cpp:(.text+0x696): undefined reference to `THNN_CudaSpatialAveragePooling_updateOutput'
../build/cunnproduction/libcunnproduction_static.a(cunn.cpp.o): In function `cunn::ReLU::forward(THCudaTensor*)':
cunn.cpp:(.text+0x73f): undefined reference to `THNN_CudaThreshold_updateOutput'
../build/cunnproduction/libcunnproduction_static.a(cunn.cpp.o): In function `cunn::SoftMax::forward(THCudaTensor*)':
cunn.cpp:(.text+0x1fb3): undefined reference to `THNN_CudaSoftMax_updateOutput'
collect2: error: ld returned 1 exit status

Error in make (line 17)
mex -I../src...

Any idea what might be wrong?