How do I resolve Undefined symbols for architecture x86_64 error with clang++ building Octave from source on Catalina? - octave

I am building Octave from source code on OS X 10.15.7
The linker is generating numerous errors:
E.g.
"bsxfun_add(intNDArray<octave_int<signed char> > const&, intNDArray<octave_int<signed char> > const&)", referenced from:
octave_value bsxfun_forward_op<intNDArray<octave_int<signed char> >, &(bsxfun_add(intNDArray<octave_int<signed char> > const&, intNDArray<octave_int<signed char> > const&))>(octave_value const&, octave_value const&) in libcorefcn.a(libcorefcn_la-bsxfun.o)
Here's my build environment settings:
$ xcrun --show-sdk-path
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk
(base) MacBook-Pro:.build davidlaxer$ xcode-select -p
/Library/Developer/CommandLineTools
$ clang++ --version
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Here's my 'configuration' command for Octave:
../configure \
CC=/usr/bin/clang \
CXX=/usr/bin/clang++ \
CCLD=/usr/bin/clang \
CXXLD=/usr/bin/clang++ \
F77=/opt/local/bin/gfortran-mp-10 \
FFLAGS="-pipe -Os -m64" \
CFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk" \
CCFLAGS="-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk" \
CPPFLAGS="-I/opt/local/include -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -I/Users/davidlaxer/SuiteSparse/include -I/opt/local/libexec/qt5/include -I/Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home/include" \
CXXFLAGS="-pipe -Os -std=c++17 -stdlib=libc++ -arch x86_64 -pthread -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk" LDFLAGS="-L/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib -L/Users/davidlaxer/SuiteSparse/lib/ -L/opt/local/libexec/qt5/lib -L/Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home/lib -arch x86_64" DYLD_LIBRARY_PATH="-L/opt/local/lib -L/opt/local/libexec/qt5/lib -L/Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home/lib" LD_LIBRARY_PATH="-L/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib -L/Users/davidlaxer/SuiteSparse/lib/ -L/opt/local/lib -L/opt/local/libexec/qt5/lib -L/Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home/lib" --with-suitesparseconfig-includedir=/Users/davidlaxer/SuiteSparse/include --with-suitesparseconfig-libdir=/Users/davidlaxer/SuiteSparse/lib --disable-readline --with-sundials_ida-includedir=/opt/local/include/sundials --with-sundials_ida-libdir=/opt/local/lib/ --with-qt=5 --with-libiconv-prefix=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr --with-qhull-includedir=/opt/local/include/libqhull --with-qhull-libdir=/opt/local/lib --with-hdf5-includedir=/opt/local/include --with-hdf5-libdir=/opt/local/lib
There are compiler warnings regarding DEPRECATED functions but it seems unrelated.
CXX libinterp/corefcn/libcorefcn_la-bsxfun.lo
../libinterp/corefcn/bsxfun.cc:543:31: warning: 'do_cat_op' is deprecated
[-Wdeprecated-declarations]
C = do_cat_op (C, tmp(0), ra_idx);
^
../libinterp/octave-value/ov.h:1713:1: note: 'do_cat_op' has been explicitly
marked deprecated here
OCTAVE_DEPRECATED (7, "use 'octave::cat_op' instead")
^
The symbols the linker is complaining about are in the object file and static library:
$ nm -n ../.build/libinterp/corefcn/.libs/libcorefcn_la-bsxfun.o | grep bsxfun_add
U __Z10bsxfun_addRK10intNDArrayI10octave_intIaEES4_
U __Z10bsxfun_addRK10intNDArrayI10octave_intIhEES4_
U __Z10bsxfun_addRK10intNDArrayI10octave_intIiEES4_
U __Z10bsxfun_addRK10intNDArrayI10octave_intIjEES4_
U __Z10bsxfun_addRK10intNDArrayI10octave_intIsEES4_
U __Z10bsxfun_addRK10intNDArrayI10octave_intItEES4_
U __Z10bsxfun_addRK10intNDArrayI10octave_intIxEES4_
U __Z10bsxfun_addRK10intNDArrayI10octave_intIyEES4_
U __Z10bsxfun_addRK12FloatNDArrayS1_
U __Z10bsxfun_addRK14ComplexNDArrayS1_
U __Z10bsxfun_addRK19FloatComplexNDArrayS1_
U __Z10bsxfun_addRK7NDArrayS1_
0000000000004a35 t __ZL17bsxfun_forward_opI7NDArrayXadL_Z10bsxfun_addRKS0_S2_EEE12octave_valueRKS3_S5_
0000000000005311 t __ZL17bsxfun_forward_opI12FloatNDArrayXadL_Z10bsxfun_addRKS0_S2_EEE12octave_valueRKS3_S5_
0000000000005bed t __ZL17bsxfun_forward_opI14ComplexNDArrayXadL_Z10bsxfun_addRKS0_S2_EEE12octave_valueRKS3_S5_
00000000000064c9 t __ZL17bsxfun_forward_opI19FloatComplexNDArrayXadL_Z10bsxfun_addRKS0_S2_EEE12octave_valueRKS3_S5_
0000000000006da5 t __ZL17bsxfun_forward_opI10intNDArrayI10octave_intIaEEXadL_Z10bsxfun_addRKS3_S5_EEE12octave_valueRKS6_S8_
0000000000007651 t __ZL17bsxfun_forward_opI10intNDArrayI10octave_intIsEEXadL_Z10bsxfun_addRKS3_S5_EEE12octave_valueRKS6_S8_
0000000000007efd t __ZL17bsxfun_forward_opI10intNDArrayI10octave_intIiEEXadL_Z10bsxfun_addRKS3_S5_EEE12octave_valueRKS6_S8_
00000000000087a9 t __ZL17bsxfun_forward_opI10intNDArrayI10octave_intIxEEXadL_Z10bsxfun_addRKS3_S5_EEE12octave_valueRKS6_S8_
0000000000009055 t __ZL17bsxfun_forward_opI10intNDArrayI10octave_intIhEEXadL_Z10bsxfun_addRKS3_S5_EEE12octave_valueRKS6_S8_
0000000000009901 t __ZL17bsxfun_forward_opI10intNDArrayI10octave_intItEEXadL_Z10bsxfun_addRKS3_S5_EEE12octave_valueRKS6_S8_
000000000000a1ad t __ZL17bsxfun_forward_opI10intNDArrayI10octave_intIjEEXadL_Z10bsxfun_addRKS3_S5_EEE12octave_valueRKS6_S8_
000000000000aa59 t __ZL17bsxfun_forward_opI10intNDArrayI10octave_intIyEEXadL_Z10bsxfun_addRKS3_S5_EEE12octave_valueRKS6_S8_
and
$ nm -n ../.build/libinterp/corefcn/.libs/libcorefcn.a | grep bsxfun_add
U __Z10bsxfun_addRK10intNDArrayI10octave_intIaEES4_
U __Z10bsxfun_addRK10intNDArrayI10octave_intIhEES4_
U __Z10bsxfun_addRK10intNDArrayI10octave_intIiEES4_
U __Z10bsxfun_addRK10intNDArrayI10octave_intIjEES4_
U __Z10bsxfun_addRK10intNDArrayI10octave_intIsEES4_
U __Z10bsxfun_addRK10intNDArrayI10octave_intItEES4_
U __Z10bsxfun_addRK10intNDArrayI10octave_intIxEES4_
U __Z10bsxfun_addRK10intNDArrayI10octave_intIyEES4_
U __Z10bsxfun_addRK12FloatNDArrayS1_
U __Z10bsxfun_addRK14ComplexNDArrayS1_
U __Z10bsxfun_addRK19FloatComplexNDArrayS1_
U __Z10bsxfun_addRK7NDArrayS1_
0000000000004a7d t __ZL17bsxfun_forward_opI7NDArrayXadL_Z10bsxfun_addRKS0_S2_EEE12octave_valueRKS3_S5_
0000000000005359 t __ZL17bsxfun_forward_opI12FloatNDArrayXadL_Z10bsxfun_addRKS0_S2_EEE12octave_valueRKS3_S5_
0000000000005c35 t __ZL17bsxfun_forward_opI14ComplexNDArrayXadL_Z10bsxfun_addRKS0_S2_EEE12octave_valueRKS3_S5_
0000000000006511 t __ZL17bsxfun_forward_opI19FloatComplexNDArrayXadL_Z10bsxfun_addRKS0_S2_EEE12octave_valueRKS3_S5_
0000000000006ded t __ZL17bsxfun_forward_opI10intNDArrayI10octave_intIaEEXadL_Z10bsxfun_addRKS3_S5_EEE12octave_valueRKS6_S8_
0000000000007699 t __ZL17bsxfun_forward_opI10intNDArrayI10octave_intIsEEXadL_Z10bsxfun_addRKS3_S5_EEE12octave_valueRKS6_S8_
0000000000007f45 t __ZL17bsxfun_forward_opI10intNDArrayI10octave_intIiEEXadL_Z10bsxfun_addRKS3_S5_EEE12octave_valueRKS6_S8_
00000000000087f1 t __ZL17bsxfun_forward_opI10intNDArrayI10octave_intIxEEXadL_Z10bsxfun_addRKS3_S5_EEE12octave_valueRKS6_S8_
000000000000909d t __ZL17bsxfun_forward_opI10intNDArrayI10octave_intIhEEXadL_Z10bsxfun_addRKS3_S5_EEE12octave_valueRKS6_S8_
0000000000009949 t __ZL17bsxfun_forward_opI10intNDArrayI10octave_intItEEXadL_Z10bsxfun_addRKS3_S5_EEE12octave_valueRKS6_S8_
000000000000a1f5 t __ZL17bsxfun_forward_opI10intNDArrayI10octave_intIjEEXadL_Z10bsxfun_addRKS3_S5_EEE12octave_valueRKS6_S8_
000000000000aaa1 t __ZL17bsxfun_forward_opI10intNDArrayI10octave_intIyEEXadL_Z10bsxfun_addRKS3_S5_EEE12octave_valueRKS6_S8_
The mangled names in the object file and the static library appear to be slightly different from the one in compile warning:
demangled with http://demangler.com:
_octave_value bsxfun_forward_op<NDArray, &(bsxfun_add(NDArray const&, NDArray const&))>(octave_value const&, octave_value const&)
Linker error (undefined symbol):
octave_value bsxfun_forward_op<intNDArray<octave_int<signed char> >, &(bsxfun_add(intNDArray<octave_int<signed char> > const&, intNDArray<octave_int<signed char> > const&))>(octave_value const&, octave_value const&)
Easier viewing:
Here's the linker command:
/usr/bin/clang++ -v -dynamiclib -o libinterp/.libs/liboctinterp.8.dylib libinterp/.libs/liboctinterp_la-octave.o libinterp/operators/.libs/liboctinterp_la-op-b-b.o libinterp/operators/.libs/liboctinterp_la-op-b-bm.o libinterp/operators/.libs/liboctinterp_la-op-b-sbm.o libinterp/operators/.libs/liboctinterp_la-op-bm-b.o libinterp/operators/.libs/liboctinterp_la-op-bm-bm.o libinterp/operators/.libs/liboctinterp_la-op-bm-sbm.o libinterp/operators/.libs/liboctinterp_la-op-cdm-cdm.o libinterp/operators/.libs/liboctinterp_la-op-cdm-cm.o libinterp/operators/.libs/liboctinterp_la-op-cdm-cs.o libinterp/operators/.libs/liboctinterp_la-op-cdm-dm.o libinterp/operators/.libs/liboctinterp_la-op-cdm-m.o libinterp/operators/.libs/liboctinterp_la-op-cdm-s.o libinterp/operators/.libs/liboctinterp_la-op-cell.o libinterp/operators/.libs/liboctinterp_la-op-chm.o libinterp/operators/.libs/liboctinterp_la-op-class.o libinterp/operators/.libs/liboctinterp_la-op-cm-cdm.o libinterp/operators/.libs/liboctinterp_la-op-cm-cm.o libinterp/operators/.libs/liboctinterp_la-op-cm-cs.o libinterp/operators/.libs/liboctinterp_la-op-cm-dm.o libinterp/operators/.libs/liboctinterp_la-op-cm-m.o libinterp/operators/.libs/liboctinterp_la-op-cm-pm.o libinterp/operators/.libs/liboctinterp_la-op-cm-s.o libinterp/operators/.libs/liboctinterp_la-op-cm-scm.o libinterp/operators/.libs/liboctinterp_la-op-cm-sm.o libinterp/operators/.libs/liboctinterp_la-op-cs-cm.o libinterp/operators/.libs/liboctinterp_la-op-cs-cs.o libinterp/operators/.libs/liboctinterp_la-op-cs-m.o libinterp/operators/.libs/liboctinterp_la-op-cs-s.o libinterp/operators/.libs/liboctinterp_la-op-cs-scm.o libinterp/operators/.libs/liboctinterp_la-op-cs-sm.o libinterp/operators/.libs/liboctinterp_la-op-dm-cdm.o libinterp/operators/.libs/liboctinterp_la-op-dm-cm.o libinterp/operators/.libs/liboctinterp_la-op-dm-cs.o libinterp/operators/.libs/liboctinterp_la-op-dm-dm.o libinterp/operators/.libs/liboctinterp_la-op-dm-m.o libinterp/operators/.libs/liboctinterp_la-op-dm-s.o libinterp/operators/.libs/liboctinterp_la-op-dm-scm.o libinterp/operators/.libs/liboctinterp_la-op-dm-sm.o libinterp/operators/.libs/liboctinterp_la-op-fcdm-fcdm.o libinterp/operators/.libs/liboctinterp_la-op-fcdm-fcm.o libinterp/operators/.libs/liboctinterp_la-op-fcdm-fcs.o libinterp/operators/.libs/liboctinterp_la-op-fcdm-fdm.o libinterp/operators/.libs/liboctinterp_la-op-fcdm-fm.o libinterp/operators/.libs/liboctinterp_la-op-fcdm-fs.o libinterp/operators/.libs/liboctinterp_la-op-fcm-fcdm.o libinterp/operators/.libs/liboctinterp_la-op-fcm-fcm.o libinterp/operators/.libs/liboctinterp_la-op-fcm-fcs.o libinterp/operators/.libs/liboctinterp_la-op-fcm-fdm.o libinterp/operators/.libs/liboctinterp_la-op-fcm-fm.o libinterp/operators/.libs/liboctinterp_la-op-fcm-fs.o libinterp/operators/.libs/liboctinterp_la-op-fcm-pm.o libinterp/operators/.libs/liboctinterp_la-op-fcn.o libinterp/operators/.libs/liboctinterp_la-op-fcs-fcm.o libinterp/operators/.libs/liboctinterp_la-op-fcs-fcs.o libinterp/operators/.libs/liboctinterp_la-op-fcs-fm.o libinterp/operators/.libs/liboctinterp_la-op-fcs-fs.o libinterp/operators/.libs/liboctinterp_la-op-fdm-fcdm.o libinterp/operators/.libs/liboctinterp_la-op-fdm-fcm.o libinterp/operators/.libs/liboctinterp_la-op-fdm-fcs.o libinterp/operators/.libs/liboctinterp_la-op-fdm-fdm.o libinterp/operators/.libs/liboctinterp_la-op-fdm-fm.o libinterp/operators/.libs/liboctinterp_la-op-fdm-fs.o libinterp/operators/.libs/liboctinterp_la-op-fm-fcdm.o libinterp/operators/.libs/liboctinterp_la-op-fm-fcm.o libinterp/operators/.libs/liboctinterp_la-op-fm-fcs.o libinterp/operators/.libs/liboctinterp_la-op-fm-fdm.o libinterp/operators/.libs/liboctinterp_la-op-fm-fm.o libinterp/operators/.libs/liboctinterp_la-op-fm-fs.o libinterp/operators/.libs/liboctinterp_la-op-fm-pm.o libinterp/operators/.libs/liboctinterp_la-op-fs-fcm.o libinterp/operators/.libs/liboctinterp_la-op-fs-fcs.o libinterp/operators/.libs/liboctinterp_la-op-fs-fm.o libinterp/operators/.libs/liboctinterp_la-op-fs-fs.o libinterp/operators/.libs/liboctinterp_la-op-i16-i16.o libinterp/operators/.libs/liboctinterp_la-op-i32-i32.o libinterp/operators/.libs/liboctinterp_la-op-i64-i64.o libinterp/operators/.libs/liboctinterp_la-op-i8-i8.o libinterp/operators/.libs/liboctinterp_la-op-int-concat.o libinterp/operators/.libs/liboctinterp_la-op-m-cdm.o libinterp/operators/.libs/liboctinterp_la-op-m-cm.o libinterp/operators/.libs/liboctinterp_la-op-m-cs.o libinterp/operators/.libs/liboctinterp_la-op-m-dm.o libinterp/operators/.libs/liboctinterp_la-op-m-m.o libinterp/operators/.libs/liboctinterp_la-op-m-pm.o libinterp/operators/.libs/liboctinterp_la-op-m-s.o libinterp/operators/.libs/liboctinterp_la-op-m-scm.o libinterp/operators/.libs/liboctinterp_la-op-m-sm.o libinterp/operators/.libs/liboctinterp_la-op-mi.o libinterp/operators/.libs/liboctinterp_la-op-pm-cm.o libinterp/operators/.libs/liboctinterp_la-op-pm-fcm.o libinterp/operators/.libs/liboctinterp_la-op-pm-fm.o libinterp/operators/.libs/liboctinterp_la-op-pm-m.o libinterp/operators/.libs/liboctinterp_la-op-pm-pm.o libinterp/operators/.libs/liboctinterp_la-op-pm-scm.o libinterp/operators/.libs/liboctinterp_la-op-pm-sm.o libinterp/operators/.libs/liboctinterp_la-op-range.o libinterp/operators/.libs/liboctinterp_la-op-s-cm.o libinterp/operators/.libs/liboctinterp_la-op-s-cs.o libinterp/operators/.libs/liboctinterp_la-op-s-m.o libinterp/operators/.libs/liboctinterp_la-op-s-s.o libinterp/operators/.libs/liboctinterp_la-op-s-scm.o libinterp/operators/.libs/liboctinterp_la-op-s-sm.o libinterp/operators/.libs/liboctinterp_la-op-sbm-b.o libinterp/operators/.libs/liboctinterp_la-op-sbm-bm.o libinterp/operators/.libs/liboctinterp_la-op-sbm-sbm.o libinterp/operators/.libs/liboctinterp_la-op-scm-cm.o libinterp/operators/.libs/liboctinterp_la-op-scm-cs.o libinterp/operators/.libs/liboctinterp_la-op-scm-m.o libinterp/operators/.libs/liboctinterp_la-op-scm-s.o libinterp/operators/.libs/liboctinterp_la-op-scm-scm.o libinterp/operators/.libs/liboctinterp_la-op-scm-sm.o libinterp/operators/.libs/liboctinterp_la-op-sm-cm.o libinterp/operators/.libs/liboctinterp_la-op-sm-cs.o libinterp/operators/.libs/liboctinterp_la-op-sm-m.o libinterp/operators/.libs/liboctinterp_la-op-sm-s.o libinterp/operators/.libs/liboctinterp_la-op-sm-scm.o libinterp/operators/.libs/liboctinterp_la-op-sm-sm.o libinterp/operators/.libs/liboctinterp_la-op-str-m.o libinterp/operators/.libs/liboctinterp_la-op-str-s.o libinterp/operators/.libs/liboctinterp_la-op-str-str.o libinterp/operators/.libs/liboctinterp_la-op-struct.o libinterp/operators/.libs/liboctinterp_la-op-ui16-ui16.o libinterp/operators/.libs/liboctinterp_la-op-ui32-ui32.o libinterp/operators/.libs/liboctinterp_la-op-ui64-ui64.o libinterp/operators/.libs/liboctinterp_la-op-ui8-ui8.o libinterp/template-inst/.libs/liboctinterp_la-Array-tc.o libinterp/template-inst/.libs/liboctinterp_la-Array-jit.o libinterp/.libs/liboctinterp_la-build-env-features.o libinterp/.libs/liboctinterp_la-build-env.o libinterp/.libs/liboctinterp_la-builtins.o libinterp/corefcn/.libs/liboctinterp_la-oct-errno.o libinterp/.libs/liboctinterp_la-liboctinterp-build-info.o libinterp/operators/.libs/liboctinterp_la-ops.o -Wl,-force_load,libinterp/octave-value/.libs/liboctave-value.a -Wl,-force_load,libinterp/parse-tree/.libs/libparse-tree.a -Wl,-force_load,libinterp/corefcn/.libs/libcorefcn.a -L/opt/local/lib -L/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/lib -L/Users/davidlaxer/SuiteSparse/lib/ -L/opt/local/libexec/qt5/lib -L/Library/Java/JavaVirtualMachines/jdk-13.0.2.jdk/Contents/Home/lib liboctave/.libs/liboctave.dylib -L/opt/local/lib/gcc10/gcc/x86_64-apple-darwin19/10.2.0 -L/opt/local/lib/gcc10/gcc/x86_64-apple-darwin19/10.2.0/../../.. -liconv -lhdf5 -lGraphicsMagick++ -lGraphicsMagick -lz -framework OpenGL -lfontconfig -lfreetype -L/opt/X11/lib -lX11 -framework Carbon -lgl2ps -lcurl -lcholmod -lumfpack -lamd -lcamd -lcolamd -lccolamd -lcxsparse -lsuitesparseconfig -lspqr -larpack -lfftw3_threads -lfftw3 -lfftw3f_threads -lfftw3f -llapack -lblas -lncurses -lpcre -ldl -lgfortran -lquadmath -lm -pthread -Os -stdlib=libc++ -arch x86_64 -pthread -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk -arch x86_64 -Wl,-framework -Wl,CoreFoundation -pthread -framework OpenGL -framework Carbon -install_name /usr/local/lib/octave/7.0.0/liboctinterp.8.dylib -compatibility_version 9 -current_version 9.0 -Wl,-single_module

