|
[Sponsors] |
November 10, 2006, 09:30 |
I am currently a bit puzzled b
|
#1 |
Senior Member
Rasmus Hemph
Join Date: Mar 2009
Location: Sweden
Posts: 108
Rep Power: 17 |
I am currently a bit puzzled by the compilation with wmake. In Make/options I have
EXE_LIBS = \ -L$(FOAM_LIBBIN) -lEulerianInterfacialModels \ -L$(FOAM_LIBBIN) -lphaseModel Compilation runs fine, but at the linking stage, wmake picks up equally named libraries, not from $(FOAM_LIBBIN), but from $(FOAM_USER_LIBBIN). How can I get wmake to use the correct libraries? |
|
November 10, 2006, 10:22 |
You can:
1. Either use the fu
|
#2 |
Senior Member
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21 |
You can:
1. Either use the full pathname for the libraries instead of the -l prefix 2. Delete the libraries in $FOAM_USER_LIBBIN 3. Rename the libraries in $FOAM_USER_LIBBIN |
|
November 10, 2006, 10:40 |
Thanks for your reply Eugene,
|
#3 |
Senior Member
Rasmus Hemph
Join Date: Mar 2009
Location: Sweden
Posts: 108
Rep Power: 17 |
Thanks for your reply Eugene, I resorted to number 3. However, I thought that the -L flag was there to tell gcc that is should use the supplied directory for the library in question. I am curious: why is it picking up libs from $(FOAM_USER_LIBBIN) ?
|
|
November 10, 2006, 10:53 |
Heh, I dont know how or why it
|
#4 |
Senior Member
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21 |
Heh, I dont know how or why it works.
All I know is that there is a hierarchy defined somewhere and FOAM_USER_LIBBIN is higher up the pecking order than FOAM_LIBBIN. |
|
November 10, 2006, 13:16 |
Could it be ld using LD_LIBRAR
|
#5 |
Senior Member
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26 |
Could it be ld using LD_LIBRARY_PATH?
From 'man ld': The linker uses the following search paths to locate required shared libraries. .. 5. For a native linker, the contents of the environment variable "LD_LIBRARY_PATH". |
|
November 13, 2006, 05:12 |
You are right! I did a bit of
|
#6 |
Senior Member
Rasmus Hemph
Join Date: Mar 2009
Location: Sweden
Posts: 108
Rep Power: 17 |
You are right! I did a bit of Googling and found out what is going on. At compilation gcc uses the directories I supply with the -L flag. At the linking stage however, the linker looks to $LD_LIBRARY_PATH to see where the library I gave with the -l flag is located. Since $(FOAM_USER_LIBBIN) is ahead of $(FOAM_LIBBIN) in this path, my final application is linked to the "wrong" libraries in this case.
Solution? One can supply commands to the linker by the -Wl-flag. By adding -Wl, -rpath $(FOAM_LIBBIN) to the end of Make/options, the linker places this directory first in the search path, and the "right" libraries are linked to my application. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[Other] Using native MPI libraries | arkangel | OpenFOAM Installation | 21 | December 16, 2016 00:23 |
Problems linking my libraries with libfoamUser | jblucca | OpenFOAM Running, Solving & CFD | 5 | October 22, 2008 17:53 |
CGNS libraries, compiling and linking... | Ironman80 | Main CFD Forum | 2 | February 14, 2006 23:36 |
AMG libraries | CMB | Siemens | 2 | January 23, 2004 02:54 |
help on POOMA/PVM etc. libraries | mayank | Main CFD Forum | 0 | November 15, 2002 00:04 |