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.
Related
I am trying to use this pandoc filter to convert markdown to HTML.
This is the example file:
gantt
dateFormat YYYY-MM-DD
title Adding GANTT diagram functionality to mermaid
section A section
Completed task :done, des1, 2014-01-06,2014-01-08
Active task :active, des2, 2014-01-09, 3d
Future task : des3, after des2, 5d
Future task2 : des4, after des3, 5d
section Critical tasks
Completed task in the critical line :crit, done, 2014-01-06,24h
Implement parser and jison :crit, done, after des1, 2d
Create tests for parser :crit, active, 3d
Future task in critical line :crit, 5d
Create tests for renderer :2d
Add to mermaid :1d
This is the command that I am running:
pandoc file.md -f markdown -o out.html --filter=pandoc-mermaid
This is the error message:
File "D:\Anaconda3\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "D:\Anaconda3\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "D:\Anaconda3\Scripts\pandoc-mermaid.exe\__main__.py", line 7, in <module>
File "D:\Anaconda3\lib\site-packages\pandoc_mermaid_filter.py", line 38, in main
toJSONFilter(mermaid)
File "D:\Anaconda3\lib\site-packages\pandocfilters.py", line 130, in toJSONFilter
toJSONFilters([action])
File "D:\Anaconda3\lib\site-packages\pandocfilters.py", line 164, in toJSONFilters
sys.stdout.write(applyJSONFilters(actions, source, format))
File "D:\Anaconda3\lib\site-packages\pandocfilters.py", line 195, in applyJSONFilters
altered = walk(altered, action, format, meta)
File "D:\Anaconda3\lib\site-packages\pandocfilters.py", line 123, in walk
return {k: walk(v, action, format, meta) for k, v in x.items()}
File "D:\Anaconda3\lib\site-packages\pandocfilters.py", line 123, in <dictcomp>
return {k: walk(v, action, format, meta) for k, v in x.items()}
File "D:\Anaconda3\lib\site-packages\pandocfilters.py", line 110, in walk
res = action(item['t'],
File "D:\Anaconda3\lib\site-packages\pandoc_mermaid_filter.py", line 31, in mermaid
subprocess.check_call([MERMAID_BIN, "-i", src, "-o", dest])
File "D:\Anaconda3\lib\subprocess.py", line 359, in check_call
retcode = call(*popenargs, **kwargs)
File "D:\Anaconda3\lib\subprocess.py", line 340, in call
with Popen(*popenargs, **kwargs) as p:
File "D:\Anaconda3\lib\subprocess.py", line 858, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "D:\Anaconda3\lib\subprocess.py", line 1311, in _execute_child
hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] El sistema no puede encontrar el archivo especificado
Error running filter pandoc-mermaid:
Filter returned error status 1
The folder where the executable is located is apparently added to path. Any ideas on how I could fix it?
Specifications:
Windows 10 Home
pandoc 2.14.0.1
Thanks
Not solving the problem but providing a different way to achieve the same and in case it's useful to others who arrive here:
Mermaid-cli has the feature to act as a preprocessor for Markdown.
As such, you can do the following:
mkdir build
npx -p #mermaid-js/mermaid-cli mmdc -i file.md -o build/output-svg.md
# Generates lots of output-svg-1.svg files linked from the doc
cd build
pandoc output-svg.md -o output.html
It defaults to SVG images (which generally works fine for HTML but fails when targeting PDF). It has a less well documented feature to force PNG generation.
npx -p #mermaid-js/mermaid-cli mmdc -i file.md --outputFormat=png -o build/output-png.md
# Generates lots of output-png-1.png files linked from the doc
cd build
pandoc output-png.md -o output.pdf
I found success with the NPM library which adds a similar Mermaid filter for Pandoc: raghur/mermaid-filter.
You should be able to do:
pandoc file.md -f markdown -o out.html --filter=mermaid-filter
IMPORTANT: On Windows, you need to specify the filter as --filter mermaid-filter.cmd instead of --filter mermaid-filter (I missed this at first and was very confused)
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
CUDA distributions on Linux used to have a file named version.txt which read, e.g.:
CUDA Version 10.2.89
which is quite useful. However, as of CUDA 11.1, this file no longer exists.
How can I determine, on Linux and from the command line, and inspecting /path/to/cuda/toolkit, which exact version I'm looking at? Including the subversion?
(Answer due to #RobertCrovella's comment)
This will do the trick:
/path/to/cuda/toolkit/bin/nvcc --version | egrep -o "V[0-9]+.[0-9]+.[0-9]+" | cut -c2-
And of course, for the CUDA version currently chosen and configured to be used, just take the nvcc that's on the path:
nvcc --version | egrep -o "V[0-9]+.[0-9]+.[0-9]+" | cut -c2-
For example: You would get 11.2.67 for the download of CUDA 11.2 which was available this week on the NVIDIA website.
The full nvcc --version output would be:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2020 NVIDIA Corporation
Built on Mon_Nov_30_19:08:53_PST_2020
Cuda compilation tools, release 11.2, V11.2.67
Build cuda_11.2.r11.2/compiler.29373293_0
The following python code works well for both Windows and Linux and I have tested it with a variety of CUDA (8-11.2, most of them).
It searches for the cuda_path, via a series of guesses (checking environment vars, nvcc locations or default installation paths) and then grabs the CUDA version from the output of nvcc --version. Doesn't use #einpoklum's style regexp, it simply assumes there is only one release string within the output of nvcc --version, but that can be simply checked.
You can also just use the first function, if you have a known path to query.
Adding it as an extra of #einpoklum answer, does the same thing, just in python.
From TIGRE.
import glob
import os
from os.path import join as pjoin
import subprocess
import sys
def get_cuda_version(cuda_home):
"""Locate the CUDA version
"""
version_file = os.path.join(cuda_home, "version.txt")
try:
if os.path.isfile(version_file):
with open(version_file) as f:
version_str = f.readline().replace('\n', '').replace('\r', '')
return version_str.split(" ")[2][:4]
else:
version_str = subprocess.check_output([os.path.join(cuda_home,"bin","nvcc"),"--version"])
version_str=str(version_str).replace('\n', '').replace('\r', '')
idx=version_str.find("release")
return version_str[idx+len("release "):idx+len("release ")+4]
except:
raise RuntimeError("Cannot read cuda version file")
def locate_cuda():
"""Locate the CUDA environment on the system
Returns a dict with keys 'home', 'include' and 'lib64'
and values giving the absolute path to each directory.
Starts by looking for the CUDA_HOME or CUDA_PATH env variable. If not found, everything
is based on finding 'nvcc' in the PATH.
"""
# Guess #1
cuda_home = os.environ.get('CUDA_HOME') or os.environ.get('CUDA_PATH')
if cuda_home is None:
# Guess #2
try:
which = 'where' if IS_WINDOWS else 'which'
nvcc = subprocess.check_output(
[which, 'nvcc']).decode().rstrip('\r\n')
cuda_home = os.path.dirname(os.path.dirname(nvcc))
except subprocess.CalledProcessError:
# Guess #3
if IS_WINDOWS:
cuda_homes = glob.glob(
'C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v*.*')
if len(cuda_homes) == 0:
cuda_home = ''
else:
cuda_home = cuda_homes[0]
else:
cuda_home = '/usr/local/cuda'
if not os.path.exists(cuda_home):
cuda_home = None
version = get_cuda_version(cuda_home)
cudaconfig = {'home': cuda_home,
'include': pjoin(cuda_home, 'include'),
'lib64': pjoin(cuda_home, pjoin('lib', 'x64') if IS_WINDOWS else 'lib64')}
if not all([os.path.exists(v) for v in cudaconfig.values()]):
raise EnvironmentError(
'The CUDA path could not be located in $PATH, $CUDA_HOME or $CUDA_PATH. '
'Either add it to your path, or set $CUDA_HOME or $CUDA_PATH.')
return cudaconfig, version
CUDA, CUDA_VERSION = locate_cuda()
I am trying to write a simple Ada (with AWS) program to post data to a server. The curl command is working as follows and return a valid response in JSON after successful login:
curl -XPOST -d '{"type":"m.login.password", "user":"xxx", "password": "xxxxxxxxxx"}' "https://matrix.org/_matrix/client/r0/login"
My Ada program:
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Text_Io; use Ada.Text_IO;
with AWS.Client;
with AWS.Communication.Client;
with AWS.MIME;
with AWS.Net;
with AWS.Response;
use AWS;
procedure Communicate is
Result : Response.Data;
Data : String := "{""type"":""m.login.password"", ""user"":""xxx"", ""password"": ""xxxxxxxxxx""}";
begin
Result := Client.Post
( URL => "https://matrix.org/_matrix/client/r0/login",
Data => Data,
Content_Type => AWS.MIME.Application_JSON ) ;
Put_Line ( Response.Message_Body ( Result ) ) ;
end Communicate;
An exception was raised. I can't figure out what is wrong with this code.
$ ./Communicate
raised PROGRAM_ERROR : aws-client.adb:543 finalize/adjust raised exception
To test the code, you can create an account at http://matrix.org and replace the login credential.
Thanks.
Adrian
After a few minor changes (mostly because I don't like compiler warnings), and an adaption to the Debian/Jessie version of AWS, I got it to work.
Here's the adapted version:
with Ada.Text_IO; use Ada.Text_IO;
with AWS.Client;
-- with AWS.MIME;
with AWS.Response;
use AWS;
procedure Communicate is
Result : Response.Data;
Data : constant String :=
"{""type"":""m.login.password"", ""user"":""xxx"", " &
"""password"": ""xxxxxxxxxx""}";
begin
Result := Client.Post
(URL => "https://matrix.org/_matrix/client/r0/login",
Data => Data,
Content_Type => "application/json");
-- Content_Type => AWS.MIME.Application_JSON);
Put_Line (Response.Message_Body (Result));
end Communicate;
Here is my project file:
with "aws";
project Communicate is
for Main use ("communicate");
package Builder is
for Default_Switches ("Ada")
use ("-m");
end Builder;
package Compiler is
for Default_Switches ("Ada")
use ("-fstack-check", -- Generate stack checking code (part of Ada)
"-gnata", -- Enable assertions (part of Ada)
"-gnato13", -- Overflow checking (part of Ada)
"-gnatf", -- Full, verbose error messages
"-gnatwa", -- All optional warnings
"-gnatVa", -- All validity checks
"-gnaty3abcdefhiklmnoOprstux", -- Style checks
"-gnatwe", -- Treat warnings as errors
"-gnat2012", -- Use Ada 2012
"-Wall", -- All GCC warnings
"-O2"); -- Optimise (level 2/3)
end Compiler;
end Communicate;
I built the program with:
% gprbuild -P communicate
gnatgcc -c -fstack-check -gnata -gnato13 -gnatf -gnatwa -gnatVa -gnaty3abcdefhiklmnoOprstux -gnatwe -gnat2012 -Wall -O2 communicate.adb
gprbind communicate.bexch
gnatbind communicate.ali
gnatgcc -c b__communicate.adb
gnatgcc communicate.o -L/usr/lib/x86_64-linux-gnu -lgnutls -lz -llber -lldap -lpthread -o communicate
%
And then tested with:
% ./communicate
{"errcode":"M_FORBIDDEN","error":"Invalid password"}
%
It looks like the problem is located in your AWS version/installation.
Problem resolved by building AWS with gnutls from MacPorts. Apple deprecated OpenSSL since OS X Lion and used CommonCrypto so modern macOS does not come with OpenSSL. The solution is to download and install OpenSSL or gnutls from Mac Ports or Home Brew.
Another problem is that Apple introduced SIP (System Integrity Protection) since El Capitan. With SIP enabled, user with administrator's rights is unable to change the contents in /usr/include and /usr/lib etc.
Mac Ports installs to /opt/local so I made references to /opt/local/include and /opt/local/lib so that AWS can build with either OpenSSL or gnutls.
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.