Use COLMAP as static library

910 views
Skip to first unread message

anhdu...@gmail.com

unread,
May 4, 2018, 4:03:32 AM5/4/18
to COLMAP
Hello, I am trying to use some of the functions in base/database.h to get the features and matching pairs performed by COLMAP.

I created a CMake project and link to static library "libbase.a" but it seems it is impossible because it requires a lot of dependencies. Anyone knows how to deal with that problem? I spent a whole day but got nothing.

Thank you for your help.

Johannes Schönberger

unread,
May 4, 2018, 4:13:59 AM5/4/18
to col...@googlegroups.com

You should link against libcolmap.a.

--
You received this message because you are subscribed to the Google Groups "COLMAP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
colmap+un...@googlegroups.com.
To post to this group, send email to
col...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/colmap/5a0342f8-42dc-4e09-bc07-d4db50b6d4d4%40googlegroups.com.
For more options, visit
https://groups.google.com/d/optout.

anhdu...@gmail.com

unread,
May 4, 2018, 5:11:45 AM5/4/18
to COLMAP
Thanks for very quick reply. I followed the instruction here: https://colmap.github.io/install.html in order to build COLMAP from source for Linux, but I cannot find the location of libcolmap.a (I used "locate -i libcolmap.a but unable to find the its location)
Can you please guide me how to compile the libcolmap.a?

Thank you for your help!

On Friday, May 4, 2018 at 5:43:59 PM UTC+9:30, Johannes Schönberger wrote:

You should link against libcolmap.a.

 

From: <col...@googlegroups.com> on behalf of <anhdu...@gmail.com>
Reply-To: <col...@googlegroups.com>
Date: Friday, May 4, 2018 at 10:03 AM
To: COLMAP <col...@googlegroups.com>
Subject: [COLMAP] Use COLMAP as static library

 

Hello, I am trying to use some of the functions in base/database.h to get the features and matching pairs performed by COLMAP.

 

I created a CMake project and link to static library "libbase.a" but it seems it is impossible because it requires a lot of dependencies. Anyone knows how to deal with that problem? I spent a whole day but got nothing.

 

Thank you for your help.

 

--
You received this message because you are subscribed to the Google Groups "COLMAP" group.

To unsubscribe from this group and stop receiving emails from it, send an email to colmap+unsubscribe@googlegroups.com.


To post to this group, send email to


To view this discussion on the web visit

Johannes Schönberger

unread,
May 5, 2018, 9:16:18 AM5/5/18
to col...@googlegroups.com
I actually don’t compile a static library at the moment, but this could be changed in the future. I will add a new target or option in CMake to do so. 

Cheers,
Johannes
To unsubscribe from this group and stop receiving emails from it, send an email to colmap+un...@googlegroups.com.

To post to this group, send email to col...@googlegroups.com.

Johannes Schönberger

unread,
May 24, 2018, 8:12:36 AM5/24/18
to COLMAP
This feature is now implemented in the latest commit in the dev branch, see https://github.com/colmap/colmap/issues/360
Message has been deleted

anhdu...@gmail.com

unread,
Jun 20, 2018, 10:48:56 PM6/20/18
to COLMAP
This thread is quite long, so thanks for your patience to read all about it

I tried to download the latest commit of COLMAP, build and install it. I followed your guide here: https://colmap.github.io/install.html#library

I compiled test.cc and got the error:

In file included from /usr/local/include/colmap/util/option_manager.h:39:0,
                 
from /home/dzungdoan/DzungDoan/codes/COLMAP-test/test.cc:4:
/usr/local/share/colmap/../../include/colmap/util/logging.h: In function bool colmap::__CheckOptionOpImpl(const char*, int, bool, const T1&, const T2&, const char*, const char*, const char*)’:
/usr/local/share/colmap/../../include/colmap/util/logging.h:84:49: error: to_string is not a member of std
                               op_str
, val2_str, std::to_string(val1).c_str(),
                                                 
^
/usr/local/share/colmap/../../include/colmap/util/logging.h:85:31: error: to_string is not a member of std
                               std
::to_string(val2).c_str())
                               
^
In file included from /home/dzungdoan/DzungDoan/codes/COLMAP-test/test.cc:4:0:
/usr/local/include/colmap/util/option_manager.h: At global scope:
/usr/local/include/colmap/util/option_manager.h:115:8: error: shared_ptr in namespace std does not name a template type
   std
::shared_ptr<std::string> project_path;
       
