Add new variable to openfoam adapter

Hello,

I am going to add new variable to openFOAM adapter. When I did the compilation, I face a error “undefined symbol”, as show in ldd.log. This is because I created a new variable in my developed solver in createFields.H file, which means that I don’t have a library with this variable to link it. In order to have the library to do linking, I created a xx.H and xx.C file for the declaration of variable without defining the member function,as shown in figure below. But I still facing the error “undefined symbol”.

Anyone can help me for this problem? Thanks in advance.

ldd.log (6.3 KB)
Screenshot from 2022-06-22 12-28-26
Screenshot from 2022-06-22 12-28-42

These are your undefined symbol log lines:

undefined symbol: _ZNK14preciceAdapter15Volume_Coupling24meanAcousticForceDensity23isLocationTypeSupportedEb	(/home/u0148289/OpenFOAM/u0148289-6/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZNK14preciceAdapter15Volume_Coupling24meanAcousticForceDensity11getDataNameB5cxx11Ev	(/home/u0148289/OpenFOAM/u0148289-6/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)
undefined symbol: _ZNK14preciceAdapter15Volume_Coupling5alpha23isLocationTypeSupportedEb	(/home/u0148289/OpenFOAM/u0148289-6/platforms/linux64GccDPInt32Opt/lib/libpreciceAdapterFunctionObject.so)

I understand that you are already using one of the contributed volume coupling extensions.

Have you already added your new file (object file) to the Make/files file of the adapter?

Thanks Makis for your kind reply. I added my .C file in Make Files.I also added the new variable library to Make/options. I enclosed my Make/files and Options there. Could you help me to have a look? Do you know how to solve this problem?

files.txt (545 Bytes)
options.txt (1.1 KB)

Since you added the -lacousticSymbolClass (assuming this is what you need), this should be fine. Try ./Allclean before you run ./Allwmake again. Do you still get the same error?

Dear Makis,

Yes, I still got the same problem. The following figure is what I got using ./Allwmake. (I used ./Allclean as you suggested and then I used ./Allwmake). I think maybe it is because I created a new library(as shown in the figure for my first post) but I didn’t add any member functions?

@Yin_Jun Something that I am wondering is why the symbols that are reported by ldd (e.g., _ZNK14preciceAdapter15Volume_Coupling24meanAcousticForceDensity23isLocationTypeSupportedEb) are not shown in the code in your first post. Have you actually implemented everything, or are they only declarations?

This seems to me like a general C++ issue, and I assume that you would have a similar issue when trying to link the library to just an OpenFOAM solver. Maybe starting from that already would be helpful while debugging.