CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

Linking libraries with wmake

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 10, 2006, 09:30
Default I am currently a bit puzzled b
  #1
Senior Member
 
Rasmus Hemph
Join Date: Mar 2009
Location: Sweden
Posts: 108
Rep Power: 17
hemph is on a distinguished road
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?
hemph is offline   Reply With Quote

Old   November 10, 2006, 10:22
Default You can: 1. Either use the fu
  #2
Senior Member
 
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21
eugene is on a distinguished road
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
eugene is offline   Reply With Quote

Old   November 10, 2006, 10:40
Default Thanks for your reply Eugene,
  #3
Senior Member
 
Rasmus Hemph
Join Date: Mar 2009
Location: Sweden
Posts: 108
Rep Power: 17
hemph is on a distinguished road
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) ?
hemph is offline   Reply With Quote

Old   November 10, 2006, 10:53
Default Heh, I dont know how or why it
  #4
Senior Member
 
Eugene de Villiers
Join Date: Mar 2009
Posts: 725
Rep Power: 21
eugene is on a distinguished road
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.
eugene is offline   Reply With Quote

Old   November 10, 2006, 13:16
Default Could it be ld using LD_LIBRAR
  #5
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
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".
mattijs is offline   Reply With Quote

Old   November 13, 2006, 05:12
Default You are right! I did a bit of
  #6
Senior Member
 
Rasmus Hemph
Join Date: Mar 2009
Location: Sweden
Posts: 108
Rep Power: 17
hemph is on a distinguished road
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.
hemph is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


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


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