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

Linking error in OF-1.6-ext: undefined reference to ...

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes
  • 3 Post By deepsterblue
  • 1 Post By Hisham
  • 1 Post By ngj

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 11, 2013, 16:22
Default Linking error in OF-1.6-ext: undefined reference to ...
  #1
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
Dear Foamers,

I am trying to port a custom solver to OpenFOAM-1.6-ext. The compile process runs smoothly until a linking error is issued at the end of the process. The error is:
Code:
         -lfiniteVolume     -lOpenFOAM     -ltriSurface     -lmeshTools     -lmaterialConstitutiveModel     -L/home/hisham/OpenFOAM/hisham-1.6-ext/lib/linux64GccDPOpt     -lsoilZones     -lcontactModel     -pipe -lOpenFOAM -liberty -ldl   -lm -o /home/hisham/OpenFOAM/hisham-1.6-ext/applications/bin/linux64GccDPOpt/geotechFoam3
Make/linux64GccDPOpt/geotechFoam3.o: In function `Foam::IOField<Foam::Field<Foam::Vector<double> > >::type() const':
geotechFoam3.C:(.text._ZNK4Foam7IOFieldINS_5FieldINS_6VectorIdEEEEE4typeEv[Foam::IOField<Foam::Field<Foam::Vector<double> > >::type() const]+0x3): undefined reference to `Foam::IOField<Foam::Field<Foam::Vector<double> > >::typeName'
Make/linux64GccDPOpt/geotechFoam3.o: In function `Foam::IOField<Foam::Field<double> >::type() const':
geotechFoam3.C:(.text._ZNK4Foam7IOFieldINS_5FieldIdEEE4typeEv[Foam::IOField<Foam::Field<double> >::type() const]+0x3): undefined reference to `Foam::IOField<Foam::Field<double> >::typeName'
Make/linux64GccDPOpt/geotechFoam3.o: In function `Foam::IOField<Foam::Field<Foam::SymmTensor<double> > >::type() const':
geotechFoam3.C:(.text._ZNK4Foam7IOFieldINS_5FieldINS_10SymmTensorIdEEEEE4typeEv[Foam::IOField<Foam::Field<Foam::SymmTensor<double> > >::type() const]+0x3): undefined reference to `Foam::IOField<Foam::Field<Foam::SymmTensor<double> > >::typeName'
Make/linux64GccDPOpt/geotechFoam3.o: In function `Foam::IOField<Foam::Field<double> >::IOField(Foam::IOobject const&, int)':
geotechFoam3.C:(.text._ZN4Foam7IOFieldINS_5FieldIdEEEC2ERKNS_8IOobjectEi[_ZN4Foam7IOFieldINS_5FieldIdEEEC5ERKNS_8IOobjectEi]+0x52): undefined reference to `Foam::IOField<Foam::Field<double> >::typeName'
Make/linux64GccDPOpt/geotechFoam3.o: In function `Foam::IOField<Foam::Field<Foam::Vector<double> > >::IOField(Foam::IOobject const&, int)':
geotechFoam3.C:(.text._ZN4Foam7IOFieldINS_5FieldINS_6VectorIdEEEEEC2ERKNS_8IOobjectEi[_ZN4Foam7IOFieldINS_5FieldINS_6VectorIdEEEEEC5ERKNS_8IOobjectEi]+0x52): undefined reference to `Foam::IOField<Foam::Field<Foam::Vector<double> > >::typeName'
Make/linux64GccDPOpt/geotechFoam3.o: In function `Foam::IOField<Foam::Field<Foam::SymmTensor<double> > >::IOField(Foam::IOobject const&, int)':
geotechFoam3.C:(.text._ZN4Foam7IOFieldINS_5FieldINS_10SymmTensorIdEEEEEC2ERKNS_8IOobjectEi[_ZN4Foam7IOFieldINS_5FieldINS_10SymmTensorIdEEEEEC5ERKNS_8IOobjectEi]+0x52): undefined reference to `Foam::IOField<Foam::Field<Foam::SymmTensor<double> > >::typeName'
collect2: ld returned 1 exit status
make: *** [/home/hisham/OpenFOAM/hisham-1.6-ext/applications/bin/linux64GccDPOpt/geotechFoam3] Error 1
The linking error seems to come from this part of the code:
Code:
IOField<scalarField> matHistoryScalar(
                      IOobject
                      (
                       "matHistoryScalar",
                       runTime.timeName(),
                       mesh,
                       IOobject::READ_IF_PRESENT,
                       IOobject::AUTO_WRITE
                       ),
                      sZones.size() 
                      );


