Linking problems dynamic library
Dear all,
Using Ubuntu 11.04 I recently upgraded to OF 2.0.1. I have created a custom library without problems. However, the following error message keeps appearing when I try to use this new library (libfvMotionSolversNew.so): --> FOAM Warning : From function dlLibraryTable::open(const fileName&, const bool) in file db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C at line 96 could not load "libfvMotionSolversNew.so" For some reason OF cannot find the library, although I did add the line libs ("libfvMotionSolversNew.so"); to the file controlDict. The new library is placed in the folder $FOAM_USER_LIBBIN, copying it to $FOAM_LIBBIN does not solve the problem. Does anyone have a suggestion to solve this? Regards, Kevin |
This is normally how it should work afaik.
Probably the solution is simple, no typo somewhere? Compilation problems? Did you compile with "wmake libso"? Do you have such a problem with other libraries (I guess not)? |
Compiling using "wmake libso" works without problems.
Using the standard libraries provided with OF is also no problem. The only thing is that OF cannot find the newly created library. Maybe my 'options' file contains an error in the linking? Please see below: EXE_INC = \ -I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/postProcessing/functionObjects/forces/lnInclude \ -I$(LIB_SRC)/fvMotionSolver/lnInclude \ LIB_LIBS = \ -L$(FOAM_USER_LIBBIN) \ -ltriSurface \ -lmeshTools \ -ldynamicMesh \ -lfiniteVolume \ /*-lforces include in controlDict if needed */ |
Hi
I think you must remove the "back slash"(\) from the last lines: EXE_INC = \ -I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/postProcessing/functionObjects/forces/lnInclude \ -I$(LIB_SRC)/fvMotionSolver/lnInclude LIB_LIBS = \ -L$(FOAM_USER_LIBBIN) \ -ltriSurface \ -lmeshTools \ -ldynamicMesh \ -lfiniteVolume |
If you add the options you specified in:
As a matter of fact, your library should then be usable even without adding the line: Code:
libs("libfvMotionSolversNew.so"); Hope this helps. Kind regards, Francois. |
Of course, don't forget to recompile the original library once you changed the "options" file... ;)
|
I've encountered linking problems trying to compile it in Ubuntu 11.10. See this thread: http://www.cfd-online.com/Forums/ope...tml#post328779
It could be related, and it could be a compiler issue. |
Dear all,
Thanks for the replies. I just found another message running OF 2.0.1, it says to disallow user-supplied system cal operations, see below: (...) nProcs : 1 sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE). fileModificationChecking : Monitoring run-time modified files using timeStampMaster allowSystemOperations : Disallowing user-supplied system call operations // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Create time (...) I guess OF doesn't allow me to access my new library? Secondly, it seems that the new library does work when using OF 1.7.1. That is, there are no problems accessing the library and I can start debugging. Although I'm a bit short on time (who isn't?) I'll get back on this. Regards, Kevin |
No, it shouldn't matter.
The Quote:
Kind regards, Francois. |
I ran into a problem loading a library in 2.0.x yesterday, and a colleague suggested this solution, which helped a lot. I added the following lines to OpenFOAM-2.0.x/src/OSspecific/POSIX/POSIX.C. In that file, around line 1138, you'll find this line:
Code:
void* handle = ::dlopen(lib.c_str(), RTLD_LAZY|RTLD_GLOBAL); Code:
// find error (if any) With that, you should get more information on why the .so file wouldn't load. (In my case, I found that I forgot that I also needed to first load a second .so file.) I've submitted this as a "feature request" to OpenCFD, so maybe future versions will give better feedback. Hope it helps! David |
Dear All
I have also created my custom library without problems. However, I am also getting the following error message when I try to use this new library (libfvMotionSolversNew.so): --> FOAM Warning : From function dlLibraryTable::open(const fileName&, const bool) in file db/dynamicLibrary/dlLibraryTable/dlLibraryTable.C at line 96 Could you help me please? Best Mahdi |
Hi
Did you add the library name to the controldict? |
Greetings to all!
Mahdi, I got the private message you sent me. You should have also indicated the thread where you asked your question as well. Either way, this isn't sufficient information: Quote:
Bruno |
Dear Bruno and Ata
Thanks for your kind reply. I am working with OpenFOAM-2.0.x on Ubuntu 10.04 LTS. to create my boundary condition I did that : 1- I have copied the turbulentTemperatureCoupledBaffleMixed boundary condition and renamed it to myturbulentTemperatureCoupledBaffleMixed 2-secondly I have done my changes 3- I complied it as a dynamic library with wmake libso. then I have tested two things. 1-first I just added a libs ("mylibfinvoll.so"); to the controldict and start running and then I got the following message. Code:
2- secondly instead of adding the libentry in controldict i add the library to Option file my solver which looks like: Code:
Code:
Do you think that it it could be related to DL_LIBrary_PATH? I have readed in some of the threads in forum. Best Mahdi |
In a nutshell:
|
Dear Burno
Thanks for your kind reply I have corrected the name. but it didn't solved. if i don't add in the solver I will receive the same message. but if add it it will gives the follwing error: Code:
g++ -m64 -Dlinux64 -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-100 -Iinclude -Ifluid -Isolid -I/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/meshTools/lnInclude -I/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/turbulenceModels/incompressible/turbulenceModel -I/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/transportModels -I/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/transportModels/incompressible/singlePhaseTransportModel -I/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/finiteVolume/lnInclude -I/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/turbulenceModels -I/home/mahdi/OpenFOAM/mahdi-2.0.x/src/MultiRegionBound/lnInclude -I/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/thermophysicalModels/basicSolidThermo/lnInclude -I/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/thermophysicalModels/specie/lnInclude -I/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/turbulenceModels/compressible/turbulenceModel/lnInclude -IlnInclude -I. -I/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OpenFOAM/lnInclude -I/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/src/OSspecific/POSIX/lnInclude -fPIC -Xlinker --add-needed Make/linux64Gcc45DPOpt/incompressibleCourantNo.o Make/linux64Gcc45DPOpt/solidRegionDiffNo.o Make/linux64Gcc45DPOpt/ppplasmaFoam.o -L/home/mahdi/centFOAM//OpenFOAM/OpenFOAM-2.0.x/platforms/linux64Gcc45DPOpt/lib \ |
Hi Mahdi,
I'm too tired right now to guess was going on wrong... well, I can guess that you removed the last "-L*" line and replaced it with the "-lmyfinvoll", when you should have added the last one. Either way, here are a few tutorials on how to modify OpenFOAM code for personal modifications, for you to study and draw ideas from:
Bruno |
Dear Buruno
Thanks for your kind reply.... the first problem as you mwntioned was with the name of library. and the second was that I didnt add the correct libralry when compiling my own library ...( but it was compiling correctly and without any waring or error!!!)... When I add that library and changed the name, it works :)... Thanks for your help. |
All times are GMT -4. The time now is 19:56. |