^
/usr/local/include/colmap/util/option_manager.h:116:8: error: shared_ptr in namespace std does not name a template type
   std
::shared_ptr<std::string> database_path;
       
^
/usr/local/include/colmap/util/option_manager.h:117:8: error: shared_ptr in namespace std does not name a template type
   std
::shared_ptr<std::string> image_path;
       
^
/usr/local/include/colmap/util/option_manager.h:119:8: error: shared_ptr in namespace std does not name a template type
   std
::shared_ptr<ImageReaderOptions> image_reader;
       
^
/usr/local/include/colmap/util/option_manager.h:120:8: error: shared_ptr in namespace std does not name a template type
   std
::shared_ptr<SiftExtractionOptions> sift_extraction;
       
^
/usr/local/include/colmap/util/option_manager.h:122:8: error: shared_ptr in namespace std does not name a template type
   std
::shared_ptr<SiftMatchingOptions> sift_matching;
       
^
/usr/local/include/colmap/util/option_manager.h:123:8: error: shared_ptr in namespace std does not name a template type
   std
::shared_ptr<ExhaustiveMatchingOptions> exhaustive_matching;
       
^
/usr/local/include/colmap/util/option_manager.h:124:8: error: shared_ptr in namespace std does not name a template type
   std
::shared_ptr<SequentialMatchingOptions> sequential_matching;
       
^
/usr/local/include/colmap/util/option_manager.h:125:8: error: shared_ptr in namespace std does not name a template type
   std
::shared_ptr<VocabTreeMatchingOptions> vocab_tree_matching;
       
^
/usr/local/include/colmap/util/option_manager.h:126:8: error: shared_ptr in namespace std does not name a template type
   std
::shared_ptr<SpatialMatchingOptions> spatial_matching;
       
^
/usr/local/include/colmap/util/option_manager.h:127:8: error: shared_ptr in namespace std does not name a template type
   std
::shared_ptr<TransitiveMatchingOptions> transitive_matching;
       
^
/usr/local/include/colmap/util/option_manager.h:129:8: error: shared_ptr in namespace std does not name a template type
   std
::shared_ptr<BundleAdjustmentOptions> bundle_adjustment;
       
^
/usr/local/include/colmap/util/option_manager.h:130:8: error: shared_ptr in namespace std does not name a template type
   std
::shared_ptr<IncrementalMapperOptions> mapper;
       
^
/usr/local/include/colmap/util/option_manager.h:132:8: error: shared_ptr in namespace std does not name a template type
   std
::shared_ptr<mvs::PatchMatchOptions> dense_stereo;
       
^
/usr/local/include/colmap/util/option_manager.h:133:8: error: shared_ptr in namespace std does not name a template type
   std
::shared_ptr<mvs::StereoFusionOptions> dense_fusion;


        ^
Then, I add
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
to the CMakeLists.txt, then the compilation was succesfull.

However, I got another error (it seems it is the linking error) as follows:

[ 50%] Building CXX object CMakeFiles/test.dir/test.cc.o
[100%] Linking CXX executable test
/usr/local/share/colmap/../../lib/colmap/libpba.a(pba_generated_ProgramCU.cu.o): In function `__device_stub__ZN3pba20jte_point_vec_kernelILi2ELi2EEEviiPf(int, int, float*)':
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x1d): undefined reference to `
cudaSetupArgument'
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x40): undefined reference to `cudaSetupArgument'

tmpxft_00001371_00000000
-5_ProgramCU.cudafe1.cpp:(.text+0x56): undefined reference to `cudaSetupArgument'
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x66): undefined reference to `
cudaLaunch'
/usr/local/share/colmap/../../lib/colmap/libpba.a(pba_generated_ProgramCU.cu.o): In function `__device_stub__ZN3pba20jte_point_vec_kernelILi2ELi1EEEviiPf(int, int, float*)'
:
tmpxft_00001371_00000000
-5_ProgramCU.cudafe1.cpp:(.text+0x8d): undefined reference to `cudaSetupArgument'
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0xb0): undefined reference to `
cudaSetupArgument'
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0xc6): undefined reference to `cudaSetupArgument'

tmpxft_00001371_00000000
-5_ProgramCU.cudafe1.cpp:(.text+0xd6): undefined reference to `cudaLaunch'
/usr/local/share/colmap/../../lib/colmap/libpba.a(pba_generated_ProgramCU.cu.o): In function `
__device_stub__ZN3pba23jtjd_point_block_kernelILi2EEEviiffP6float4S2_(int, int, float, float, float4*, float4*)':
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x10e): undefined reference to `cudaSetupArgument'

