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

collect2: error: ld returned 1 exit status

Register Blogs Community New Posts Updated Threads Search

Like Tree10Likes
  • 3 Post By alexeym
  • 2 Post By alexeym
  • 2 Post By alexeym
  • 1 Post By alexeym
  • 2 Post By alexeym

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 10, 2017, 13:20
Default collect2: error: ld returned 1 exit status
  #1
New Member
 
Join Date: Sep 2012
Posts: 23
Rep Power: 13
Zack is on a distinguished road
Hi All

I am compiling a solver (which is initially made for OF-2.2.2) in a recent version of OF-V1606+. Compiling states below error:

Code:
Make/linux64GccDPInt32Opt/efficiencyFunction.o: In function `Foam::efficiencyFunction::efficiencyFunction(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, double c
onst&)':
efficiencyFunction.C:(.text+0x24e5): undefined reference to `Foam::LESdelta::New(Foam::word const&, Foam::fvMesh const&, Foam::dictionary const&)'

collect2: error: ld returned 1 exit status
make: *** [/home/ofuser/OpenFOAM/ofuser-v1606+/platforms/linux64GccDPInt32Opt/bin/TFM-Foam] Error 1
Can someone Pls help me to understand this error?
Zack is offline   Reply With Quote

Old   February 10, 2017, 13:52
Default
  #2
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Hi,

Your code used LESDelta::New with the following set of arguments:

Code:
Foam::word const&, Foam::fvMesh const&, Foam::dictionary const&
yet in 4.x signature is changed to:

Code:
        //- Return a reference to the selected LES delta
        static autoPtr<LESdelta> New
        (
            const word& name,
            const turbulenceModel& turbulence,
            const dictionary& dict
        );

        //- Return a reference to the selected LES delta
        static autoPtr<LESdelta> New
        (
            const word& name,
            const turbulenceModel& turbulence,
            const dictionary& dict,
            const dictionaryConstructorTable&
        );
So it was OK during compilation, but not during linking stage, and you have to adapt your code to new API.
Zack, Uyan and Foam fan like this.
alexeym is offline   Reply With Quote

Old   February 11, 2017, 16:08
Default
  #3
New Member
 
Join Date: Sep 2012
Posts: 23
Rep Power: 13
Zack is on a distinguished road
Thank you alexeym for your reply.

These are my efficiencyFunction.C :

Code:
#include "efficiencyFunction.H"

namespace Foam
{

    defineTypeNameAndDebug(efficiencyFunction, 0);
    defineRunTimeSelectionTable(efficiencyFunction, dictionary);

    autoPtr<efficiencyFunction> efficiencyFunction::New
    (
        const volVectorField& U,
        const scalar& TF
    )
    {
        word typeName;

        // Enclose the creation of the dictionary to ensure it is
        // deleted before the model is created otherwise the dictionary
        // is entered in the database twice
        {
            IOdictionary propertiesDict
                (
                    IOobject
                    (
                        "efficiencyFunctionProperties",
                        U.time().constant(),
                        U.db(),
                        IOobject::MUST_READ,
                        IOobject::NO_WRITE
                    )
                );
            
            propertiesDict.lookup("efficiencyFunction") 
                >> typeName;
        }

        dictionaryConstructorTable::iterator cstrIter =
            dictionaryConstructorTablePtr_->find(typeName);
        
        if (cstrIter == dictionaryConstructorTablePtr_->end())
        {
            FatalErrorIn
                (
                    "efficiencyFunction::New()"
                )   << "Unknown efficiency function " << typeName
                    << endl << endl
                    << "Valid efficiency functions are :" << endl
                    << dictionaryConstructorTablePtr_->toc()
                    << exit(FatalError);
        }

        return autoPtr<efficiencyFunction>(cstrIter()(U, TF));
        
    }



    efficiencyFunction::efficiencyFunction
    (
        const volVectorField& U,
        const scalar& TF
    )
        : IOdictionary
    (
        IOobject
        (
            "efficiencyFunctionProperties",
            U.time().constant(),
            U.db(),
            IOobject::MUST_READ,
            IOobject::NO_WRITE
        )
    ),
          U_(U),
          TF_(TF),
          efficiency_
        (
            IOobject
            (
                "efficiency",
                U.time().timeName(),
                U.mesh(),
                IOobject::NO_READ,
                IOobject::AUTO_WRITE
            ),
            U.mesh(),
            dimensionedScalar("", dimless, 1.0)
        ),
          delta_(LESdelta::New("delta", U.mesh(), *this))
    {
    }

    efficiencyFunction::~efficiencyFunction()
    {
    }


}
and my efficiencyFunction.H files :

Code:
#ifndef EFFICIENCYFUNCTION_H
#define EFFICIENCYFUNCTION_H

