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

‘argc’ was not declared in this scope

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   October 7, 2021, 07:26
Default ‘argc’ was not declared in this scope
  #1
New Member
 
Philipp Conen
Join Date: Jul 2021
Location: Germany, NRW
Posts: 22
Rep Power: 4
philippconen is on a distinguished road
Dear Foamers,

for the first time, I am trying to compile an application in OpenFOAM.

Regarding my needs, I would like to build the code mentioned in this thread: https://www.cfd-online.com/Forums/op...ary-patch.html
Code:
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"

label PatchID = mesh.boundaryMesh().findPatchID("tuyau");

const polyPatch& patchFound = mesh.boundaryMesh()[PatchID];

labelList labelPatchFound( patchFound.meshPoints() );

pointField meshPoints(mesh.points());

long nombre = 0;

forAll(labelPatchFound , label)
{
vector coord = meshPoints[labelPatchFound[label]];
Info << coord[0] << " " << coord[1] << " " << coord[2] << endl;
nombre++;
}

Info << nombre << endl;
Having no idea how to do this I started with the tutorial by Stefan Radl: https://wiki.openfoam.com/Programming_by_Stefan_Radl and also read the guide: https://cfd.direct/openfoam/user-guide/v6-applications/.

After trying to merge a simple code from the tutorial with the above-mentioned code I am getting the following output (errors).

Code:
philipp@philipp-MS-7A38:~/OpenFOAM/philipp-3.0.1/apps/patchPointsOrder$ wmake
Making dependency list for source file patchPointsOrder.C
g++-5 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=64 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3  -DNoRepository -ftemplate-depth-100 -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/finiteVolume/lnInclude 	-I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/meshTools/lnInclude -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OpenFOAM/include -IlnInclude -I. -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OpenFOAM/lnInclude -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OSspecific/POSIX/lnInclude   -fPIC -c patchPointsOrder.C -o Make/linux64GccDPInt64Opt/patchPointsOrder.o
In file included from patchPointsOrder.C:17:0:
/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OpenFOAM/include/setRootCase.H: In function ‘int main()’:
/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OpenFOAM/include/setRootCase.H:5:24: error: ‘argc’ was not declared in this scope
     Foam::argList args(argc, argv);
                        ^
/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OpenFOAM/include/setRootCase.H:5:30: error: ‘argv’ was not declared in this scope
     Foam::argList args(argc, argv);
                              ^
/home/philipp/OpenFOAM/OpenFOAM-3.0.1/wmake/rules/General/transform:8: recipe for target 'Make/linux64GccDPInt64Opt/patchPointsOrder.o' failed
make: *** [Make/linux64GccDPInt64Opt/patchPointsOrder.o] Error 1
Sadly, I quite not know where to start. Is it a problem of the linking or maybe the code?
/Make/files:
Code:
patchPointsOrder.C

EXE = $(FOAM_USER_APPBIN)/patchPointsOrder
/Make/options:
Code:
EXE_INC = \
	-I$(LIB_SRC)/finiteVolume/lnInclude \
	-I$(LIB_SRC)/meshTools/lnInclude \
        -I$(LIB_SRC)/OpenFOAM/include
	
EXE_LIBS = \
	-lfiniteVolume
tree:
Code:
philipp@philipp-MS-7A38:~/OpenFOAM/philipp-3.0.1/apps/patchPointsOrder$ tree
.
├── Make
│** ├── files
│** ├── linux64GccDPInt64Opt
│** │** ├── options
│** │** ├── patchPointsOrder.C.dep
│** │** ├── sourceFiles
│** │** └── variables
│** └── options
└── patchPointsOrder.C
Also, I am not sure what work needs exactly to be done to file the options file in the correct way. So in other works - where or how do I get the information on which paths and libraries I need to put in there?

I would be very happy about any help.

My OpenFOAM is version 3.0.1.

Greetings!
philippconen is offline   Reply With Quote