Related

How to tell OCaml compiler the path of recently installed module

I already have OCaml installed on my Mac by running these commands:
$ brew install opam
$ opam init --bare -a -y
$ opam switch create cs3110-2022fa ocaml-base-compiler.4.14.0
Running any OCaml code which only uses Standard library modules works fine. Then I want to do a few things that are not covered with it, e.g reading CSV files.
$ opam install csv
Let's try to compile this code
open Printf
open Csv
let embedded_csv = "\
\"Banner clickins\"
\"Clickin\",\"Number\",\"Percentage\",
\"brand.adwords\",\"4,878\",\"14.4\"
\"vacation.advert2.adwords\",\"4,454\",\"13.1\"
\"affiliates.generic.tc1\",\"1,608\",\"4.7\"
\"brand.overture\",\"1,576\",\"4.6\"
\"vacation.cheap.adwords\",\"1,515\",\"4.5\"
\"affiliates.generic.vacation.biggestchoice\",\"1,072\",\"3.2\"
\"breaks.no-destination.adwords\",\"1,015\",\"3.0\"
\"fly.no-destination.flightshome.adwords\",\"833\",\"2.5\"
\"exchange.adwords\",\"728\",\"2.1\"
\"holidays.cyprus.cheap\",\"574\",\"1.7\"
\"travel.adwords\",\"416\",\"1.2\"
\"affiliates.vacation.generic.onlinediscount.200\",\"406\",\"1.2\"
\"promo.home.topX.ACE.189\",\"373\",\"1.1\"
\"homepage.hp_tx1b_20050126\",\"369\",\"1.1\"
\"travel.agents.adwords\",\"358\",\"1.1\"
\"promo.home.topX.SSH.366\",\"310\",\"0.9\""
let csvs =
List.map (fun name -> name, Csv.load name)
[ "examples/example1.csv"; "examples/example2.csv" ]
let () =
let ecsv = Csv.input_all(Csv.of_string embedded_csv) in
printf "---Embedded CSV---------------------------------\n" ;
Csv.print_readable ecsv;
List.iter (
fun (name, csv) ->
printf "---%s----------------------------------------\n" name;
Csv.print_readable csv
) csvs;
printf "Compare (Embedded CSV) example1.csv = %i\n"
(Csv.compare ecsv (snd(List.hd csvs)))
let () =
(* Save it to a file *)
let ecsv = Csv.input_all(Csv.of_string embedded_csv) in
let fname = Filename.concat (Filename.get_temp_dir_name()) "example.csv" in
Csv.save fname ecsv;
printf "Saved CSV to file %S.\n" fname
The result is:
$ ocamlopt csvdemo.ml -o csvdemo
File "csvdemo.ml", line 2, characters 5-8:
2 | open Csv
^^^
Error: Unbound module Csv
How to tell OCaml compiler where to find Csv module path?
This seems like a wonderful place to use Dune, but going a little bit old school you can use ocamlfind to locate the package.
% cat test2.ml
open Csv
let () = print_endline "hello"
% ocamlopt -I `ocamlfind query csv` -o test2 csv.cmxa test2.ml
% ./test2
hello
%
Or alternatively:
ocamlfind ocamlopt -package csv -o test2 cvs.cmxa test2.ml