IOField<vectorField> matHistoryVector(
                      IOobject
                      (
                       "matHistoryVector",
                       runTime.timeName(),
                       mesh,
                       IOobject::READ_IF_PRESENT,
                       IOobject::AUTO_WRITE
                       ),
                      sZones.size()
                      );


IOField<symmTensorField> matHistorySymmTensor(
                          IOobject
                          (
                           "matHistorySymmTensor",
                           runTime.timeName(),
                           mesh,
                           IOobject::READ_IF_PRESENT,
                           IOobject::AUTO_WRITE
                           ),
                          sZones.size()
                          );
As far as I know I have all libraries involved included in the Make/options

Code:
EXE_LIBS = -lfiniteVolume \
    -lOpenFOAM \
    -ltriSurface \
    -lmeshTools \
    -L$(FOAM_USER_LIBBIN)
Any help is appreciated!

Best regards
Hisham
Hisham is offline   Reply With Quote

Old   February 11, 2013, 16:56
Default
  #2
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi Hisham,

I do not think you are allowed to create an IOField< Field<Type> > in OpenFoam - at least I could not get it compiled either. Is this what you want, or do you merely need an IOField<Type>?

All the best,

Niels
ngj is offline   Reply With Quote

Old   February 11, 2013, 17:08
Default
  #3
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Hi again,

I could not help trying to get something like you sketched to compile, so along your line of thought, this might be, what you need:

Code:
        PtrList<IOField<vector> > listField(sZones.size());

        forAll( listField, fieldi)
        {
            listField.set
            (
                fieldi,
                new IOField<vector>
                (
                    IOobject
                    (
                        "fjdskl",
                        runTime.timeName(),
                        mesh,
                        IOobject::READ_IF_PRESENT,
                        IOobject::AUTO_WRITE
                    )
                )
            );
        }
You must, however, be a bit careful with the naming "fjdskl", since all of the fields will be written to the same file name. It compiles, however, I do not know if it will work!?!

Good luck,

Niels
ngj is offline   Reply With Quote

Old   February 11, 2013, 17:50
Default
  #4
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
Quote:
Originally Posted by ngj View Post
Hi again,

I could not help trying to get something like you sketched to compile, so along your line of thought, this might be, what you need:

Code:
        PtrList<IOField<vector> > listField(sZones.size());

        forAll( listField, fieldi)
        {
            listField.set
            (
                fieldi,
                new IOField<vector>
                (
                    IOobject
                    (
                        "fjdskl",
                        runTime.timeName(),
                        mesh,
                        IOobject::READ_IF_PRESENT,
                        IOobject::AUTO_WRITE
                    )
                )
            );
        }
You must, however, be a bit careful with the naming "fjdskl", since all of the fields will be written to the same file name. It compiles, however, I do not know if it will work!?!

Good luck,

Niels
EDITED
Hi Niels

Thanks a lot for the super fast response.

Actually, this code compiles and works perfectly on OpenFOAM-2.1.x. I do not know what could be the problem as the implementation of IOFields seems to be the same for both editions and I can't figure out more info from the linker message.

The idea is to have a scalar(vector/symmTensor)Field for each zone that differs in size and they all write to one file (e.g. matHistoryScalar) in the time step.

This how a file looks from a run on OF-2.1.x.

