Pergunta

I have the following:

g++ $(LD_OPTS) -o lib/foo.so lib/bar.o lib/qaz.o ../path/to/foodependency.so

It and foo are both being built here (assume foodependency has already been built by the makefile previously). The end result looks something like this, during build:

project
---libFoo
------lib
---------foo.so
---libFooDependency
------lib
---------foodependency.so

However, during runtime, both foo.so and foodependency.so are in the same directory, bar:

bar
---foo.so
---foodependency.so

This layout during runtime cannot be changed. But now as a result, ldd foo.so returns the following: ../path/to/foodependency.so => not found

How can I resolve this difference?

Foi útil?

Solução

How can I resolve this

There are several ways.

  1. Rename foodependency.so to libfoodependency.so, and use -L../path/to -lfoodependency when linking, or
  2. Use -L../path/to -l:foodependency.so when linking, or
  3. When linking foodependency.so, add -Wl,--soname=foodependency.so and use your original link line.
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top