#include "fvCFD.H"
#include "LESdelta.H"
#include "runTimeSelectionTables.H"

namespace Foam
{

class efficiencyFunction
: public IOdictionary
{

protected:
    const volVectorField& U_;
    const scalar& TF_;

    volScalarField efficiency_;

    autoPtr<LESdelta> delta_;

public:
    TypeName("efficiencyFunction");

    declareRunTimeSelectionTable
    (
        autoPtr,
        efficiencyFunction,
        dictionary,
        (
            const volVectorField& U,
            const scalar& TF
        ),
        (U, TF)
    );

    //- Return a reference to the selected LES model
    static autoPtr<efficiencyFunction> New
    (
        const volVectorField& U,
        const scalar& TF
    );



    efficiencyFunction(const volVectorField& U, const scalar& TF);
    ~efficiencyFunction();

    inline const volScalarField& eff() const 
        { return efficiency_; }

    //- Access function to filter width
    inline const volScalarField& delta() const
        {
            return delta_();
        }    
 

    virtual void correct() =0;
};

}

#endif
How should I update it?



As the first solution, I tried to copy the old version of LESdelta.C and LESdelta.H files in my solver folder and compiled it. It worked fine. But when I was trying to run a test case I got the below error:

Code:
#0  Foam::error::printStack(Foam::Ostream&) in "/opt/OpenFOAM/OpenFOAM-v1606+/platforms/linux64GccDPInt32Opt/lib/libOpenFOAM.so"
#1  Foam::sigSegv::sigHandler(int) in "/opt/OpenFOAM/OpenFOAM-v1606+/platforms/linux64GccDPInt32Opt/lib/libOpenFOAM.so"
#2  ? in "/lib64/libc.so.6"
#3  Foam::LESdelta::LESdelta(Foam::word const&, Foam::turbulenceModel const&) in "/opt/OpenFOAM/OpenFOAM-v1606+/platforms/linux64GccDPInt32Opt/lib/libturbulenceModels.so"
#4  Foam::LESModels::cubeRootVolDelta::cubeRootVolDelta(Foam::word const&, Foam::turbulenceModel const&, Foam::dictionary const&) in "/opt/OpenFOAM/OpenFOAM-v1606+/platforms/linux64GccDPInt32Opt/lib/l
ibturbulenceModels.so"
#5  Foam::LESdelta::adddictionaryConstructorToTable<Foam::LESModels::cubeRootVolDelta>::New(Foam::word const&, Foam::turbulenceModel const&, Foam::dictionary const&) in "/opt/OpenFOAM/OpenFOAM-v1606+/
platforms/linux64GccDPInt32Opt/lib/libturbulenceModels.so"
#6  ? in "/home/ofuser/OpenFOAM/ofuser-v1606+/platforms/linux64GccDPInt32Opt/bin/TFM-Foam"
#7  ? in "/home/ofuser/OpenFOAM/ofuser-v1606+/platforms/linux64GccDPInt32Opt/bin/TFM-Foam"
#8  ? in "/home/ofuser/OpenFOAM/ofuser-v1606+/platforms/linux64GccDPInt32Opt/bin/TFM-Foam"
#9  Foam::efficiencyFunction::adddictionaryConstructorToTable<Foam::colinWrinkling>::New(Foam::GeometricField<Foam::Vector<double>, Foam::fvPatchField, Foam::volMesh> const&, double const&) in "/home/
ofuser/OpenFOAM/ofuser-v1606+/platforms/linux64GccDPInt32Opt/bin/TFM-Foam"
#10  ? in "/home/ofuser/OpenFOAM/ofuser-v1606+/platforms/linux64GccDPInt32Opt/bin/TFM-Foam"
#11  ? in "/home/ofuser/OpenFOAM/ofuser-v1606+/platforms/linux64GccDPInt32Opt/bin/TFM-Foam"
#12  __libc_start_main in "/lib64/libc.so.6"
#13  ? in "/home/ofuser/OpenFOAM/ofuser-v1606+/platforms/linux64GccDPInt32Opt/bin/TFM-Foam"
Segmentation fault
Zack is offline   Reply With Quote

Old   February 11, 2017, 16:23
Default
  #4
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
LESDeltas developed using new API (cubeRootVolDelta in you output) can not live with old LESDelta API. Hence, segmentation fault.

Modification should be made here (efficiencyFunction.C):

Code:
delta_(LESdelta::New("delta", U.mesh(), *this))
Instead of U.mesh(), which is fvMesh, there should be turbulenceModel now. You can use lookupObject or lookupClass to get it form objectRegistry, you can change your API, so user pass turbulenceModel instead of volVectorField to contructor (and then you can use U method of turbulence model to get velocity field, if you need it).
Zack and Uyan like this.
alexeym is offline   Reply With Quote

Old   February 12, 2017, 13:58
Default
  #5