tmpxft_00001371_00000000
-5_ProgramCU.cudafe1.cpp:(.text+0x130): undefined reference to `cudaSetupArgument'
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x148): undefined reference to `
cudaSetupArgument'
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x160): undefined reference to `cudaSetupArgument'

tmpxft_00001371_00000000
-5_ProgramCU.cudafe1.cpp:(.text+0x178): undefined reference to `cudaSetupArgument'
/usr/local/share/colmap/../../lib/colmap/libpba.a(pba_generated_ProgramCU.cu.o):tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x18e): more undefined references to `
cudaSetupArgument' follow
/usr/local/share/colmap/../../lib/colmap/libpba.a(pba_generated_ProgramCU.cu.o): In function `__device_stub__ZN3pba23jtjd_point_block_kernelILi2EEEviiffP6float4S2_(int, int, float, float, float4*, float4*)'
:
tmpxft_00001371_00000000
-5_ProgramCU.cudafe1.cpp:(.text+0x19e): undefined reference to `cudaLaunch'
/usr/local/share/colmap/../../lib/colmap/libpba.a(pba_generated_ProgramCU.cu.o): In function `
__device_stub__ZN3pba23jtjd_point_block_kernelILi1EEEviiffP6float4S2_(int, int, float, float, float4*, float4*)':
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x1de): undefined reference to `cudaSetupArgument'

tmpxft_00001371_00000000
-5_ProgramCU.cudafe1.cpp:(.text+0x200): undefined reference to `cudaSetupArgument'
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x218): undefined reference to `
cudaSetupArgument'
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x230): undefined reference to `cudaSetupArgument'

tmpxft_00001371_00000000
-5_ProgramCU.cudafe1.cpp:(.text+0x248): undefined reference to `cudaSetupArgument'
/usr/local/share/colmap/../../lib/colmap/libpba.a(pba_generated_ProgramCU.cu.o):tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x25e): more undefined references to `
cudaSetupArgument' follow
/usr/local/share/colmap/../../lib/colmap/libpba.a(pba_generated_ProgramCU.cu.o): In function `__device_stub__ZN3pba23jtjd_point_block_kernelILi1EEEviiffP6float4S2_(int, int, float, float, float4*, float4*)'
:
tmpxft_00001371_00000000
-5_ProgramCU.cudafe1.cpp:(.text+0x26e): undefined reference to `cudaLaunch'
/usr/local/share/colmap/../../lib/colmap/libpba.a(pba_generated_ProgramCU.cu.o): In function `
__device_stub__ZN3pba28jtjd_cam_block_invert_kernelILi8EEEviP6float4(int, float4*)':
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x299): undefined reference to `cudaSetupArgument'

tmpxft_00001371_00000000
-5_ProgramCU.cudafe1.cpp:(.text+0x2be): undefined reference to `cudaSetupArgument'
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x2ce): undefined reference to `
cudaLaunch'
/usr/local/share/colmap/../../lib/colmap/libpba.a(pba_generated_ProgramCU.cu.o): In function `__device_stub__ZN3pba28jtjd_cam_block_invert_kernelILi7EEEviP6float4(int, float4*)'
:
tmpxft_00001371_00000000
-5_ProgramCU.cudafe1.cpp:(.text+0x2f9): undefined reference to `cudaSetupArgument'
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x31e): undefined reference to `
cudaSetupArgument'
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x32e): undefined reference to `cudaLaunch'

/usr/local/share/colmap/../../lib/colmap/libpba.a(pba_generated_ProgramCU.cu.o): In function `pba::ProgramCU::CheckErrorCUDA(char const*)':
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x3a8): undefined reference to `
cudaGetLastError'
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x3e2): undefined reference to `cudaGetErrorString'

/usr/local/share/colmap/../../lib/colmap/libpba.a(pba_generated_ProgramCU.cu.o): In function `pba::ProgramCU::ResetCurrentDevice()':
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x462): undefined reference to `
cudaGetDevice'
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x467): undefined reference to `cudaDeviceReset'

