lua---mattorch icon indicating copy to clipboard operation
lua---mattorch copied to clipboard

OS X build failed, seems Makefile not correct

Open jakezhaojb opened this issue 10 years ago • 16 comments

I made attempt building and installing mattorch on OS X, by: sudo luarocks install mattorch

Installing https://raw.githubusercontent.com/torch/rocks/master/mattorch-1.0-0.rockspec...
Using https://raw.githubusercontent.com/torch/rocks/master/mattorch-1.0-0.rockspec... switching to 'build' mode
Cloning into 'lua---mattorch'...
remote: Counting objects: 19, done.
remote: Compressing objects: 100% (16/16), done.
remote: Total 19 (delta 0), reused 8 (delta 0)
Receiving objects: 100% (19/19), 11.32 KiB | 0 bytes/s, done.
Checking connectivity... done.
Note: checking out 'c3640f86dc23c9cac836752576f6a3594d9fc4e3'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

cmake -E make_directory build;
cd build;
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="/usr/local/bin/.." -DCMAKE_INSTALL_PREFIX="/usr/local/lib/luarocks/rocks/mattorch/1.0-0";
make

-- The C compiler identification is AppleClang 5.1.0.5030040
-- The CXX compiler identification is AppleClang 5.1.0.5030040
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found Torch7 in /usr/local
-- ** WARNING no MATLAB_ROOT setting to /opt/matlab
-- ** you can set the correct MATLAB_ROOT in your environment
-- ** eg. bash: export MATLAB_ROOT=/home/john/matlab
-- Using Matlab in: /opt/matlab
CMake Error at /usr/local/Cellar/cmake/3.0.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:136 (message):
  MATLAB_INCLUDE_DIR (missing: MATLAB_MEX_LIBRARY MATLAB_MAT_LIBRARY
  MATLAB_ENG_LIBRARY MATLAB_MX_LIBRARY)
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.0.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:343 (_FPHSA_FAILURE_MESSAGE)
  FindMatlab.cmake:123 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:11 (FIND_PACKAGE)


-- Configuring incomplete, errors occurred!
See also "/tmp/luarocks_mattorch-1.0-0-5516/lua---mattorch/build/CMakeFiles/CMakeOutput.log".
make: *** No targets specified and no makefile found.  Stop.

Error: Build error: Failed building.

jakezhaojb avatar Dec 04 '14 05:12 jakezhaojb

you can install it manually:

git clone https://github.com/clementfarabet/lua---mattorch.git
cd lua---mattorch
mkdir build
cd build
cmake -DMATLAB_ROOT=/Applications/MATLAB_R2014a.app/ ..
cd ..
luarocks make

szagoruyko avatar Dec 04 '14 12:12 szagoruyko

Tested, it works! thx @szagoruyko

russellfei avatar Jan 03 '15 11:01 russellfei

Yeah same here! Thanks

jakezhaojb avatar Jan 03 '15 19:01 jakezhaojb

Not me: Linking C shared library libmattorchlive.dylib Undefined symbols for architecture x86_64:

physicsman avatar Aug 02 '15 21:08 physicsman

Me neither on mac OSX:-

ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) make[2]: *** [libmattorchlive.dylib] Error 1 make[1]: *** [CMakeFiles/mattorchlive.dir/all] Error 2 make: *** [all] Error 2

jaiabhayk avatar Oct 03 '15 06:10 jaiabhayk

Anybody found way around this problem?

Linking C shared library libmattorchlive.dylib ld: symbol(s) not found for architecture x86_64

parthchadha avatar Jan 05 '16 09:01 parthchadha

I am on Ubuntu 14 and I encountered the same problem with luarocks install mattorch. After I set the correct MATLAB_ROOT path in my bashrc, the error persisted:

-- Using Matlab in: /usr/local/MATLAB/R2015a:
CMake Error at /usr/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
  MATLAB_INCLUDE_DIR (missing: MATLAB_MEX_LIBRARY MATLAB_MAT_LIBRARY
  MATLAB_ENG_LIBRARY MATLAB_MX_LIBRARY)
Call Stack (most recent call first):
  /usr/share/cmake-3.2/Modules/FindPackageHandleStandardArgs.cmake:374 (_FPHSA_FAILURE_MESSAGE)
  FindMatlab.cmake:123 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:11 (FIND_PACKAGE)


-- Configuring incomplete, errors occurred!
See also "/tmp/luarocks_mattorch-1.0-0-7695/lua---mattorch/build/CMakeFiles/CMakeOutput.log".
make: *** No targets specified and no makefile found. Stop.

Then I somehow managed to fix the problem by using MATLAB_ROOT=/usr/local/MATLAB/R2015a luarocks install mattorch instead!

qizhuli avatar Feb 09 '16 14:02 qizhuli

