|
[Sponsors] |
Using functions in coded function object | undefined symbol |
![]() |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
![]() |
![]() |
#1 |
New Member
Marius
Join Date: Aug 2020
Location: Germany
Posts: 11
Rep Power: 6 ![]() |
Hi,
I have written a coded function object with a working code block. Now I'm trying to package this code into individual functions so I can use them in multiple function objects and maintain a clean structure in my controlDict file. For this I created a directory pp_functions in the system directory where I put all my header and cpp files. I'm having problems with including and using these functions in my coded function objects. For testing I created a header file test_methods.h Code:
#ifndef TEST_METHODS_H// To make sure you don't declare the function more than once by including the header multiple times. #define TEST_METHODS_H void test_method(); #endif Code:
#include "pp_functions/test_methods.h" void test_method() { Info << "TEST METHOD" << endl; } My coded function object looks like this: Code:
codedTest { libs ("libutilityFunctionObjects.so"); type coded; // Name of on-the-fly generated functionObject name codedTest; codeOptions #{ -I$(FOAM_CASE)/system/pp_functions #}; codeInclude #{ #include "test_methods.h" #}; codeWrite #{ test_method(); #}; } Code:
Using dynamicCode for functionObject codedTest at line 15 in "/home/openfoam/system/controlDict/functions/codedTest" Creating new library in "dynamicCode/codedTest/platforms/linux64GccDPInt32Opt/lib/libcodedTest_2146ab0e392c492df3767af3c8ac8b8b90ae358e.so" Invoking "wmake -s libso /home/openfoam/dynamicCode/codedTest" wmake libso /home/openfoam/dynamicCode/codedTest ln: ./lnInclude wmkdep: functionObjectTemplate.C Ctoo: functionObjectTemplate.C ld: /home/openfoam/dynamicCode/codedTest/../platforms/linux64GccDPInt32Opt/lib/libcodedTest_2146ab0e392c492df3767af3c8ac8b8b90ae358e.so simpleFoam: symbol lookup error: /home/openfoam/dynamicCode/platforms/linux64GccDPInt32Opt/lib/libcodedTest_2146ab0e392c492df3767af3c8ac8b8b90ae358e.so: undefined symbol: _Z11test_methodv Did I miss a step or some definition before runnning simpleFoam? Does anyone know how to solve the "undefined symbol" error? Any help would be appreciated. |
|
![]() |
![]() |
![]() |
![]() |
#2 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16 ![]() |
did you compile your cpp file. The symbol look up error is when you have defined your function (or class) but the linker did not find the actual execution block.
So you should probably compile your cpp file, make a library out of it and include it into libs. This should work Best Michael |
|
![]() |
![]() |
![]() |
![]() |
#3 | |
New Member
Marius
Join Date: Aug 2020
Location: Germany
Posts: 11
Rep Power: 6 ![]() |
Hi Michael,
thank you for your reply. Quote:
I guess at this point I could just as well start to define my own function objects, that will probably be cleaner than using the coded function object with my own library of functions. |
||
![]() |
![]() |
![]() |
![]() |
#4 |
Senior Member
Michael Alletto
Join Date: Jun 2018
Location: Bremen
Posts: 616
Rep Power: 16 ![]() |
you can include your code directly in the codeWrite or codeExecute blocks. So wmake will take care of the compilation
|
|
![]() |
![]() |
![]() |
Tags |
coded function object |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Caffa 3D code | Waliur Rahman | Main CFD Forum | 0 | May 29, 2018 00:53 |
Error in compiling new drag model | k.farnagh | OpenFOAM Programming & Development | 13 | May 21, 2016 03:08 |
[foam-extend.org] Error compiling OpenFOAM-1.6-ext | Canesin | OpenFOAM Installation | 137 | January 20, 2016 14:56 |
[blockMesh] error message with modeling a cube with a hold at the center | hsingtzu | OpenFOAM Meshing & Mesh Conversion | 2 | March 14, 2012 09:56 |
OpenFOAM 1.6-ext git installation on Ubuntu 11.10 x64 | Attesz | OpenFOAM Installation | 45 | January 13, 2012 12:38 |