I try to install caffe on win

I try to install caffe,
https://github.com/BVLC/caffe/tree/opencl
C:\Projects> git clone https://github.com/BVLC/caffe.git
C:\Projects> cd caffe
C:\Projects\caffe> git checkout windows
:: Edit any of the options inside build_win.cmd to suit your needs
C:\Projects\caffe> scripts\build_win.cmd
When I try to build, I get this error,
'MySQL' is not recognized as an internal command
Or external, an executable program or a batch file.
I think the error comes from this file build_win.cmd
Line 117 :: Setup the environement for VS x64
Line 118 set batch_file=!VS%MSVC_VERSION%0COMNTOOLS!..\..\VC\vcvarsall.bat
Line 119 call "%batch_file%" amd64
Here is the PATH
PATH=C:\Server\Python\python353\Scripts\;
C:\Server\Python\python353\;
C:\Users\Snarcraft\AMD APP SDK\2.9-1\bin\x86_64;
C:\Users\Snarcraft\AMD APP SDK\2.9-1\bin\x86;
C:\Program Files (x86)\AMD APP SDK\2.9-1\bin\x86_64;
C:\Program Files (x86)\AMD APP SDK\2.9-1\bin\x86;
C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;
C:\ProgramData\Oracle\Java\javapath;
C:\WINDOWS\system32;
C:\WINDOWS;
C:\WINDOWS\System32\Wbem;
C:\WINDOWS\System32\WindowsPowerShell\v1.0\;
C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\;
C:\Program Files (x86)\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\Doctrine extensions for PHP\;
--> C:\Program Files\MySQL\MySQL Server 5.7\bin;
C:\Server\Apache24\bin;
C:\Server\php\php-5.6.30-Win32-VC11-x64;
C:\ProgramData\ComposerSetup\bin;
C:\Server\Git\cmd;C:\Server\MATLAB\R2016a\runtime\win64;
C:\Server\MATLAB\R2016a\bin;
C:\Server\MATLAB\R2016a\polyspace\bin;
--> C:\Program Files\CMake\bin;
C:\Server\Miniconda3;
C:\Server\Miniconda3\Scripts;
C:\Server\Miniconda3\Library\bin;
C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;
C:\Users\Snarcraft\AppData\Local\Microsoft\WindowsApps;
C:\Users\Snarcraft\AppData\Roaming\npm;
C:\Users\Snarcraft\AppData\Roaming\Composer\vendor\bin;
The content of build_win.cmd
#echo off
#setlocal EnableDelayedExpansion
:: Default values
if DEFINED APPVEYOR (
echo Setting Appveyor defaults
if NOT DEFINED MSVC_VERSION set MSVC_VERSION=14
if NOT DEFINED WITH_NINJA set WITH_NINJA=1
if NOT DEFINED CPU_ONLY set CPU_ONLY=1
if NOT DEFINED CUDA_ARCH_NAME set CUDA_ARCH_NAME=Auto
if NOT DEFINED CMAKE_CONFIG set CMAKE_CONFIG=Release
if NOT DEFINED USE_NCCL set USE_NCCL=0
if NOT DEFINED CMAKE_BUILD_SHARED_LIBS set CMAKE_BUILD_SHARED_LIBS=0
if NOT DEFINED PYTHON_VERSION set PYTHON_VERSION=2
if NOT DEFINED BUILD_PYTHON set BUILD_PYTHON=1
if NOT DEFINED BUILD_PYTHON_LAYER set BUILD_PYTHON_LAYER=1
if NOT DEFINED BUILD_MATLAB set BUILD_MATLAB=1
if NOT DEFINED PYTHON_EXE set PYTHON_EXE=python
if NOT DEFINED RUN_TESTS set RUN_TESTS=1
if NOT DEFINED RUN_LINT set RUN_LINT=1
if NOT DEFINED RUN_INSTALL set RUN_INSTALL=1
:: Set python 2.7 with conda as the default python
if !PYTHON_VERSION! EQU 2 (
set CONDA_ROOT=C:\Server\Miniconda3
)
:: Set python 3.5 with conda as the default python
if !PYTHON_VERSION! EQU 3 (
set CONDA_ROOT=C:\Server\Miniconda3
)
set PATH=!CONDA_ROOT!;!CONDA_ROOT!\Scripts;!CONDA_ROOT!\Library\bin;!PATH!
:: Check that we have the right python version
!PYTHON_EXE! --version
:: Add the required channels
conda config --add channels conda-forge
conda config --add channels willyd
:: Update conda
conda update conda -y
:: Download other required packages
conda install --yes cmake ninja numpy scipy protobuf==3.1.0 six scikit-image pyyaml pydotplus graphviz
if ERRORLEVEL 1 (
echo ERROR: Conda update or install failed
exit /b 1
)
:: Install cuda and disable tests if needed
if !WITH_CUDA! == 1 (
call %~dp0\appveyor\appveyor_install_cuda.cmd
set RUN_TESTS=0
set USE_NCCL=1
) else (
set CPU_ONLY=1
)
:: Disable the tests in debug config
if "%CMAKE_CONFIG%" == "Debug" (
echo Disabling tests on appveyor with config == %CMAKE_CONFIG%
set RUN_TESTS=0
)
:: Disable linting with python 3 until we find why the script fails
if !PYTHON_VERSION! EQU 3 (
set RUN_LINT=0
)
) else (
:: Change the settings here to match your setup
:: Change MSVC_VERSION to 12 to use VS 2013
if NOT DEFINED MSVC_VERSION set MSVC_VERSION=14
:: Change to 1 to use Ninja generator (builds much faster)
if NOT DEFINED WITH_NINJA set WITH_NINJA=0
:: Change to 1 to build caffe without CUDA support
if NOT DEFINED CPU_ONLY set CPU_ONLY=0
:: Change to generate CUDA code for one of the following GPU architectures
:: [Fermi Kepler Maxwell Pascal All]
if NOT DEFINED CUDA_ARCH_NAME set CUDA_ARCH_NAME=Auto
:: Change to Debug to build Debug. This is only relevant for the Ninja generator the Visual Studio generator will generate both Debug and Release configs
if NOT DEFINED CMAKE_CONFIG set CMAKE_CONFIG=Release
:: Set to 1 to use NCCL
if NOT DEFINED USE_NCCL set USE_NCCL=0
:: Change to 1 to build a caffe.dll
if NOT DEFINED CMAKE_BUILD_SHARED_LIBS set CMAKE_BUILD_SHARED_LIBS=0
:: Change to 3 if using python 3.5 (only 2.7 and 3.5 are supported)
if NOT DEFINED PYTHON_VERSION set PYTHON_VERSION=2
:: Change these options for your needs.
if NOT DEFINED BUILD_PYTHON set BUILD_PYTHON=1
if NOT DEFINED BUILD_PYTHON_LAYER set BUILD_PYTHON_LAYER=1
if NOT DEFINED BUILD_MATLAB set BUILD_MATLAB=1
:: If python is on your path leave this alone
if NOT DEFINED PYTHON_EXE set PYTHON_EXE=python
:: Run the tests
if NOT DEFINED RUN_TESTS set RUN_TESTS=0
:: Run lint
if NOT DEFINED RUN_LINT set RUN_LINT=0
:: Build the install target
if NOT DEFINED RUN_INSTALL set RUN_INSTALL=0
:: Enable CUDA backend
if NOT DEFINED USE_CUDA set USE_CUDA=0
:: Use cuDNN acceleration with CUDA backend
if NOT DEFINED USE_CUDNN set USE_CUDNN=0
:: Use OpenCL backend
if NOT DEFINED USE_GREENTEA set USE_GREENTEA=1
:: Use LibDNN acceleration with OpenCL and/or CUDA backend
if NOT DEFINED USE_LIBDNN set USE_LIBDNN=1
:: Use OpenMP (disable this on systems with #NUMA > 1)
if NOT DEFINED USE_OPENMP set USE_OPENMP=0
:: Use 64 bit indexing for very large memory blob support (above 2G)
if NOT DEFINED USE_INDEX64 set USE_INDEX64=0
:: Use Intel spatial kernels acceleration for forward convolution on Intel iGPUs
if NOT DEFINED USE_INTEL_SPATIAL set USE_INTEL_SPATIAL=0
:: Disable host/device shared memory
if NOT DEFINED DISABLE_DEVICE_HOST_UNIFIED_MEMORY set DISABLE_DEVICE_HOST_UNIFIED_MEMORY=0
)
:: Set the appropriate CMake generator
:: Use the exclamation mark ! below to delay the
:: expansion of CMAKE_GENERATOR
if %WITH_NINJA% EQU 0 (
if "%MSVC_VERSION%"=="14" (
set CMAKE_GENERATOR=Visual Studio 14 2015 Win64
)
if "%MSVC_VERSION%"=="12" (
set CMAKE_GENERATOR=Visual Studio 12 2013 Win64
)
if "!CMAKE_GENERATOR!"=="" (
echo ERROR: Unsupported MSVC version
exit /B 1
)
) else (
set CMAKE_GENERATOR=Ninja
)
echo INFO: ============================================================
echo INFO: Summary:
echo INFO: ============================================================
echo INFO: MSVC_VERSION = !MSVC_VERSION!
echo INFO: WITH_NINJA = !WITH_NINJA!
echo INFO: CMAKE_GENERATOR = "!CMAKE_GENERATOR!"
echo INFO: CPU_ONLY = !CPU_ONLY!
echo INFO: USE_CUDA = !USE_CUDA!
echo INFO: CUDA_ARCH_NAME = !CUDA_ARCH_NAME!
echo INFO: USE_CUDNN = !USE_CUDNN!
echo INFO: USE_GREENTEA = !USE_GREENTEA!
echo INFO: USE_LIBDNN = !USE_LIBDNN!
echo INFO: USE_OPENMP = !USE_OPENMP!
echo INFO: USE_INDEX64 = !USE_INDEX_64!
echo INFO: USE_INTEL_SPATIAL = !USE_INTEL_SPATIAL!
echo INFO: DISABLE_DEVICE_HOST_UNIFIED_MEMORY = !DISABLE_DEVICE_HOST_UNIFIED_MEMORY!
echo INFO: CMAKE_CONFIG = !CMAKE_CONFIG!
echo INFO: USE_NCCL = !USE_NCCL!
echo INFO: CMAKE_BUILD_SHARED_LIBS = !CMAKE_BUILD_SHARED_LIBS!
echo INFO: PYTHON_VERSION = !PYTHON_VERSION!
echo INFO: BUILD_PYTHON = !BUILD_PYTHON!
echo INFO: BUILD_PYTHON_LAYER = !BUILD_PYTHON_LAYER!
echo INFO: BUILD_MATLAB = !BUILD_MATLAB!
echo INFO: PYTHON_EXE = "!PYTHON_EXE!"
echo INFO: RUN_TESTS = !RUN_TESTS!
echo INFO: RUN_LINT = !RUN_LINT!
echo INFO: RUN_INSTALL = !RUN_INSTALL!
echo INFO: ============================================================
:: Build and exectute the tests
:: Do not run the tests with shared library
if !RUN_TESTS! EQU 1 (
if %CMAKE_BUILD_SHARED_LIBS% EQU 1 (
echo WARNING: Disabling tests with shared library build
set RUN_TESTS=0
)
)
if NOT EXIST build mkdir build
pushd build
:: Setup the environement for VS x64
set batch_file=!VS%MSVC_VERSION%0COMNTOOLS!..\..\VC\vcvarsall.bat
call "%batch_file%" amd64
:: Configure using cmake and using the caffe-builder dependencies
:: Add -DCUDNN_ROOT=C:/Projects/caffe/cudnn-8.0-windows10-x64-v5.1/cuda ^
:: below to use cuDNN
cmake -G"!CMAKE_GENERATOR!" ^
-DBLAS=Open ^
-DCMAKE_BUILD_TYPE:STRING=%CMAKE_CONFIG% ^
-DBUILD_SHARED_LIBS:BOOL=%CMAKE_BUILD_SHARED_LIBS% ^
-DBUILD_python:BOOL=%BUILD_PYTHON% ^
-DBUILD_python_layer:BOOL=%BUILD_PYTHON_LAYER% ^
-DBUILD_matlab:BOOL=%BUILD_MATLAB% ^
-DCPU_ONLY:BOOL=%CPU_ONLY% ^
-DUSE_CUDA:BOOL=%USE_CUDA% ^
-DUSE_CUDNN:BOOL=%USE_CUDNN% ^
-DUSE_LIBDNN:BOOL=%USE_LIBDNN% ^
-DUSE_GREENTEA:BOOL=%USE_GREENTEA% ^
-DUSE_OPENMP:BOOL=%USE_OPENMP% ^
-DUSE_INDEX64:BOOL=%USE_INDEX64% ^
-DUSE_INTEL_SPATIAL:BOOL=%USE_INTEL_SPATIAL% ^
-DDISABLE_DEVICE_HOST_UNIFIED_MEMORY=%DISABLE_DEVICE_HOST_UNIFIED_MEMORY% ^
-DCOPY_PREREQUISITES:BOOL=1 ^
-DINSTALL_PREREQUISITES:BOOL=1 ^
-DUSE_NCCL:BOOL=!USE_NCCL! ^
-DCUDA_ARCH_NAME:STRING=%CUDA_ARCH_NAME% ^
"%~dp0\.."
if ERRORLEVEL 1 (
echo ERROR: Configure failed
exit /b 1
)
:: Lint
if %RUN_LINT% EQU 1 (
cmake --build . --target lint --config %CMAKE_CONFIG%
)
if ERRORLEVEL 1 (
echo ERROR: Lint failed
exit /b 1
)
:: Build the library and tools
cmake --build . --config %CMAKE_CONFIG%
if ERRORLEVEL 1 (
echo ERROR: Build failed
exit /b 1
)
:: Build and exectute the tests
if !RUN_TESTS! EQU 1 (
cmake --build . --target runtest --config %CMAKE_CONFIG%
if ERRORLEVEL 1 (
echo ERROR: Tests failed
exit /b 1
)
if %BUILD_PYTHON% EQU 1 (
if %BUILD_PYTHON_LAYER% EQU 1 (
:: Run python tests only in Release build since
:: the _caffe module is _caffe-d is debug
if "%CMAKE_CONFIG%"=="Release" (
:: Run the python tests
cmake --build . --target pytest
if ERRORLEVEL 1 (
echo ERROR: Python tests failed
exit /b 1
)
)
)
)
)
if %RUN_INSTALL% EQU 1 (
cmake --build . --target install --config %CMAKE_CONFIG%
)
popd
#endlocal
it's all

Why my function in .vimrc got called automatically?

As I know, we could define function in .vimrc as below:
function Fun()
do something here
endfunction
Then we could call it like :call Fun().
For one of my system, there's only the function definition in my .vimrc, however the function is always exectued once I get into vim. Why?
Below is version of my vim:
# vi --version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Feb 17 2012 10:24:10)
Included patches: 1-411
Modified by <bugzilla#redhat.com>
Compiled by <bugzilla#redhat.com>
Small version without GUI. Features included (+) or not (-):
-arabic -autocmd -balloon_eval -browse +builtin_terms -byte_offset -cindent
-clientserver -clipboard -cmdline_compl +cmdline_hist -cmdline_info -comments
-cryptv -cscope -cursorshape -dialog -diff -digraphs -dnd -ebcdic -emacs_tags
-eval -ex_extra -extra_search -farsi -file_in_path -find_in_path -float
-folding -footer +fork() -gettext -hangul_input +iconv -insert_expand +jumplist
-keymap -langmap -libcall -linebreak -lispindent -listcmds -localmap -menu
-mksession -modify_fname -mouse -mouse_dec -mouse_gpm -mouse_jsbterm
-mouse_netterm -mouse_sysmouse -mouse_xterm +multi_byte -multi_lang -mzscheme
-netbeans_intg -osfiletype -path_extra -perl -printer -profile -python
-quickfix -reltime -rightleft -ruby -scrollbind -signs -smartindent -sniff
-startuptime -statusline -sun_workshop -syntax -tag_binary -tag_old_static
-tag_any_white -tcl +terminfo -termresponse -textobjects -title -toolbar
-user_commands -vertsplit -virtualedit +visual -visualextra -viminfo -vreplace
+wildignore -wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp
-xterm_clipboard -xterm_save
system vimrc file: "/etc/virc"
user vimrc file: "$HOME/.vimrc"
user exrc file: "$HOME/.exrc"
fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -O2 -g -pipe -Wall -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=1
Linking: gcc -L/usr/local/lib -o vim -lm -lselinux -lncurses -lacl
And my .vimrc:
# cat ~/.vimrc
function Fun1()
:!ls
endfunction
Function name doesn't matter, I've changed the name as a test.
Update on July 8, 2015:
According to the answer from Ben, and since I'd like my .vimrc be compatible over multiple environments, I wrap the function definition with if has('eval')...endif as my finial solution:
if has('eval')
function! Fun1()
do something
endfunction
endif
Your vim is compiled without "eval" support. That means your Vim does not support defining functions. The opening function Fun1() command is therefore invalid, and ignored. Then the function definition is executed because those are valid commands.
You will need to install a more fully-featured Vim, or compile your own Vim, or find an alternate Vim installation on your system that has more features. "eval" comes with a NORMAL or larger feature set.

octave cannot find fltk XGetUtf8FontAndGlyph symbol

octave 3.8.2 produces this error on loading:
error: /usr/lib64/octave/3.8.2/oct/x86_64-pc-linux-gnu/PKG_ADD: /usr/lib64/octave/3.8.2/oct/x86_64-pc-linux-gnu/__init_fltk__.oct: failed to load: /usr/lib64/fltk/libfltk_gl.so.1.3: undefined symbol: XGetUtf8FontAndGlyph
error: called from:
error: /usr/lib64/octave/3.8.2/oct/x86_64-pc-linux-gnu/PKG_ADD at line 6, column 1
GNU Octave, version 3.8.2
I obtain the following information about configuration of graphics libraries
octave:1> octave_config_info().GRAPHICS_LIBS
ans = -L/usr/lib64/fltk -Wl,-rpath,/usr/lib64/fltk -Wl,-O1 -Wl,--sort-common -Wl,--as-needed -lfltk_gl -lGLU -lGL -lfltk -lXcursor -lXfixes -lXext -ldl -lm -lX11
and although no graphic toolkits are evidently loaded initially,
octave:2> available_graphics_toolkits
ans = {}(1x0)
I can register them subsequently,
octave:3> register_graphics_toolkit("gnuplot")
octave:4> available_graphics_toolkits
ans =
{
[1,1] = gnuplot
}
octave:5> register_graphics_toolkit("fltk")
octave:6> available_graphics_toolkits
ans =
{
[1,1] = fltk
[1,2] = gnuplot
}
but attempting to load fltk produces an error consistent with the initial warning
octave:7> graphics_toolkit("fltk")
error: feval: /usr/lib64/octave/3.8.2/oct/x86_64-pc-linux-gnu/__init_fltk__.oct: failed to load: /usr/lib64/fltk/libfltk_gl.so.1.3: undefined symbol: XGetUtf8FontAndGlyph
error: called from:
error: /usr/share/octave/3.8.2/m/plot/util/graphics_toolkit.m at line 74, column 5
and of course attempting to plot anything also fails,
octave:8> plot(1:10)
error: feval: /usr/lib64/octave/3.8.2/oct/x86_64-pc-linux-gnu/__init_fltk__.oct: failed to load: /usr/lib64/fltk/libfltk_gl.so.1.3: undefined symbol: XGetUtf8FontAndGlyph
error: called from:
error: /usr/share/octave/3.8.2/m/plot/util/graphics_toolkit.m at line 74, column 5
error: failed to load fltk graphics toolkit
error: base_graphics_toolkit::initialize: invalid graphics toolkit
error: /usr/share/octave/3.8.2/m/plot/util/figure.m at line 94, column 9
error: /usr/share/octave/3.8.2/m/plot/util/gcf.m at line 63, column 9
error: /usr/share/octave/3.8.2/m/plot/util/newplot.m at line 113, column 8
error: /usr/share/octave/3.8.2/m/plot/draw/plot.m at line 219, column 9
Both octave and fltk were compiled from source under gentoo:
x11-libs/fltk-1.3.3-r2:1 USE="opengl -cairo -debug -doc -examples -games -pdf -static-libs -threads -xft -xinerama"
sci-mathematics/octave-3.8.2:0/3.8.2 USE="X doc glpk gnuplot gui imagemagick opengl qhull qrupdate readline sparse zlib -curl -fftw -hdf5 -java -jit -postscript -static-libs"
resulting in configure switches of (for the fltk library):
./configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --includedir=/usr/include/fltk --libdir=/usr/lib64/fltk --docdir=/usr/share/doc/fltk-1.3.3-r2/html --enable-largefile --enable-shared --enable-xdbe --disable-localjpeg --disable-localpng --disable-localzlib --disable-debug --disable-cairo --enable-gl --disable-threads --disable-xft --disable-xinerama
and (for octave)
./configure --prefix=/usr --build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu --mandir=/usr/share/man --infodir=/usr/share/info --datadir=/usr/share --sysconfdir=/etc --localstatedir=/var/lib --libdir=/usr/lib64 --disable-silent-rules --disable-dependency-tracking --docdir=/usr/share/doc/octave-3.8.2 --enable-shared --disable-static --localstatedir=/var/state/octave --with-blas=-L/usr/lib64/blas/reference -lblas --with-lapack=-llapack -L/usr/lib64/blas/reference -lblas --enable-docs --disable-java --enable-gui --disable-jit --enable-readline --without-curl --without-fftw3 --without-fftw3f --disable-fftw-threads --with-glpk --without-hdf5 --with-opengl --with-qhull --with-qrupdate --with-arpack --with-umfpack --with-colamd --with-ccolamd --with-cholmod --with-cxsparse --with-x --with-z --with-magick=GraphicsMagick
If I examine libfltk_gl.so.1.3 with nm, I see that the following symbols are exported:
$ nm -D /usr/lib64/fltk/libfltk_gl.so.1.3
U XCreateColormap
U XGetUtf8FontAndGlyph
w _ITM_deregisterTMCloneTable
w _ITM_registerTMCloneTable
w _Jv_RegisterClasses
U _Z10fl_measurePKcRiS1_i
000000000000e170 T _Z10gl_descentv
000000000000e590 T _Z10gl_measurePKcRiS1_
... <snip>
According to nm manual, the U designates that the symbol is global (external) but unknown. My question is whether this unknown symbol status is the origin of the error reported from octave, suggesting that the problem lies with how fltk was compiled, or whether the octave compilation is somehow at fault.
Edit: Solved by enabling Xft support: Please see comments below, and I thank Andy again for his help.
XGetUtf8FontAndGlyph should be in libfltk.so.1.3.
nm -D /usr/lib/x86_64-linux-gnu/libfltk.so.1.3 |grep XGetU
00000000000c2fc0 T XGetUtf8FontAndGlyph
It's very likely that this is a problem with your configure flags for fltk and not GNU Octave. Just try it with the default settings first.
You can test if the UTF8 stuff with OpenGL is okay with the "cube" test. Just digg into the fltk-source dir tests:
cd fltk-1.3.3/test
make cube && ./cube
Does the text in the lower left of the GL window show up?
Had a similar problem. Was getting the following error while trying to run octave (undefined symbol: _ZN18Fl_XFont_On_Demand5valueEv):
bash-4.3$ octave
error: /usr/local/lib/octave/4.0.2/oct/i686-pc-linux-gnu/PKG_ADD: /usr/local/lib/octave/4.0.2/oct/i686-pc-linux-gnu/__init_fltk__.oct: failed to load: /usr/lib/libfltk_gl.so.1.3: undefined symbol: _ZN18Fl_XFont_On_Demand5valueEv
error: called from
/usr/local/lib/octave/4.0.2/oct/i686-pc-linux-gnu/PKG_ADD at line 3 column 1
Command nm -D /usr/lib/libfltk_gl.so.1.3 showed that symbol _ZN18Fl_XFont_On_Demand5valueEv is undefined (with U):
0000a3d4 T _ZN14Fl_Glut_WindowD1Ev
0000a3d4 T _ZN14Fl_Glut_WindowD2Ev
U _ZN18Fl_Font_DescriptorD1Ev
U _ZN18Fl_Graphics_Driver11clip_regionEP8_XRegion
U _ZN18Fl_XFont_On_Demand5valueEv
The solution was to apply a patch file mentioned here to some files inside source directory of FLTK-1.3.3 and then recompile and reinstall FLTK. Now octave works with FLTK without any problem.

Undefined symbol error when testing Netezza UDX

I'm trying to implement a Netezza UDX that uses R language through Rserve (therefore I use Rconnection library for C++). Currently I've written only the bare minimum required for the UDX to run.
It looks as follows:
#define MAIN
// Netezza UDX libraries
#include "udxinc.h"
#include "udxhelpers.h"
// C++ libraries
#include <cstdlib>
#include <cstring>
// external Rserve and R headers
#include "Rconnection.h"
#include "sisocks.h"
using namespace nz::udx::dthelpers;
using namespace nz::udx_ver2;
// extends UDF base class
class My_UDX : public Udf {
public:
Rconnection * rc;
My_UDX(UdxInit *pInit) : Udf(pInit) {
initsocks();
// IP address in place of ...
rc = new Rconnection("...", 6311);
};
~My_UDX() {
delete rc;
}
static Udf* instantiate(UdxInit *pInit);
virtual ReturnValue evaluate();
};
Udf* My_UDX::instantiate(UdxInit *pInit) {
return new My_UDX(pInit);
}
// called once for each row of data during execution
ReturnValue My_UDX::evaluate() {
int32 retval = 15;
NZ_UDX_RETURN_INT32(retval);
}
The problem arises when I try to test the UDX with a SQL query. My query looks like this:
SELECT * FROM table_name WHERE My_UDX(table_field) = 1;
And this is the error message I get:
Testing...
nzsql -d database_name -u my_username -pw my_password -f sql/test.sql
nzsql:sql/test.sql:1: ERROR: /dev/shm/spuplans/63_1_3.o: undefined symbol: _ZN11RconnectionC1EPKci : loading executable code
make: *** [update] Error 2
If I remove the Rconnection object, UDX works just fine.
I've checked different manuals about Netezza UDXs, Rserve, and Rconnection but with no results. Couldn't find any explanation to this error and what could be done to resolve it.
Then I assumed there might be something wrong with the compiling process, inclusion of needed libraries and flags. I'm not so familiar with makefiles so this is quite a possibility. My makefile looks like so:
# list of files
function_name = My_UDX
object_files = $(function_name).o_x86
spu_files = $(function_name).o_spu10
# database connection
db_call = nzsql -d database_name -u my_username -pw my_password -f
# path to directories
lib_dir = /home/nz/libs
r_connection_dir = /home/nz/Rconnection
all: update
update: compile
$(db_call) sql/unload.sql
cp $(object_files) $(lib_dir)
cp $(spu_files) $(lib_dir)
rm -f *.o_spu10 *.o_x86
$(db_call) sql/create.sql
$(db_call) sql/test.sql
compile:
nzudxcompile $(function_name).cpp --args -I$(r_connection_dir)
unload.sql just drops the previously loaded function and create.sql just creates it. The problem arises only when the test.sql with the previously shown SQL query is executed.
Have been trying to resolve this issue for quite a long time so any help would be appreciated!
As mentioned above by Alex, Rconnection had to be loaded as a shared library or compiled along with the UDF. Solved this by compiling with the UDF.
# for host environment
nzudxcompile --host Rconnection.cpp -o temp_rconnection.o_x86
nzudxcompile --host myudf.cpp -o temp_myudf.o_x86
nzudxcompile --host --objs temp_rconnection.o_x86 --objs temp_myudf.o_x86 -o myudf.o_x86
# for spu environment
nzudxcompile Rconnection.cpp --spu -o temp_rconnection.o_spu10
nzudxcompile myudf.cpp --spu -o temp_myudf.o_spu10
nzudxcompile --spu --objs temp_rconnection.o_spu10 --objs temp_myudf.o_spu10 -o myudf.o_spu10