CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   using $FOAM_USER_LIBBIN (https://www.cfd-online.com/Forums/openfoam-programming-development/83752-using-foam_user_libbin.html)

linch January 10, 2011 10:44

using $FOAM_USER_LIBBIN
 
Hi guys,

I have a rather simple question to you:

as I made some changes in an OF library and compiled it with a new name into the $FOAM_USER_LIBBIN directory, OF couldn't find it. But as I copied the .so file manually into the $FOAM_LIBBIN directory, everything ran fine.

It's not a great problem as long as I can use the lib, but I would like to keep my stuff apart from the unchanged OF. Do I have to add the $FOAM_USER_LIBBIN directory as a look-up path somewhere in OF (1.7.x)?

Regards,
Illya

olesen January 11, 2011 02:29

Quote:

Originally Posted by linch (Post 289885)
Hi guys,

I have a rather simple question to you:

as I made some changes in an OF library and compiled it with a new name into the $FOAM_USER_LIBBIN directory, OF couldn't find it. But as I copied the .so file manually into the $FOAM_LIBBIN directory, everything ran fine.

It's not a great problem as long as I can use the lib, but I would like to keep my stuff apart from the unchanged OF. Do I have to add the $FOAM_USER_LIBBIN directory as a look-up path somewhere in OF (1.7.x)?

Regards,
Illya

This sounds odd. If you check line 84 and line 98 of the settings.sh file:
https://github.com/OpenCFD/OpenFOAM-...tc/settings.sh
There appears to be no reason why it shouldn't find your FOAM_USER_LIBBIN.

If you echo the values
Code:

echo $LD_LIBRARY_PATH
# or
echo $LD_LIBRARY_PATH | tr ':' '\n'

I would hope that the directory corresponding to FOAM_USER_LIBBIN should also appear. If this is not the case, there is indeed something wrong.

l_r_mcglashan January 11, 2011 04:32

I've always had the same. My paths are (shortened);

FOAM_LIBBIN
=
OpenFOAM/OpenFOAM-1.7.x/lib/linux64GccDPOpt

FOAM_USER_LIBBIN
=
OpenFOAM/lrm29-1.7.x/lib/linux64GccDPOpt

LD_LIBRARY_PATH
=
OpenFOAM/lrm29-1.7.x/lib/linux64GccDPOpt
OpenFOAM/OpenFOAM-1.7.x/lib/linux64GccDPOpt

but I've always had to put -L$(FOAM_USER_LIBBIN) in the EXE_LIBS part of the Make/options file when using custom libraries stored there, otherwise wmake doesn't seem to find the custom libraries.

olesen January 11, 2011 04:54

Quote:

Originally Posted by l_r_mcglashan (Post 289971)
I've always had the same
...
but I've always had to put -L$(FOAM_USER_LIBBIN) in the EXE_LIBS part of the Make/options file when using custom libraries stored there, otherwise wmake doesn't seem to find the custom libraries.

Ah now I see the confusion. The LD_LIBRARY_PATH mechanism only help ldd at runtime to find the libraries. At the link stage you need to let it know where to search. The FOAM_LIBBIN is automatically added in the wmake Makefile, thus it gets found transparently. If you take a look at the fieldview9Reader Make/options you'll see a more complex example of specifying where to find things.

Summary: if you are linking against user libs, you'll need to add -L$(FOAM_USER_LIBBIN) in the Make/options regardless of what is in the LD_LIBRARY_PATH.

linch January 12, 2011 04:59

Quote:

Originally Posted by olesen (Post 289956)
If you echo the values
Code:

echo $LD_LIBRARY_PATH
# or
echo $LD_LIBRARY_PATH | tr ':' '\n'

I would hope that the directory corresponding to FOAM_USER_LIBBIN should also appear. If this is not the case, there is indeed something wrong.

FOAM_USER_LIBBIN does not appear in the list.

Quote:

Originally Posted by olesen (Post 289975)
Summary: if you are linking against user libs, you'll need to add -L$(FOAM_USER_LIBBIN) in the Make/options regardless of what is in the LD_LIBRARY_PATH.

Thank you, it works. What do -I and -L mean?

olesen January 12, 2011 05:17

Quote:

Originally Posted by linch (Post 290109)
FOAM_USER_LIBBIN does not appear in the list.

But the value equivalent to "echo $FOAM_USER_LIBBIN" should be in the LD_LIBRARY_PATH, otherwise something is seriously wrong.

Quote:

Originally Posted by linch (Post 290109)
What do -I and -L mean?

From the gcc manpage you can see that '-Idir' is for include dirs and that '-Ldir' is for library dirs.
It is probably worth skimming this section of the manpage if you are going to be working with C/C++ at all.

linch January 12, 2011 06:22

Thank you very much Mark


All times are GMT -4. The time now is 02:23.