New Member
 
Join Date: Sep 2012
Posts: 23
Rep Power: 13
Zack is on a distinguished road
Thank you alexeym for your help.

I am getting a little bit confused by employing of your suggestion in :

Code:
delta_(LESdelta::New("delta", U.mesh(), *this))
If I want to call turbulenceModel here instead of U.mesh(), which term should I use? What are the options to use here basically?
Zack is offline   Reply With Quote

Old   February 12, 2017, 14:28
Default
  #6
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Unfortunately now I am not quite getting your question. Instead of U.mesh(), which has type const fvMesh&, you have to pass something with type turbulenceModel& (guess you have turbulence model in your solver).

You have several choices:

1. You have turbulence model variable at the place of LESDelta creation, pass this variable as the second parameter to LESDelta::New.

2. You do not have turbulence model variable at the place of LESDelta creation. Since turbulenceModel has IOdictionary as parent, it is registered in object registry, and you can look it up by a) name using lookupObject<turbulenceModel>(name), b) look it up by class using lookupClass<turbulenceModel>(). And then pass result as a second parameter to LESDelta::New.
Zack and Uyan like this.
alexeym is offline   Reply With Quote

Old   February 14, 2017, 11:59
Default
  #7
New Member
 
Join Date: Sep 2012
Posts: 23
Rep Power: 13
Zack is on a distinguished road
I am sorry if my question makes you confused. That's probably because I have never done that before and my question is more fundamental!

I prefer to look it up in turbulenceProperties dictionary. I tried two different ways. I added below lines to my C file :

Code:
const turbulenceModel& turbModel = db().lookupObject<turbulenceModel>(turbName);

delta_(LESdelta::New("delta", turbName, *this))
or

Code:
{
	word typeTurb;

            IOdictionary propertiesDict
                (
                    IOobject
                    (
                        "turbulenceProperties",
                        U.time().constant(),
                        U.db(),
                        IOobject::MUST_READ,
                        IOobject::NO_WRITE
                    )
                );
            
            propertiesDict.lookup("simulationType") 
                >> typeTurb;

        }
			
          delta_(LESdelta::New("delta", typeTurb, *this))
But non of them works. Could you pls correct them?
Zack is offline   Reply With Quote

Old   February 14, 2017, 14:56
Default
  #8
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
Fancier and fancier...

As I said the second parameter of LESdelta::New should have type turbulenceModel. I do not know what is turbName in your first example and I do not know why you have decided to pass word instead of turbulenceModel.

Here are two examples of how you can construct LESdelta using only fvMesh:

Code:
void strange_function_creating_les_delta(const fvMesh& mesh)
{
  const turbulenceModel& turbulence_model =
    mesh.lookupObject<turbulenceModel>("turbulenceProperties");
  dictionary dict;
  dict.add("delta", "vanDriest");
  dictionary coeffs;
  coeffs.add("delta", "cubeRootVol");
  dictionary crv_coeffs;
  coeffs.add("cubeRootVolCoeffs", crv_coeffs);
  dict.add("vanDriestCoeffs", coeffs);
  autoPtr<LESdelta> delta(
    LESdelta::New("delta", turbulence_model, dict));
}
As I have already suggested, you utilize lookupObject to find your created turbulence model. Instead of constructing dictionary by hand, you can pass LES subdictionary of you turbulenceProperties.

Output

Code:
Selecting LES delta type vanDriest
Selecting LES delta type cubeRootVol
Also LESdelta is a part of LESModel, the only problem - it is protected. So you can create child of LESModel and do pointer entertainment, something like this:

Code:
class DeltaGetter : public LESModel<incompressible::turbulenceModel>
{
public:
  DeltaGetter(
    const word& type,
    const alphaField& alpha,
    const rhoField& rho,
    const volVectorField& U,
    const surfaceScalarField& alphaRhoPhi,
    const surfaceScalarField& phi,
    const transportModel& transport,
    const word& propertiesName)
    :
    LESModel<incompressible::turbulenceModel>(
      type, alpha, rho, U, alphaRhoPhi, phi, transport, propertiesName)
  {}
  ~DeltaGetter() {}

  LESdelta& delta() { return const_cast<LESdelta&>(delta_()); }
};

void strange_function_getting_reference_to_les_delta(const fvMesh& mesh)
{
  void* model =
    static_cast<void*>(
      &(const_cast<turbulenceModel&>(
          mesh.lookupObject<turbulenceModel>("turbulenceProperties"))));
  DeltaGetter* dg = static_cast<DeltaGetter*>(model);
  LESdelta& delta = dg->delta();
  Info << delta.type() << endl;
}
Once again you utilize lookupObject to get turbulenceModel reference and then use all these casts to access protected delta_ property through child.

Output (in $FOAM_TUTORIALS/incompressible/pisoFoam/les/pitzDaily):