Code:
/*--------------------------------*- C++ -*----------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  2.1.x                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      binary;
    class       scalarFieldField;
    location    "0.3";
    object      matHistoryScalar;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //


2 // zones
(

0 // first zone zero


19200 // second zone
(
bla bla in binary

)

)

// ******************************  //
I am afraid I understand from your proposal that each vectorField will overwrite the same file or a new file is needed for each zone!

Is there a more similar approach to what I need?

Hisham
Hisham is offline   Reply With Quote

Old   February 11, 2013, 18:24
Default
  #5
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
I think I found where the problem might be. There are files in OF that are not in OF-ext:

scalarFieldIOField.H & .C
vectorFieldIOField.H & .C
symmTensorFieldIOField.H & .C

I'll try to copy them to the solver directory.

EDIT:
No they're not. They are just typedefs:
Quote:
typedef IOField<scalarField> scalarFieldIOField;
And as it is compiling, it is only a link problem ...
Hisham is offline   Reply With Quote

Old   February 12, 2013, 00:20
Default
  #6
Senior Member
 
Sandeep Menon
Join Date: Mar 2009
Location: Amherst, MA
Posts: 403
Rep Power: 25
deepsterblue will become famous soon enough
You might be missing a defineTypeNameAndDebug macro in your .C file somewhere. Those are static class variables wrapped in macros.

Since you're dealing with a compound type, something like this might be necessary:

// Explicitly specify typeNames for IOFields
defineCompoundTypeName(Field<scalar>, scalarField);
addCompoundToRunTimeSelectionTable(Field<scalar>, scalarField);

defineCompoundTypeName(Field<vector>, vectorField);
addCompoundToRunTimeSelectionTable(Field<vector>, vectorField);

defineTemplateTypeNameAndDebugWithName
(
IOList<scalarField>, "scalarFieldList", 0
);

defineTemplateTypeNameAndDebugWithName
(
IOList<vectorField>, "vectorFieldList", 0
);
ngj, Hisham and usv001 like this.
__________________
Sandeep Menon
University of Massachusetts Amherst
https://github.com/smenon
deepsterblue is offline   Reply With Quote

Old   February 12, 2013, 04:53
Default
  #7
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
Quote:
Originally Posted by deepsterblue View Post
You might be missing a defineTypeNameAndDebug macro in your .C file somewhere. Those are static class variables wrapped in macros.

Since you're dealing with a compound type, something like this might be necessary:

// Explicitly specify typeNames for IOFields
defineCompoundTypeName(Field<scalar>, scalarField);
addCompoundToRunTimeSelectionTable(Field<scalar>, scalarField);

defineCompoundTypeName(Field<vector>, vectorField);
addCompoundToRunTimeSelectionTable(Field<vector>, vectorField);

defineTemplateTypeNameAndDebugWithName
(
IOList<scalarField>, "scalarFieldList", 0
);

defineTemplateTypeNameAndDebugWithName
(
IOList<vectorField>, "vectorFieldList", 0
);
Hi Sandeep and Niels,

Thanks a lot Sandeep. This surely makes it work

Code:
namespace Foam
{
    typedef IOField<vectorField> vectorFieldIOField;
    typedef IOField<scalarField> scalarFieldIOField;
    typedef IOField<symmTensorField> symmTensorFieldIOField;

    defineTemplateTypeNameAndDebugWithName
    (
        vectorFieldIOField,
        "vectorFieldField",
        0
    );

    defineTemplateTypeNameAndDebugWithName
    (
        scalarFieldIOField,
        "scalarFieldField",
        0
    );

    defineTemplateTypeNameAndDebugWithName
    (
        symmTensorFieldIOField,
        "symmTensorFieldField",
        0
    );

}
The code is copied from scalar(vector, symmTensor)FieldIOField.C and .H

Thanks again to both of you!

Best regards,
Hisham
ngj likes this.
Hisham is offline   Reply With Quote

Old   November 5, 2013, 15:35
Default
  #8
ngj
Senior Member
 
Niels Gjoel Jacobsen
Join Date: Mar 2009
Location: Copenhagen, Denmark
Posts: 1,903
Rep Power: 37
ngj will become famous soon enoughngj will become famous soon enough
Dear Hisham and Sandeep,

I just found myself needed this solution, so thank you a lot for these posts. It was exceptionally helpful.

Kind regards,

Niels
Hisham likes this.
__________________
Please note that I do not use the Friend-feature, so do not be offended, if I do not accept a request.
ngj is offline   Reply With Quote

Reply

Tags
iofield, linking, openfoam-1.6-ext


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
Second Derivative Zero - Boundary Condition fu-ki-pa OpenFOAM 11 March 27, 2021 05:28
OpenFOAM 1.6-ext git installation on Ubuntu 11.10 x64 Attesz OpenFOAM Installation 45 January 13, 2012 13:38
Error with Wmake skabilan OpenFOAM Installation 3 July 28, 2009 01:35
OpenFOAM on MinGW crosscompiler hosted on Linux allenzhao OpenFOAM Installation 127 January 30, 2009 20:08
G95 + CGNS Bruno Main CFD Forum 1 January 30, 2007 01:34


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