Old   October 7, 2021, 12:53
Default
  #2
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 663
Rep Power: 13
Tobermory will become famous soon enough
Ok - a quick question - was the code that you quoted at the top your whole code? If not, then it would be best to include the whole code.

If it WAS, then you need to just brush up on your basic C++, since the implementation file needs to be of the form:

Code:
#include "something.H"

int main(int argc, char *argv[])
{

   #include "somethingElse.H"

   insert your coding here

   return(0);
}
i.e. you forgot to enclose your coding in a main{}, so the compiler is getting rather confused.
Tobermory is offline   Reply With Quote

Old   October 7, 2021, 13:08
Default
  #3
New Member
 
Philipp Conen
Join Date: Jul 2021
Location: Germany, NRW
Posts: 22
Rep Power: 4
philippconen is on a distinguished road
Dear Tobermory,

many many thanks for the fast reply!

So my first try was:
Code:
#include "vector.H"
#include "IOstreams.H"

#include "scalar.H"
#include "fvCFD.H"
#include "OFstream.H"

#define FIELDSIZE 4

using namespace Foam;

typedef Field<scalar> binningField;
typedef Field<vector> binningVField;

int main()
{	
    #include "setRootCase.H"
    #include "createTime.H"
    #include "createMesh.H"
    
    label PatchID = mesh.boundaryMesh().findPatchID("tuyau");
    
    const polyPatch& patchFound = mesh.boundaryMesh()[PatchID];
    
    labelList labelPatchFound( patchFound.meshPoints() );
    
    pointField meshPoints(mesh.points());
    
    long nombre = 0;
    
    forAll(labelPatchFound , label)
    {
    vector coord = meshPoints[labelPatchFound[label]];
    Info << coord[0] << " " << coord[1] << " " << coord[2] << endl;
    nombre++;
    }
    
    Info << nombre << endl;
    return 0;
}
(Sorry that I don't mentioned this fact at first..) So I forgot the "int argc, char *argv[]" inside the main.

After your answer I changed it to:
Code:
#include "vector.H"
#include "IOstreams.H"

#include "scalar.H"
#include "fvCFD.H"
#include "OFstream.H"

#define FIELDSIZE 4

using namespace Foam;

typedef Field<scalar> binningField;
typedef Field<vector> binningVField;

int main(int argc, char *argv[])
{	
    #include "setRootCase.H"
    #include "createTime.H"
    #include "createMesh.H"
    
    label PatchID = mesh.boundaryMesh().findPatchID("tuyau");
    
    const polyPatch& patchFound = mesh.boundaryMesh()[PatchID];
    
    labelList labelPatchFound( patchFound.meshPoints() );
    
    pointField meshPoints(mesh.points());
    
    long nombre = 0;
    
    forAll(labelPatchFound , label)
    {
    vector coord = meshPoints[labelPatchFound[label]];
    Info << coord[0] << " " << coord[1] << " " << coord[2] << endl;
    nombre++;
    }
    
    Info << nombre << endl;
    return 0;
}
and it compiled
Code:
philipp@philipp-MS-7A38:~/OpenFOAM/philipp-3.0.1/apps/patchPointsOrder$ wclean
philipp@philipp-MS-7A38:~/OpenFOAM/philipp-3.0.1/apps/patchPointsOrder$ wmake
Making dependency list for source file patchPointsOrder.C
g++-5 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=64 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3  -DNoRepository -ftemplate-depth-100 -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/finiteVolume/lnInclude 	-I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/meshTools/lnInclude -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OpenFOAM/include -IlnInclude -I. -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OpenFOAM/lnInclude -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OSspecific/POSIX/lnInclude   -fPIC -c patchPointsOrder.C -o Make/linux64GccDPInt64Opt/patchPointsOrder.o
g++-5 -m64 -Dlinux64 -DWM_ARCH_OPTION=64 -DWM_DP -DWM_LABEL_SIZE=64 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -O3  -DNoRepository -ftemplate-depth-100 -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/finiteVolume/lnInclude 	-I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/meshTools/lnInclude -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OpenFOAM/include -IlnInclude -I. -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OpenFOAM/lnInclude -I/home/philipp/OpenFOAM/OpenFOAM-3.0.1/src/OSspecific/POSIX/lnInclude   -fPIC -Xlinker --add-needed -Xlinker --no-as-needed Make/linux64GccDPInt64Opt/patchPointsOrder.o -L/home/philipp/OpenFOAM/OpenFOAM-3.0.1/platforms/linux64GccDPInt64Opt/lib \
    -lfiniteVolume -lOpenFOAM -ldl  \
     -lm -o /home/philipp/OpenFOAM/philipp-3.0.1/platforms/linux64GccDPInt64Opt/bin/patchPointsOrder
When I now run the program I get:
Code:
philipp@philipp-MS-7A38:~/OpenFOAM/philipp-3.0.1/run/DLR/Working/airfoil2D_dynMesh_rotateProfile$ patchPointsOrder 
/*---------------------------------------------------------------------------*\
| =========                 |                                                 |
| \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox           |
|  \\    /   O peration     | Version:  3.0.1                                 |
|   \\  /    A nd           | Web:      www.OpenFOAM.org                      |
|    \\/     M anipulation  |                                                 |
\*---------------------------------------------------------------------------*/
Build  : 3.0.1-d8a290b55d28
Exec   : patchPointsOrder
Date   : Oct 07 2021
Time   : 18:01:23
Host   : "philipp-MS-7A38"
PID    : 16476
Case   : /home/philipp/OpenFOAM/philipp-3.0.1/run/DLR/Working/airfoil2D_dynMesh_rotateProfile
nProcs : 1
sigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).
fileModificationChecking : Monitoring run-time modified files using timeStampMaster
allowSystemOperations : Allowing user-supplied system call operations

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

