3rd Step to OpenFOAM: compiling

Copy whole app folder from 

/usr/lib/openfoam/openfoam2306/etc/codeTemplates/app, 

Paste into user folder 

~/OpenFOAM/jk-v2306/platforms/linux64GccDPInt32Opt/bin/


While I was renaming the folder and C files within the folder, eg.

mv app.C Lesson1-HelloWorld

because I failed to rename it as Lesson1-HelloWorld.C

Compiler fails to recognise there's a C file.

 

Edit Make/file. Ensure the EXE file name is different from the folder name, or you will get an error:


jk@JK:~/OpenFOAM/jk-v2306/platforms/linux64GccDPInt32Opt/bin/Lesson1-HelloWorld$ wmake
Making dependencies: Lesson1-HelloWorld.C
g++ -std=c++14 -m64 -pthread -DOPENFOAM=2306 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -Wno-unknown-pragmas -O3  -DNoRepository -ftemplate-depth-100  -I/usr/lib/openfoam/openfoam2306/src/finiteVolume/lnInclude -I/usr/lib/openfoam/openfoam2306/src/meshTools/lnInclude -iquote. -IlnInclude -I/usr/lib/openfoam/openfoam2306/src/OpenFOAM/lnInclude -I/usr/lib/openfoam/openfoam2306/src/OSspecific/POSIX/lnInclude   -fPIC -c Lesson1-HelloWorld.C -o Make/linux64GccDPInt32Opt/Lesson1-HelloWorld.o
g++ -std=c++14 -m64 -pthread -DOPENFOAM=2306 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -Wno-unknown-pragmas -O3  -DNoRepository -ftemplate-depth-100  -I/usr/lib/openfoam/openfoam2306/src/finiteVolume/lnInclude -I/usr/lib/openfoam/openfoam2306/src/meshTools/lnInclude -iquote. -IlnInclude -I/usr/lib/openfoam/openfoam2306/src/OpenFOAM/lnInclude -I/usr/lib/openfoam/openfoam2306/src/OSspecific/POSIX/lnInclude   -fPIC -Xlinker --add-needed -Xlinker --no-as-needed  Make/linux64GccDPInt32Opt/Lesson1-HelloWorld.o -L/usr/lib/openfoam/openfoam2306/platforms/linux64GccDPInt32Opt/lib \
    -lfiniteVolume -lmeshTools -lOpenFOAM -ldl  \
     -lm -o /home/jk/OpenFOAM/jk-v2306/platforms/linux64GccDPInt32Opt/bin/Lesson1-HelloWorld
/usr/bin/ld: cannot open output file /home/jk/OpenFOAM/jk-v2306/platforms/linux64GccDPInt32Opt/bin/Lesson1-HelloWorld: Is a directory
collect2: error: ld returned 1 exit status

make: *** [/usr/lib/openfoam/openfoam2306/wmake/makefiles/general:170: /home/jk/OpenFOAM/jk-v2306/platforms/linux64GccDPInt32Opt/bin/Lesson1-HelloWorld] Error 1

 

So edit the Make/file like so:
 

before compiling, be sure to source the intended version of OF (in my case, of2306) 

jk@JK:~/OpenFOAM/jk-v2306/platforms/linux64GccDPInt32Opt/bin/Lesson1-HelloWorld$ of2306

Other compile attempt where the Lesson1-HelloWorld was not renamed with C suffix.

jk@JK:~/OpenFOAM/jk-v2306/platforms/linux64GccDPInt32Opt/bin/Lesson1-HelloWorld$ wmake
make: *** No rule to make target 'Make/linux64GccDPInt32Opt/Lesson1-HelloWorld.C.dep', needed by 'Make/linux64GccDPInt32Opt/Lesson1-HelloWorld.o'.  Stop.


Must rename mv app.C Lesson1-HelloWorld.C

Then successful compile output like so:

jk@JK:~/OpenFOAM/jk-v2306/platforms/linux64GccDPInt32Opt/bin/Lesson1-HelloWorld$ wmake
g++ -std=c++14 -m64 -pthread -DOPENFOAM=2306 -DWM_DP -DWM_LABEL_SIZE=32 -Wall -Wextra -Wold-style-cast -Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof -Wno-attributes -Wno-unknown-pragmas -O3  -DNoRepository -ftemplate-depth-100  -I/usr/lib/openfoam/openfoam2306/src/finiteVolume/lnInclude -I/usr/lib/openfoam/openfoam2306/src/meshTools/lnInclude -iquote. -IlnInclude -I/usr/lib/openfoam/openfoam2306/src/OpenFOAM/lnInclude -I/usr/lib/openfoam/openfoam2306/src/OSspecific/POSIX/lnInclude   -fPIC -Xlinker --add-needed -Xlinker --no-as-needed  Make/linux64GccDPInt32Opt/Lesson1-HelloWorld.o -L/usr/lib/openfoam/openfoam2306/platforms/linux64GccDPInt32Opt/lib \
    -lfiniteVolume -lmeshTools -lOpenFOAM -ldl  \
     -lm -o /home/jk/OpenFOAM/jk-v2306/platforms/linux64GccDPInt32Opt/bin/Lesson1

 

 

Comments

Popular posts from this blog

Thoughts on open sourcing education

1st Step to OpenFOAM

4th Step to OpenFOAM