tmpxft_00001371_00000000
-5_ProgramCU.cudafe1.cpp:(.text+0x474): undefined reference to `cudaSetDevice'
/usr/local/share/colmap/../../lib/colmap/libpba.a(pba_generated_ProgramCU.cu.o): In function `
pba::ProgramCU::GetCudaMemoryCap()':
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x4c0): undefined reference to `cudaGetDevice'

tmpxft_00001371_00000000
-5_ProgramCU.cudafe1.cpp:(.text+0x4f2): undefined reference to `cudaGetDeviceProperties'
/usr/local/share/colmap/../../lib/colmap/libpba.a(pba_generated_ProgramCU.cu.o): In function `
pba::ProgramCU::SetCudaDevice(int)':
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x54c): undefined reference to `cudaGetDeviceCount'

tmpxft_00001371_00000000
-5_ProgramCU.cudafe1.cpp:(.text+0x57a): undefined reference to `cudaGetDevice'
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x5e3): undefined reference to `
cudaSetDevice'
tmpxft_00001371_00000000-5_ProgramCU.cudafe1.cpp:(.text+0x608): undefined reference to `cudaGetDeviceProperties'

/usr/local/share/colmap/../../lib/colmap/libpba.a(pba_generated_ProgramCU.cu.o): In function `pba::ProgramCU::ComputeJacobian(pba::CuTexImage&, pba::CuTexImage&, pba::CuTexImage&, pba::CuTexImage&, pba::CuTexImage&, pba::CuTexImage&, pba::CuTexImage&, pba::CuTexImage&, bool, int, bool)':


Here is the result I got when doing cmake ..

-- Found installed version of Eigen: /usr/lib/cmake/eigen3
-- Found required Ceres dependency: Eigen version 3.2.92 in /usr/include/eigen3
-- Found required Ceres dependency: glog
-- Found required Ceres dependency: gflags
-- Found Ceres version: 1.14.0 installed in: /usr/local with components: [EigenSparse, SparseLinearAlgebraLibrary, LAPACK, SuiteSparse, CXSparse, SchurSpecializations, OpenMP, Multithreading]
-- Boost version: 1.58.0
-- Found the following Boost libraries:
--   program_options
--   filesystem
--   regex
--   system
--   unit_test_framework
-- Found Eigen
--   Includes : /usr/include/eigen3
-- Found FreeImage
--   Includes : /usr/include
--   Libraries : /usr/lib/x86_64-linux-gnu/libfreeimage.so
-- Found Glog
--   Includes : /usr/include
--   Libraries : /usr/lib/x86_64-linux-gnu/libglog.so
-- Found Glew
--   Includes : /usr/include
--   Libraries : /usr/lib/x86_64-linux-gnu/libGLEW.so
CMake Warning (dev) at CMakeLists.txt:11 (add_executable):
 
Policy CMP0037 is not set: Target names should not be reserved and should
  match a validity pattern
.  Run "cmake --help-policy CMP0037" for policy
  details
.  Use the cmake_policy command to set the policy and suppress this
  warning
.

 
The target name "test" is reserved or not valid for certain CMake features,
  such
as generator expressions, and may result in undefined behavior.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring done
-- Generating done


Could you please help me with my error? Thank you very much for your assistance
To unsubscribe from this group and stop receiving emails from it, send an email to colmap+un...@googlegroups.com.

To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/colmap/8354c966-f8ef-4caa-9e70-ac43fd8d776d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and stop receiving emails from it, send an email to colmap+un...@googlegroups.com.

Johannes Schönberger

unread,
Jun 21, 2018, 9:46:02 AM6/21/18
to col...@googlegroups.com
Seems like you are not linking against CUDA, I will check the test.cc on a CUDA machine later. Thanks for the report. 

Johannes Schönberger

unread,
Jun 21, 2018, 10:55:32 AM6/21/18
to col...@googlegroups.com

Hi,

 

This should be fixed now with the latest commit in the dev branch: https://github.com/colmap/colmap/commit/f03d165bd9503ebedacfdd5f6c2f541faa692cb1

 

Thanks again and let me know if this works for you.

 

Cheers, Johannes

--
You received this message because you are subscribed to the Google Groups "COLMAP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to colmap+un...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/colmap/8354c966-f8ef-4caa-9e70-ac43fd8d776d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "COLMAP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to colmap+un...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/colmap/527f6dbf-c100-497d-96d2-d682709f7ad1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--

You received this message because you are subscribed to the Google Groups "COLMAP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to colmap+un...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.

anhdu...@gmail.com

unread,
Jun 21, 2018, 9:05:39 PM6/21/18
to COLMAP
Hello, it works now, thank you very much :)
Reply all
Reply to author
Forward
0 new messages