0

Why cannot ld find the library libjarray.so below?

gcc -shared -Wl,-soname,libjstring.so.0.1 -I/home/jocke/development/jstring/../jarray/output -I/home/jocke/development/jstring -L/home/jocke/development/jstring/../jarray/output -ljarray jstring.o -o libjstring.so.0.1

/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../../../x86_64-pc-cygwin/bin/ld: cannot find -ljarray collect2: error: ld returned 1 exit status

$ ls -l /home/jocke/development/jstring/../jarray/output total 79<br> lrwxrwxrwx 1 jocke Domain Users 41 Oct 29 11:58 jarray.c -> /home/jocke/development/jarray/jarray.c -rw-r--r-- 1 jocke Domain Users 9840 Oct 29 11:25 jarray.o lrwxrwxrwx 1 jocke Domain Users 52 Oct 29 11:58 jarray_test.c -> /home/jocke/development/jarray/utest/jarray_test.c lrwxrwxrwx 1 jocke Domain Users 16 Oct 29 11:58 libjarray.so -> libjarray.so.0.1 -rwxr-xr-x 1 jocke Domain Users 62905 Oct 29 11:58 libjarray.so.0.1

Joachim
  • 81
  • 1
  • 3
  • 9
  • "-ljarray" option makes ld to use archive file "libjarray.ar" for linking. "Why cannot ld find the library libjarray.so below?" Because ld will not find "libjarray.so" but "libjarray.ar". – Fumu 7 Oct 29 '14 at 04:33
  • So you mean this is wrong: http://www.cprogramming.com/tutorial/shared-libraries-linux-gcc.html? " Telling GCC where to find the shared library Uh-oh! The linker doesn’t know where to find libfoo. GCC has a list of places it looks by default, but our directory is not in that list.2 We need to tell GCC where to find libfoo.so. We will do that with the -L option. In this example, we will use the current directory, /home/username/foo: $ gcc -L/home/username/foo -Wall -o test main.c -lfoo " – Joachim Oct 29 '14 at 04:47
  • And, if you think that is wrong - how should you write it? – Joachim Oct 29 '14 at 10:12
  • This post also suggest you are wrong, Fumu http://stackoverflow.com/questions/16710047/usr-bin-ld-cannot-find-lnameofthelibrary – Joachim Nov 01 '14 at 03:10

1 Answers1

0

Here I found the solution to my problem:

building and linking a shared library

I needed a specific syntax to make it work, similar to:

-l:libbeat.so.1.0.1

Community
  • 1
  • 1
Joachim
  • 81
  • 1
  • 3
  • 9