/usr/bin/ld: cannot find -lemu
You need to tell the linker where it is:
gcc stuff -L/opt/libemu -lemu
or:
gcc stuff /opt/libemu/libemu.a
where stuff
is your normal compile/link options files etc.
You can also specify library paths in the LIBRARY_PATH environment variable:
LIBRARY_PATH=/opt/libemu
export LIBRARY_PATH
before you run your build. Yet another option is to see where gcc looks for libraries by running:
gcc --print-search-dirs
and put your library in one of the listed directories.
Edit: It is really not clear from your latest info what you are trying to build. Are you trying to turn a static library into a shared library? Most important - What is the exact filename of the library file you have copied into the /opt/libemu directory?
Get rid of gcc - /usr/bin/ld: warning lib not found
You need to add the dynamic library equivalent of -L
:
-Wl,-rpath-link,/path/to/lib
This will cause the linker to look for shared libraries in non-standard places, but only for the purpose of verifying the link is correct.
If you want the program to find the library at that location at run-time, then there's a similar option to do that:
-Wl,-rpath,/path/to/lib
But, if your program runs fine without this then you don't need it.
Compile gawk executable for another server
Thank you so much for the help provided in the comments to my original post. Below is a summary of how it worked in the end. I saw that make
resulted in the following as the final compilation command for creating the gawk executable:
gcc -std=gnu99 -g -O2 -DNDEBUG -L/usr/lib64//lib -o gawk array.o awkgram.o builtin.o cint_array.o command.o debug.o eval.o ext.o field.o floatcomp.o gawkapi.o gawkmisc.o int_array.o io.o main.o mpfr.o msg.o node.o profile.o re.o replace.o str_array.o symbol.o version.o support/libsupport.a -lmpfr -lgmp -ldl -lm
So I modified that gcc command as below:
Download and compile the mpfr libraries (just ./configure
and make
).
Download and compile the gmp libraries (just ./configure
and make
).
Download and compile gawk-4.2.1.
./configure
make
gcc -std=gnu99 -g -O2 -DNDEBUG -L/usr/lib64//lib -o gawk array.o awkgram.o builtin.o cint_array.o command.o debug.o eval.o ext.o field.o floatcomp.o gawkapi.o gawkmisc.o int_array.o io.o main.o mpfr.o msg.o node.o profile.o re.o replace.o str_array.o symbol.o version.o support/libsupport.a -Bstatic -L /home/osboxes/Downloads/mpfr-4.0.1/src/.libs/ -l:libmpfr.a -L /home/osboxes/Downloads/gmp-6.1.2/.libs/ -l:libgmp.a -Bdynamic -ldl -lm
That resulted in a gawk executable that had mpfr and gmp libraries statically linked, so when I transferred it to the server which did not have libmpfr.so already installed, it was able to execute with the static library.
Before adding the static libraries:
[osboxes@osboxes Gawk]$ ldd gawk
linux-vdso.so.1 => (0x00007ffe17750000)
libmpfr.so.4 => /lib64/libmpfr.so.4 (0x00007fca2042d000)
libgmp.so.10 => /lib64/libgmp.so.10 (0x00007fca201b5000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fca1ffb1000)
libm.so.6 => /lib64/libm.so.6 (0x00007fca1fcaf000)
libc.so.6 => /lib64/libc.so.6 (0x00007fca1f8e2000)
/lib64/ld-linux-x86-64.so.2 (0x00007fca20688000)
After adding the static libraries:
[osboxes@osboxes gawk-4.2.1]$ ldd gawk
linux-vdso.so.1 => (0x00007fff1b8d5000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f69363b0000)
libm.so.6 => /lib64/libm.so.6 (0x00007f69360ae000)
libc.so.6 => /lib64/libc.so.6 (0x00007f6935ce1000)
/lib64/ld-linux-x86-64.so.2 (0x00007f69365b4000)
Related Topics
How to Two Mmap on Same /Dev File
How to Continously Run a Unix Script in Background Without Using Crontab.
Code for Wait_Event_Interruptible
Cmake: How to Suppress "Entering Directory" Messages
Difference Between The Commands "Gcloud Compute Ssh" and "Ssh"
How to Set Just Year with Linux Date Command
How to Access Files in Hadoop Hdfs
Remove The Lines Starting with a Character in Shell
How to Install Cross Compiled Cups to Target Board
How to Enter Private Key Password with Ansible
Grep in File and Replace String
Openssl Shows a Different Server Certificate While Browser Shows Correctly
Arduino Upload Error "Stk500_Recv(): Programmer Is Not Responding" in Fedora