Code:
cubeRootVol
Zack likes this.
alexeym is offline   Reply With Quote

Old   February 15, 2017, 00:34
Default
  #9
New Member
 
Join Date: Sep 2012
Posts: 23
Rep Power: 13
Zack is on a distinguished road
Hands up !!! Unfortunately I couldn't fix it! I attached the files. Could you pls fix it for me ?!
Attached Files
File Type: c efficiencyFunction.C (2.5 KB, 9 views)
File Type: h efficiencyFunction.H (1.1 KB, 7 views)
Zack is offline   Reply With Quote

Old   February 15, 2017, 02:40
Default
  #10
Senior Member
 
Alexey Matveichev
Join Date: Aug 2011
Location: Nancy, France
Posts: 1,930
Rep Power: 38
alexeym has a spectacular aura aboutalexeym has a spectacular aura about
Send a message via Skype™ to alexeym
You can fix it in many ways, for example:

Code:
    efficiencyFunction::efficiencyFunction(
        const volVectorField& U, const scalar& TF)
        :
        IOdictionary(
            IOobject(
                "efficiencyFunctionProperties", U.time().constant(),
                U.db(), IOobject::MUST_READ)),
        U_(U),
        TF_(TF),
        efficiency_(
            IOobject(
                "efficiency", U.time().timeName(), U.mesh(),
                IOobject::NO_READ, IOobject::AUTO_WRITE),
            U.mesh(),
            dimensionedScalar("efficiency", dimless, 1.0)),
        delta_(
            LESdelta::New(
                "delta",
                U.mesh().lookupObject<turbulenceModel>("turbulenceProperties"),
                *this))
    {}
or

Code:
    efficiencyFunction::efficiencyFunction(
        const volVectorField& U, const scalar& TF)
        :
        ...
        delta_()  // default nullptr value for pointer
    {
        // Here we can put code to look up turbulence model and create delta
        // For example:
        const turbulenceModel& turbulence_model =
            U.mesh().lookupObject<turbulenceModel>("turbulenceProperties");
        delta_ = LESdelta::New("delta", turbulence_model, *this);
    }
Implementation in fact depends on your preferences and the way you plan to use this LESdeta. For example, if you need it just to access filter width, you can access it through LES turbulence model object (https://cpp.openfoam.org/v4/a01321.h...ba9b247a5ef8ea).
Zack and Uyan like this.

Last edited by alexeym; February 16, 2017 at 04:22. Reason: U.mesh() instead of just mesh
alexeym is offline   Reply With Quote

Old   February 16, 2017, 12:20
Default
  #11
New Member
 
Join Date: Sep 2012
Posts: 23
Rep Power: 13
Zack is on a distinguished road
It is working now! I appreciate for your help.
Zack is offline   Reply With Quote

Old   August 29, 2018, 11:57
Default
  #12
Member
 
Join Date: Feb 2014
Posts: 63
Rep Power: 12
Uyan is on a distinguished road
Hi Zack, Alexey,

I am also having the same problem with same code, unlike Zack I am trying to use this solver with OpenFOAM-dev version.
When I looked at the LESdelta.H files between v1606 and OF-dev there is no difference at all.

So the solution methods by Alexey should ideally work on my case.
But I still get the following error for both method


Code:
efficiencyFunction.C: In constructor 'Foam::efficiencyFunction::efficiencyFunction(const volVectorField&, Foam::volScalarField&)':
efficiencyFunction.C:91:65: error: no matching function for call to 'Foam::LESdelta::New(const char [6], const Foam::turbulenceModel&, Foam::efficiencyFunction&)'
          delta_ = LESdelta::New("delta", turbulence_model, *this);
                                                                 ^
I have also included TurbulenceModel.H header file to the header file of the efficiency class.


If you guys could help me here, I would be very thankful.
Uyan is offline   Reply With Quote

Old   August 29, 2018, 15:22
Default
  #13
Member
 
Join Date: Feb 2014
Posts: 63
Rep Power: 12
Uyan is on a distinguished road
Hi,

Sorry to bother you guys, I fixed it.
Uyan 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
when running tutorial: Permission denied collect2: ld returned 1 exit status semaviso OpenFOAM Running, Solving & CFD 3 December 12, 2019 10:03
[swak4Foam] Error bulding swak4Foam sfigato OpenFOAM Community Contributions 18 August 22, 2013 12:41
[swak4Foam] Installing swak4Foam to OpenFOAM in mac Kaquesang OpenFOAM Community Contributions 22 January 21, 2013 11:51
OpenFOAM 1.6-ext git installation on Ubuntu 11.10 x64 Attesz OpenFOAM Installation 45 January 13, 2012 12:38
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug unoder OpenFOAM Installation 11 January 30, 2008 20:30


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