@qizhuli

Hey, there is no need to install mattorch to perform data transferation between .mat and .t7, matio in the torch wiki is your better choice! Good luck~

Regards, rus

russellfei avatar Feb 24 '16 06:02 russellfei

I have the same issue. I am using OSX version 10.11.4. I have very large .mat files and I have to save it with "-v7.3" flag in MATLAB, and matio does not read 'v7.3' files, so I think I have to use mattorch, but it does not compile...

I've used both methods, both times it gives me the same error:

  1. I tried using the manual compiling suggested above.
  2. ) I've also tried using MATLAB_ROOT=/Applications/MATLAB_R2014b.app luarocks install mattorch.

both times I got the following error:

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [libmattorchlive.dylib] Error 1
make[1]: *** [CMakeFiles/mattorchlive.dir/all] Error 2
make: *** [all] Error 2

Error: Build error: Failed building.

does anyone know a solution to the compiling issues? Thanks in advance!

zichaow avatar Jun 05 '16 04:06 zichaow

I have fixed the same problem using MATLAB_ROOT=/Applications/MATLAB_R2014b.app luarocks install mattorch

xiaofanglegoc avatar Dec 02 '16 09:12 xiaofanglegoc

I took the following steps for UBUNTU 14.04

git clone https://github.com/clementfarabet/lua---mattorch.git cd lua---mattorch mkdir build cd build cmake -DMATLAB_ROOT=/usr/local/MATLAB/R2017a

after this command this error raised.

CMake Error: The following variables are used in this project, but they are set to NOTFOUND. Please set them or make sure they are set and tested correctly in the CMake files: MATLAB_ENG_LIBRARY (ADVANCED) linked by target "mattorch" in directory /home/codehead/lua---mattorch/build linked by target "mattorchlive" in directory /home/codehead/lua---mattorch/build MATLAB_INCLUDE_DIR (ADVANCED) used as include directory in directory /home/codehead/lua---mattorch/build used as include directory in directory /home/codehead/lua---mattorch/build MATLAB_MEX_LIBRARY (ADVANCED) linked by target "mattorch" in directory /home/codehead/lua---mattorch/build linked by target "mattorchlive" in directory /home/codehead/lua---mattorch/build MATLAB_MX_LIBRARY (ADVANCED) linked by target "mattorch" in directory /home/codehead/lua---mattorch/build linked by target "mattorchlive" in directory /home/codehead/lua---mattorch/build

-- Configuring incomplete, errors occurred! See also "/home/codehead/lua---mattorch/build/CMakeFiles/CMakeOutput.log".

mdshopon avatar Apr 02 '17 09:04 mdshopon

@codeheadshopon Hi, your CMake variables of Matlab is NOT FOUND, you need to set them in your CMakeList.txt, good luck~

russellfei avatar Apr 03 '17 12:04 russellfei

I was having the same errors as the original poster on macOS 10.12.4, so tried a manual install:

git clone https://github.com/clementfarabet/lua---mattorch.git
cd lua---mattorch
mkdir build
cd build
cmake -DMATLAB_ROOT=/Applications/MATLAB_R2014a.app/ ..
cd ..
luarocks make

However, I still got the following output:

cmake -E make_directory build;
cd build;
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="/Users/nicholasarner/torch/install/bin/.." -DCMAKE_INSTALL_PREFIX="/Users/nicholasarner/torch/install/lib/luarocks/rocks/mattorch/1.0-0"; 
make
   
-- Found Torch7 in /Users/nicholasarner/torch/install
-- Using Matlab in: /Applications/MATLAB_R2014a.app/
CMake Error at /usr/local/Cellar/cmake/3.8.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
  MATLAB_INCLUDE_DIR (missing: MATLAB_MEX_LIBRARY MATLAB_MAT_LIBRARY
  MATLAB_ENG_LIBRARY MATLAB_MX_LIBRARY)
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.8.0/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:377 (_FPHSA_FAILURE_MESSAGE)
  FindMatlab.cmake:123 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:11 (FIND_PACKAGE)


-- Configuring incomplete, errors occurred!
See also "/Users/nicholasarner/lua---mattorch/build/CMakeFiles/CMakeOutput.log".
make: *** No targets specified and no makefile found.  Stop.

Error: Build error: Failed building.

narner avatar Apr 16 '17 21:04 narner

@narner you may not have used correct MATLAB_ROOT path.

vivkul avatar Apr 26 '17 11:04 vivkul

This solved the problem of

ld: symbol(s) not found for architecture x86_64

Based on git commit by szagoruyko I got the idea to add SET(CMAKE_C_FLAGS "-undefined dynamic_lookup") to CMakeLists.txt.

Thanks szagoruyko!

This is how my CMakeList.txt looks after the edit:

SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})

CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)
CMAKE_POLICY(VERSION 2.6)
IF(LUAROCKS_PREFIX)
    MESSAGE(STATUS "Installing Torch through Luarocks")
    STRING(REGEX REPLACE "(.*)lib/luarocks/rocks.*" "\\1" CMAKE_INSTALL_PREFIX  "${LUAROCKS_PREFIX}")
    MESSAGE(STATUS "Prefix inferred from Luarocks: ${CMAKE_INSTALL_PREFIX}")
ENDIF()
FIND_PACKAGE(Torch REQUIRED)
FIND_PACKAGE(Matlab REQUIRED)

INCLUDE_DIRECTORIES(${MATLAB_INCLUDE_DIR} ${TORCH_INCLUDE_DIR})
ADD_LIBRARY(mattorchlive SHARED mattorchlive.c)
SET(CMAKE_C_FLAGS "-undefined dynamic_lookup")
LINK_DIRECTORIES(${TORCH_LIBRARY_DIR})
TARGET_LINK_LIBRARIES(mattorchlive TH luaT ${MATLAB_LIBRARIES})

SET(src mattorch.c)
SET(luasrc init.lua)
ADD_TORCH_PACKAGE(mattorch "${src}" "${luasrc}" "Compatibility Tools")
TARGET_LINK_LIBRARIES(mattorch luaT TH ${MATLAB_LIBRARIES})

klen-copic avatar Jan 25 '18 06:01 klen-copic

I have the same error and I try the method :

git clone https://github.com/clementfarabet/lua---mattorch.git cd lua---mattorch mkdir build cd build cmake -DMATLAB_ROOT=/Applications/MATLAB_R2014a.app/ .. cd .. luarocks make

It will stili be wrong!

xuekun@xuekun-Inspiron-5420:~$ luarocks install mattorch Installing https://raw.githubusercontent.com/torch/rocks/master/mattorch-1.0-0.rockspec... Using https://raw.githubusercontent.com/torch/rocks/master/mattorch-1.0-0.rockspec... switching to 'build' mode Cloning into 'lua---mattorch'... remote: Counting objects: 19, done. remote: Compressing objects: 100% (16/16), done. remote: Total 19 (delta 0), reused 8 (delta 0), pack-reused 0 Receiving objects: 100% (19/19), 11.32 KiB | 0 bytes/s, done. Checking connectivity... done. Note: checking out 'c3640f86dc23c9cac836752576f6a3594d9fc4e3'.

You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may do so (now or later) by using -b with the checkout command again. Example:

git checkout -b new_branch_name

cmake -E make_directory build; cd build; cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="/home/xuekun/torch/install/bin/.." -DCMAKE_INSTALL_PREFIX="/home/xuekun/torch/install/lib/luarocks/rocks/mattorch/1.0-0"; make

-- The C compiler identification is GNU 4.8.4 -- The CXX compiler identification is GNU 4.8.4 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found Torch7 in /home/xuekun/torch/install -- ** WARNING no MATLAB_ROOT setting to /opt/matlab -- ** you can set the correct MATLAB_ROOT in your environment -- ** eg. bash: export MATLAB_ROOT=/home/john/matlab -- Using Matlab in: /opt/matlab CMake Error at /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message): MATLAB_INCLUDE_DIR (missing: MATLAB_MEX_LIBRARY MATLAB_MAT_LIBRARY MATLAB_ENG_LIBRARY MATLAB_MX_LIBRARY) Call Stack (most recent call first): /usr/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE) FindMatlab.cmake:123 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) CMakeLists.txt:11 (FIND_PACKAGE)

-- Configuring incomplete, errors occurred! See also "/tmp/luarocks_mattorch-1.0-0-117/lua---mattorch/build/CMakeFiles/CMakeOutput.log". make: *** No targets specified and no makefile found. Stop.

Error: Build error: Failed building.

xuekun@xuekun-Inspiron-5420:~$ git clone https://github.com/clementfarabet/lua---mattorch.git fatal: destination path 'lua---mattorch' already exists and is not an empty directory. xuekun@xuekun-Inspiron-5420:~$ cd lua---mattorch xuekun@xuekun-Inspiron-5420:~/lua---mattorch$ mkdir build mkdir: cannot create directory ‘build’: File exists xuekun@xuekun-Inspiron-5420:~/lua---mattorch$ cd build xuekun@xuekun-Inspiron-5420:~/lua---mattorch/build$ cmake -DMATLAB_ROOT=/usr/local/MATLAB/R2015b CMake Error: The source directory "/home/xuekun/lua---mattorch/build" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI.

I looked up a lot of solutions, none of them worked. Is there any other solution? Thanks!

DHXxuekun avatar Mar 20 '18 04:03 DHXxuekun