#0  Foam::error::printStack(Foam::Ostream&) at ??:?
#1  Foam::sigSegv::sigHandler(int) at ??:?
#2  ? in "/lib/x86_64-linux-gnu/libc.so.6"
#3  ? in "/home/philipp/OpenFOAM/philipp-3.0.1/platforms/linux64GccDPInt64Opt/bin/patchPointsOrder"
#4  __libc_start_main in "/lib/x86_64-linux-gnu/libc.so.6"
#5  ? in "/home/philipp/OpenFOAM/philipp-3.0.1/platforms/linux64GccDPInt64Opt/bin/patchPointsOrder"
Speicherzugriffsfehler (Speicherabzug geschrieben)
But I think this is a problem which depends on the code. (Correct me if I am wrong)
Tomorrow I will go on and try to check what could be wrong in the code.

Again many thanks!

Greetings!
philippconen is offline   Reply With Quote

Old   October 7, 2021, 13:13
Default
  #4
Senior Member
 
Join Date: Apr 2020
Location: UK
Posts: 663
Rep Power: 13
Tobermory will become famous soon enough
Excellent - yes, it looks like it has got past the creatTime.H and createMesh.H lines, and is into the main coding. My advice is to pepper the code with
Code:
 Info << variable
statements to check the variable contents and check how each line is behaving. All the best.

T
Tobermory is offline   Reply With Quote

Reply

Tags
application, argv, code, compilation error, linking

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Compile calcMassFlowC aurore OpenFOAM Programming & Development 13 March 23, 2018 08:43
error compiling modified applications yvyan OpenFOAM Programming & Development 21 March 1, 2016 05:53
Compile problem ivanyao OpenFOAM Running, Solving & CFD 1 October 12, 2012 10:31
checking the system setup and Qt version vivek070176 OpenFOAM Installation 22 June 1, 2010 13:34
How to get the max value of the whole field waynezw0618 OpenFOAM Running, Solving & CFD 4 June 17, 2008 06:07


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