VisualSFM_OS_X_Installer icon indicating copy to clipboard operation
VisualSFM_OS_X_Installer copied to clipboard

libpba.so failed to build - macOS Catalina 10.15.1 - fatal error: stdlib.h: No such file or directory

Open mikeroberts3000 opened this issue 5 years ago • 4 comments

Hello there,

Thank you for your great work in creating this installer. I have used this installer successfully in the past. Now I am trying to use it again on a new workstation running macOS Catalina 10.15.1. I am encountering a build error that I don't know how to fix.

Note that I needed to apply the workaround described here so the installer could build SiftGPU. Now I am getting into trouble when the installer attempts to build PBA.

...
LIB_PBA is present, skipping download and unzip, removing old dir to install so we don't have any conflicts
Archive:  pba_v1.0.5.zip
   creating: pba/
   creating: pba/bin/
  inflating: pba/bin/driver_x64.exe  
  inflating: pba/bin/pba.dll         
  inflating: pba/bin/pba_x64.dll     
  inflating: pba/COPYING             
   creating: pba/data/
   creating: pba/doc/
  inflating: pba/doc/manual.pdf      
  inflating: pba/doc/readme.txt      
  inflating: pba/History.txt         
  inflating: pba/makefile            
  inflating: pba/makefile_no_gpu     
   creating: pba/msvc/
   creating: pba/msvc/driver/
  inflating: pba/msvc/driver/driver.vcxproj  
   creating: pba/msvc/pba/
  inflating: pba/msvc/pba.sln        
  inflating: pba/msvc/pba.suo        
 extracting: pba/msvc/pba/pba.def    
  inflating: pba/msvc/pba/pba.vcxproj  
   creating: pba/src/
   creating: pba/src/driver/
  inflating: pba/src/driver/driver.cpp  
   creating: pba/src/pba/
  inflating: pba/src/pba/ConfigBA.cpp  
  inflating: pba/src/pba/ConfigBA.h  
  inflating: pba/src/pba/CuTexImage.cpp  
  inflating: pba/src/pba/CuTexImage.h  
  inflating: pba/src/pba/DataInterface.h  
  inflating: pba/src/pba/interface.h  
  inflating: pba/src/pba/pba.cpp     
  inflating: pba/src/pba/pba.h       
  inflating: pba/src/pba/ProgramCU.cu  
  inflating: pba/src/pba/ProgramCU.h  
  inflating: pba/src/pba/SparseBundleCPU.cpp  
  inflating: pba/src/pba/SparseBundleCPU.h  
  inflating: pba/src/pba/SparseBundleCU.cpp  
  inflating: pba/src/pba/SparseBundleCU.h  
  inflating: pba/src/pba/util.h      
Changing SiftGPU GCC to Brews gcc-4.9
Removing /usr/lib64 from makefile
Changing march from native core2 in makefile
Adding -L/usr/include/sys/ to compile Flags
patching file SparseBundleCPU.h
/Users/mike/code/github/VisualSFM_OS_X_Installer/pba
mkdir -p ./bin/out_no_gpu
mkdir -p ./bin 
g++-4.9 -w -o bin/out_no_gpu/pba.o src/pba/pba.cpp -DPBA_NO_GPU -fPIC -L -L/usr/lib -L/usr/include/sys/ -L./bin -O2 -Wall -Wno-deprecated -pthread -march=core2 -mfpmath=sse -fpermissive -c 
src/pba/pba.cpp:21:20: fatal error: stdlib.h: No such file or directory
 #include <stdlib.h>
                    ^
compilation terminated.
make: *** [bin/out_no_gpu/pba.o] Error 1
libpba.so failed to build, halting.

This error is strange because usually g++ knows where to find system headers without needing an explicitly specified include path. If I manually change the compiler from g++-4.9 to g++ (by commenting out lines 334-337 inclusive in vsfm_os_x_installer.sh), I resolve these errors and get others.

