Page 1 of 1

VisualSFM fails to compile on M5 with libf2c

PostPosted: Apr 5th, '16, 20:40
by webguy
I'm attempting to compile some interesting photogrammetry / Structure from Motion software (VisualSFM, http://ccwu.me/vsfm/index.html).
It comes with some precompiled objects using Basic Linear Algebra libs LAPACK, BLAS, and f2c (Fortran to C) http://madb.mageia.org/package/list/arch/x86_64/application/0/t_search/f2c in archive files, which compiles OK using the makefile :D

Code: Select all
#   Use supplied libs
LIB_LIST +=  -pthread -lGL -lGLU -lX11 -ldl $(GTK_LIBS) $(LIB_DIR)/lapack.a \
         $(LIB_DIR)/blas.a $(LIB_DIR)/libf2c.a $(LIB_DIR)/libjpeg.a


but I thought I'd try it with the Mageia libs (it was first written a few years ago, so who knows, maybe the algorithms in the libraries have been optimised a bit more since then :) ):

Code: Select all
#   Use local libs
#LIB_LIST +=  -pthread -lGL -lGLU -lX11 -ldl $(GTK_LIBS) -llapack -lblas -lf2c -ljpeg


which fails :? with

Code: Select all
/usr/lib/gcc/x86_64-mageia-linux-gnu/4.9.2/../../../../lib64/libf2c.so: undefined reference to `MAIN__'
collect2: error: ld returned 1 exit status
makefile:48: recipe for target 'VisualSFM' failed
make: *** [VisualSFM] Error 1


As its a precompiled library it doesn't say exactly where the error is, so I tried ldd

Code: Select all
ldd -r /usr/lib/gcc/x86_64-mageia-linux-gnu/4.9.2/../../../../lib64/libf2c.so
        linux-vdso.so.1 (0x00007ffd58da7000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f8bb0e7c000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f8bb0ac8000)
        /lib64/ld-linux-x86-64.so.2 (0x00005629fa8d0000)
undefined symbol: MAIN__        (/usr/lib/gcc/x86_64-mageia-linux-gnu/4.9.2/../../../../lib64/libf2c.so)


Is this perhaps a bug in how M5 libf2c has been compiled, perhaps not using options for a shared library like http://www.adp-gmbh.ch/cpp/gcc/create_lib.html, or is it that the source file main.c http://netlib.org/f2c/ doesn't define a return type for main(). I've noticed that other related parts of linked code return a lot of warnings that seem to be related to changes in how more modern compilers expect to see things written. (I'm no C/C++ programmer, just starting to learn a bit through attempting to get things to compile).

[Post title edited to better reflect contents]

Re: VisualSFM fails to compile on M5 with libf2c

PostPosted: Apr 5th, '16, 23:17
by webguy
I tried this on Mageia 6 dev 1 too; same result:

Code: Select all
ldd -r /usr/lib/gcc/x86_64-mageia-linux-gnu/5.3.1/../../../../lib64/libf2c.so
        linux-vdso.so.1 (0x00007ffc83721000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f7ddf11a000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f7dded67000)
        /lib64/ld-linux-x86-64.so.2 (0x0000558c9c38d000)
undefined symbol: MAIN__        (/usr/lib/gcc/x86_64-mageia-linux-gnu/5.3.1/../../../../lib64/libf2c.so)

Re: VisualSFM fails to compile on M5 with libf2c

PostPosted: Apr 6th, '16, 07:34
by doktor5000
FWIW, there may be quite some work required if you want it to work with the system libraries vs. the bundled ones.
See e.g. the fedora instructions: http://mdda.net/oss-blog/2014-06/buildi ... M-on-FC20/

If you're not firm with that, I'd strongly suggest that you use the bundled libraries.