Building Matlab and /usr/bin/ld: cannot find -lgfortran - matlab

I try to use mex some toolbox using matlab. But I got these errors: /usr/bin/ld: cannot find -lgfortran
I used Ubuntu 14.04. I installed gfortran. Could any one help ?
this is the output of : ldconfig -p | grep fortran
xiaoma#laptop:~$ ldconfig -p | grep fortran
libhdf5hl_fortran.so.7 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libhdf5hl_fortran.so.7
libhdf5_fortran.so.7 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libhdf5_fortran.so.7
libgfortran.so.3 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libgfortran.so.3

Related

Need help on LFS-7.10 Pass2 binutils configure error

I have been working on resolving issues in build scripts that were built based on LFS a few years
back. I tried over the last week and tried multiple versions and solutions from different sites.
Learned a lot as I put more effort. I need your help as I couldn't get the reason behind the issue.
Based on LFS, pass 1 completed and dummy.c file execution was a success. Then I get the error in
binutils in pass 2.
http://www.linuxfromscratch.org/lfs/view/7.10-systemd/chapter05/binutils-pass2.html GCC 6.2.0
binutils 2.27
glibc 2.24
Edit:
Let me try with a recent version of LFS as suggested
train#ubuntu:~$ uname -a Linux ubuntu 4.15.0-112-generic #113~16.04.1-Ubuntu SMP Fri Jul 10 04:37:08
UTC 2020 x86_64 x86_64 x86_64 GNU/Linux train#ubuntu:~$ gcc --version gcc (Ubuntu 5.4.0-
6ubuntu1~16.04.12) 5.4.0 20160609 train#ubuntu:~$ ldd --version ldd (Ubuntu GLIBC 2.23-0ubuntu11.2)
2.23
train#ubuntu:~$ gcc dummy.c train#ubuntu:~$ readelf -l a.out | grep linux [Requesting program
interpreter: /lib64/ld-linux-x86-64.so.2] train#ubuntu:~$ /tools/bin/x86_64-tc-linux-gnu-gcc dummy.c
train#ubuntu:~$ readelf -l a.out | grep linux [Requesting program interpreter: /tools/lib64/ld-linux-
x86-64.so.2]
cd binutils-2.27-compile; CXXFLAGS="-O2 -m64 -fPIC" CFLAGS="-O2 -m64 -fPIC" CC=x86_64-tc-linux-gnu-gcc
AR=x86_64-tc-linux-gnu-ar RANLIB=x86_64-tc-linux-gnu-ranlib ../binutils-2.27/configure --prefix=/tools
******* Contents from config log **************
configure:2297: checking build system type
configure:2311: result: x86_64-pc-linux-gnu
configure:2358: checking host system type
configure:2371: result: x86_64-pc-linux-gnu
configure:2391: checking target system type
configure:2404: result: x86_64-pc-linux-gnu
configure:2458: checking for a BSD-compatible install
configure:2526: result: /usr/bin//install -c
configure:2537: checking whether ln works
configure:2559: result: yes
configure:2563: checking whether ln -s works
configure:2567: result: yes
configure:2574: checking for a sed that does not truncate output
configure:2638: result: /bin/sed
configure:2647: checking for gawk
configure:2663: found /usr/bin//gawk
configure:2674: result: gawk
configure:4121: checking for gcc
configure:4148: result: x86_64-tc-linux-gnu-gcc
configure:4377: checking for C compiler version
configure:4386: x86_64-tc-linux-gnu-gcc --version >&5
x86_64-tc-linux-gnu-gcc (GCC) 6.2.0
Copyright (C) 2016 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
configure:4397: $? = 0
configure:4386: x86_64-tc-linux-gnu-gcc -v >&5
Using built-in specs.
COLLECT_GCC=x86_64-tc-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/home/train/swe/distrib/tools/bin/../libexec/gcc/x86_64-tc-linux-gnu/6.2.0/lto-
wrapper
Target: x86_64-tc-linux-gnu
Configured with: ../gcc-6.2.0/configure --prefix=/tools --target=x86_64-tc-linux-gnu --prefix=/tools
--with-sysroot=/home/train/swe/distrib --with-newlib --without-headers --with-local-prefix=/tools --
with-native-system-header-dir=/tools/include --disable-nls --disable-shared --disable-multilib --
disable-decimal-float --disable-threads --disable-libmudflap --disable-libssp --disable-libatomic --
disable-libstdcxx --disable-libmpx --disable-libgomp --disable-libvtv --disable-libquadmath --enable-
languages=c,c++
Thread model: single
gcc version 6.2.0 (GCC)
configure:4397: $? = 0
configure:4386: x86_64-tc-linux-gnu-gcc -V >&5
x86_64-tc-linux-gnu-gcc: error: unrecognized command line option '-V'
x86_64-tc-linux-gnu-gcc: fatal error: no input files
compilation terminated.
configure:4397: $? = 1
configure:4386: x86_64-tc-linux-gnu-gcc -qversion >&5
x86_64-tc-linux-gnu-gcc: error: unrecognized command line option '-qversion'; did you mean '--
version'?
x86_64-tc-linux-gnu-gcc: fatal error: no input files
compilation terminated.
configure:4397: $? = 1
configure:4417: checking for C compiler default output file name
configure:4439: x86_64-tc-linux-gnu-gcc -O2 -m64 -fPIC conftest.c >&5
configure:4443: $? = 0
configure:4480: result: a.out
configure:4496: checking whether the C compiler works
configure:4505: ./a.out
../binutils-2.27/
configure: line 4507: 87493 Segmentation fault (core dumped) ./$ac_file
configure:4509: $? = 139
configure:4516: error: in `/home/train/swe/distrib/build/sources/binutils/binutils-2.27-compile':
configure:4520: error: cannot run C compiled programs.
If you meant to cross compile, use --host'. See config.log' for more details.
Would appreciate any help on this

Compiling perl Net::Interface module on CentOS 8.1 fails

I download the sources and manually tried to compile the perl Net::Interface module. Using CPAN to install the module gives the same error.
wget http://search.cpan.org/CPAN/authors/id/M/MI/MIKER/Net-Interface-1.016.tar.gz
tar xvfz Net-Interface-1.016.tar.gz
cd Net-Interface-1.016
perl Makefile.PL
Now this fails with the below error
checking for getnameinfo... yes
checking whether byte ordering is bigendian... no
checking for uint8_t... yes
checking size of uint8_t... configure: error: cannot compute sizeof (uint8_t)
See `config.log' for more details.
could not open config.h
config.log shows the below error
configure:10128: result: yes
configure:10135: checking size of uint8_t
configure:10437: gcc -o conftest -g -O2 -Wl,-z,relro -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -fstack-protector-strong -L/usr/local/lib conftest.c >&5
/usr/bin/ld: /tmp/ccXH6miX.o: relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
configure:10440: $? = 1
configure: program exited with status 1
configure: failed program was:
| /* confdefs.h. */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
How can I fix this error? config.log seems to suggest to pass "-fPIC" flag but I am not sure how?
Thanks.
/usr/bin/ld: /tmp/ccXH6miX.o: relocation R_X86_64_32 against
`.rodata.str1.1' can not be used when making a PIE object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
The configure script needs to be run with --enable-shared for some reason (it is not necessary on Ubuntu). The following worked for me in a docker container with CentOS 8:
./configure --enable-shared
perl -I. Makefile.PL
make
sudo make install

linking problem, can't find symbol even though nm shows symbol in library

I'm linking an app against lflutter_linux_glfw. nm tools shows it has glad_glTexImage2D:
nm libflutter_linux_glfw.so | grep glTexImage2D
00000000034e87a0 b glad_glTexImage2D
00000000034e87a8 b glad_glTexImage2DMultisample
So I included lflutter_linux_glfw.so before flutter_video_renderer.o, and I get this:
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.4.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0
Candidate multilib: .;#m64
Selected multilib: .;#m64
"/usr/bin/ld" -z relro --hash-style=gnu --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o /home/dev/orwell/orwell_flutter/linux/../build/linux/debug/flutter_desktop_example
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../x86_64-linux-gnu/crt1.o /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../x86_64-linux-gnu/crti.o /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/crtbegin.o
-L/home/dev/orwell/orwell_flutter/linux/../build/linux/debug/lib -L/usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0 -L/usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu
-L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../.. -L/usr/lib/llvm-6.0/bin/../lib -L/lib -L/usr/lib -lflutter_linux_glfw
/home/dev/orwell/orwell_flutter/linux/../build/linux/obj/main.o /home/dev/orwell/orwell_flutter/linux/../build/linux/obj/flutter/generated_plugin_registrant.o
/home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/linux/flutter/ephemeral/cpp_client_wrapper_glfw/flutter_window_controller.o
/home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/linux/flutter/ephemeral/cpp_client_wrapper_glfw/plugin_registrar.o
/home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/linux/flutter/ephemeral/cpp_client_wrapper_glfw/engine_method_result.o
/home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/linux/flutter/ephemeral/cpp_client_wrapper_glfw/standard_codec.o
/home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/common/src/flutter_video_renderer.o
/home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/common/src/flutter_texture_video_renderer.o
/home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/common/src/flutter_orwell_plugin.o "-rpath=\$ORIGIN/lib" -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc
/usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/crtend.o /usr/bin/../lib/gcc/x86_64-linux-gnu/7.4.0/../../../x86_64-linux-gnu/crtn.o
/home/dev/orwell/orwell_flutter/linux/../build/linux/obj//home/dev/orwell/orwell_flutter/common/src/flutter_texture_video_renderer.o: In function
`flutter_orwell_plugin::FlutterTextureVideoRenderer::renderToTexture(unsigned long, unsigned long, unsigned int)':
flutter_texture_video_renderer.cc:(.text+0x1b6): undefined reference to `glad_glTexImage2D'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [/home/dev/orwell/orwell_flutter/linux/../build/linux/debug/flutter_desktop_example] Error 1
In other words, it complains there's no reference to glad_glTexImage2D even though it it indeed in
flutter_linux_glfw.so. I also tried adding flutter_linux_glfw.so after the flutter_texture_video_renderer.o but I get the same error
nm libflutter_linux_glfw.so | grep glTexImage2D
00000000034e87a0 b glad_glTexImage2D
00000000034e87a8 b glad_glTexImage2DMultisample
These symbols are local to the library (not exported from it).
You can see the list of exported symbols with:
nm -D libflutter_linux_glfw.so
You will observe that glad_glTexImage2D is not listed there.
P.S.
I included lflutter_linux_glfw.so before flutter_video_renderer.o
This is the opposite order of what you are supposed to do: libraries should follow the objects that refer to them (though this doesn't really matter for shared libraries).

Object file associated with UHD (USRP Hardware Driver) not found

I am trying to compile a C++ file that uses the utilities of UHD (USRP Hardware Driver) in MATLAB. This is in connection with trying to use a USRP called NI-2954R with MATLAB 2013b on a 64-bit system with windows 10 OS.
The following is the mex command:
mex -largeArrayDims -v -g rx_samples_to_file.cpp -I. "C:\Users\VINAYAK KARANDIKAR\Documents\MATLAB\MATLAB\Thesis\MATLAB_USRP_INTERFACE\UHD_sample_programs_from_GitHub\uhd"...
-I."C:\Users\VINAYAK KARANDIKAR\Documents\MATLAB\MATLAB\Thesis\MATLAB_USRP_INTERFACE\UHD_sample_programs_from_GitHub\boost_1_55_0\boost"...
-L."C:\Program Files\MATLAB\R2013b\extern\lib\win64\microsoft" ...
uhd.lib ...
uhd.lib libmx.lib libmex.lib libmat.lib ...
"C:\Program Files\MATLAB\R2013b\extern\lib\win64\microsoft"
And I receive the following error:
LINK : fatal error LNK1181: cannot open input file 'C:\Users\VINAYAK KARANDIKAR\Documents\MATLAB\MATLAB\Thesis\MATLAB_USRP_INTERFACE\UHD_sample_programs_from_GitHub\uhd.obj'
C:\PROGRA~1\MATLAB\R2013B\BIN\MEX.PL: Error: Link of 'rx_samples_to_file.mexw64' failed.
Unable to complete successfully.
Error in make_rx_samples_to_file (line 4)
mex -largeArrayDims -v -g rx_samples_to_file.cpp -I. "C:\Users\VINAYAK
KARANDIKAR\Documents\MATLAB\MATLAB\Thesis\MATLAB_USRP_INTERFACE\UHD_sample_programs_from_GitHub\uhd
Why do I get this error and how can I fix the compilation?
Your MEX-command has some duplicated parts, I will assume this is because of copy-paste errors. I will assume you actually used:
mex -largeArrayDims -v -g rx_samples_to_file.cpp ...
-I. "C:\Users\VINAYAK KARANDIKAR\Documents\MATLAB\MATLAB\Thesis\MATLAB_USRP_INTERFACE\UHD_sample_programs_from_GitHub\uhd"...
-I."C:\Users\VINAYAK KARANDIKAR\Documents\MATLAB\MATLAB\Thesis\MATLAB_USRP_INTERFACE\UHD_sample_programs_from_GitHub\boost_1_55_0\boost"...
-L."C:\Program Files\MATLAB\R2013b\extern\lib\win64\microsoft" ...
uhd.lib libmx.lib libmex.lib libmat.lib
You have an argument -I., indicating you want to add the current directory (.) to the compiler's include path, then another argument "C:\Users\VINAYAK KARANDIKAR\Documents\MATLAB\MATLAB\Thesis\MATLAB_USRP_INTERFACE\UHD_sample_programs_from_GitHub\uhd", indicating you want to add that file to the compilation. Consequently, mex will look for a file uhd.obj, which does not exist.
The solution is to not separate the two parts of the -I argument with a space, and not add a . after the -I argument (you also have this in the -L argument). This leads to:
mex -largeArrayDims -v -g rx_samples_to_file.cpp ...
-I"C:\Users\VINAYAK KARANDIKAR\Documents\MATLAB\MATLAB\Thesis\MATLAB_USRP_INTERFACE\UHD_sample_programs_from_GitHub\uhd" ...
-I"C:\Users\VINAYAK KARANDIKAR\Documents\MATLAB\MATLAB\Thesis\MATLAB_USRP_INTERFACE\UHD_sample_programs_from_GitHub\boost_1_55_0\boost" ...
-L"C:\Program Files\MATLAB\R2013b\extern\lib\win64\microsoft" ...
uhd.lib libmx.lib libmex.lib libmat.lib
Though I'm sort of surprised that this works in MATLAB, if you look at the documentation to the mex command you'll see that the recommended syntax would be:
mex -largeArrayDims -v -g rx_samples_to_file.cpp ...
'-IC:\Users\VINAYAK KARANDIKAR\Documents\MATLAB\MATLAB\Thesis\MATLAB_USRP_INTERFACE\UHD_sample_programs_from_GitHub\uhd' ...
'-IC:\Users\VINAYAK KARANDIKAR\Documents\MATLAB\MATLAB\Thesis\MATLAB_USRP_INTERFACE\UHD_sample_programs_from_GitHub\boost_1_55_0\boost' ...
'-LC:\Program Files\MATLAB\R2013b\extern\lib\win64\microsoft' ...
uhd.lib libmx.lib libmex.lib libmat.lib

Error When Trying to Install DBD::Oracle with CPANM

Okay, so I was trying to install a combination of the CGI module, DBI module, and DBD::Oracle driver using CPANM on a 64bit Solaris 11 machine with an Oracle11g database.
I installed that latest version of Perl using Perlbrew, updated CPANM, and then did the following...
cpanm -v -f -i CGI
cpanm -v -f -i DBI
And both of those modules installed fine, the DBI did have a small test error (t/zvxnp_85gofer.t) when I tried to install it normally, but the force install seemed to work.
So then I went to try to install the final part that I needed:
cpanm -v -f -i DBD::Oracle
And this was the error that came out towards the end of the installation...
Running Mkbootstrap for DBD::Oracle ()
chmod 644 Oracle.bs
rm -f blib/arch/auto/DBD/Oracle/Oracle.so
LD_RUN_PATH="/opt/oracle/rdbms/lib" gcc -G -L/usr/gnu/lib -fstack-protector Oracle.o dbdimp.o oci8.o -o blib/arch/auto/DBD/Oracle/Oracle.so \
-L/opt/oracle/rdbms/lib/ -lclntsh -lkstat -lnsl -lsocket -lresolv -lgen -ldl -lsched -lrt -R/opt/oracle/rdbms/lib -laio -lposix4 -lkstat -lm -lpthread \
ld: fatal: file /opt/oracle/rdbms/lib//libclntsh.so: wrong ELF class: ELFCLASS64
ld: fatal: file processing errors. No output written to blib/arch/auto/DBD/Oracle/Oracle.so
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `blib/arch/auto/DBD/Oracle/Oracle.so'
FAIL
! Installing DBD::Oracle failed. See /home/oracle/.cpanm/build.log for details.
I'm guessing just from the wrong ELF class: ELFCLASS64 it has to do with some mismatch between the 64 bit binaries that exist and that this driver requires the 32 bit binaries to install? Some research has indicated that I need to find the lib32 directory to continue the installation, but I can't seem to find it.
I did:
echo $ORACLE_HOME ---> /opt/oracle/rdbms
ls $ORACLE_HOME
That returned the following directories...
apex emcli mgw rdbms
assistants has network relnotes
bin hs nls root.sh
ccr ide oc4j scheduler
cdata install odbc slax
cfgtoollogs install.platform olap sqldeveloper
clone instantclient ons sqlj
config inventory OPatch sqlplus
crs j2ee opmn srvm
csmig javavm oracore sysman
css jdbc oraInst.loc timingframework
ctx jdev ord ucp
cv jdk oui uix
dbs jlib owb utl
dc_ocm ldap owm wwg
deinstall lib64 perl xdk
demo log plsql
diagnostics md precomp
dv mesg racg
So I see a lib64, but no lib or lib32. Has anyone ever had this problem before, found a solution to it, or know how I could continue from here?
I had the same issue. Fixed it by doing ./Configure -es -Dprefix=$HOME/usr/local -Dcc=gcc -Duse64bitall -Dusethreads for perl install
please take a look at 1271236.1 and 883702.1 at oracle.com. It will explain how to get the 32bit libraries for 11i client installation.