...
g++ -o bin/out_no_gpu/pba.o src/pba/pba.cpp -DPBA_NO_GPU -fPIC -L -L/usr/lib -L/usr/include/sys/ -L./bin -O2 -Wall -Wno-deprecated -pthread -march=core2 -mfpmath=sse -fpermissive -c 
clang: warning: argument unused during compilation: '-L-L/usr/lib' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-L/usr/include/sys/' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-L./bin' [-Wunused-command-line-argument]
g++ -o bin/out_no_gpu/ConfigBA.o src/pba/ConfigBA.cpp -DPBA_NO_GPU -fPIC -L -L/usr/lib -L/usr/include/sys/ -L./bin -O2 -Wall -Wno-deprecated -pthread -march=core2 -mfpmath=sse -fpermissive -c 
clang: warning: argument unused during compilation: '-L-L/usr/lib' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-L/usr/include/sys/' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-L./bin' [-Wunused-command-line-argument]
g++ -o bin/out_no_gpu/SparseBundleCPU.o src/pba/SparseBundleCPU.cpp -DPBA_NO_GPU -fPIC -L -L/usr/lib -L/usr/include/sys/ -L./bin -O2 -Wall -Wno-deprecated -pthread -march=core2 -mfpmath=sse -fpermissive -c 
clang: warning: argument unused during compilation: '-L-L/usr/lib' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-L/usr/include/sys/' [-Wunused-command-line-argument]
clang: warning: argument unused during compilation: '-L./bin' [-Wunused-command-line-argument]
src/pba/SparseBundleCPU.cpp:2469:32: warning: field '_num_imgpt_q' will be initialized after field '_camera_data'
      [-Wreorder]
                _num_imgpt(0), _num_imgpt_q(0), _camera_data(NULL), _point_data(NULL), _imgpt_data(NULL),
                               ^
src/pba/SparseBundleCPU.cpp:4168:14: note: in instantiation of member function
      'SparseBundleCPU<double>::SparseBundleCPU' requested here
                return new SparseBundleCPU<double>;
                           ^
src/pba/SparseBundleCPU.cpp:1129:9: error: call to function 'ComputeProjection' that is neither visible in the
      template definition nor found by argument-dependent lookup
        ComputeProjection( q->nproj, q->camera, q->point, q->ms, q->jmap, q->pj, q->radial_distortion, 0);
        ^
...

I'm not sure how to proceed from here. Has anyone successfully built VisualSFM on macOS Catalina?

mikeroberts3000 avatar Nov 26 '19 20:11 mikeroberts3000

I am also running into this issue of Catalina not finding stdlib.h

geo-jules-cross avatar Dec 04 '19 03:12 geo-jules-cross

Hi @geo-jules-cross, I never got VisualSFM running on macOS Catalina. The workaround I ended up going with was to use the structure-from-motion tool available in MVE. I am aware that VisualSFM has some features that are not available in MVE. But if you just need to get something working, then MVE is a good choice, and it builds on macOS without any issues. MVE includes other tools that do dense multi-view stereo, surface reconstruction, etc. And it outputs structure-from-motion data in the familiar Bundler format (synth_0.out), which is the same format as VisualSFM, is easy to parse yourself, and is interoperable with several different 3D reconstruction tools. I hope that helps! Please do post here if you get VisualSFM working on macOS Catalina though 😄

mikeroberts3000 avatar Dec 04 '19 05:12 mikeroberts3000

Hello @mikeroberts3000, what I've found is that the script to build VisualSFM expects header files (e.g. include.h) to be located in usr/include/sys. Since Mojave this usr/include directory no longer exists. This StackOverflow post helped. I am still trying to figure this out, I'll post here with any head way.

geo-jules-cross avatar Dec 04 '19 15:12 geo-jules-cross

Hi all,

For me adding the following path solved the issue: export CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include

Later on I had to manually download the CMVS-PMVS-master, because the PMVS_pmoulonGit.zip was empty. In there, I had an issue with some wrong redirection within the main repository, which can be solved by modifying the installer.

I also had to change #include <math.h> for #include in the file CMVS-PMVS-master>program>base>cmvs>bundle.cc

I also had to modify the CMakeLists.txt in the CMVS-PMVS>program because of Parse error.

cdarviot avatar Apr 09 '20 21:04 cdarviot