CFD Online Logo CFD Online URL
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Newbie compiling source code for debugging

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

LinkBack Thread Tools Display Modes
Old   July 28, 2006, 16:41
Default Sorry for asking a stupid ques
Posts: n/a
Sorry for asking a stupid question, perhaps nobody understood it. But since openfoam is open source, I really expected that someone could be helpful enough to explain why debug information is missing from this path:

/home/dm2/henry/OpenFOAM/linuxSrc/gcc-4.1.0/build/i686-pc-linux-gnu/libstdc++-v3 /include/bits/basic_string.h

I know you don't get paid for answering me, but isn't this so simple that it only takes 2 seconds to answer it?
  Reply With Quote

Old   July 30, 2006, 15:40
Default I guess there are still some .
Assistant Moderator
Bernhard Gschaider
Join Date: Mar 2009
Posts: 4,045
Rep Power: 43
gschaider will become famous soon enoughgschaider will become famous soon enough
I guess there are still some .o or .so files lingering around which were built on Henry Wellers machine and not properly touched by your Allwmake. Use the find-command to find all .o and .so files in your OpenFOAM-installation that were created BEFORE your own building session and remove them. Then rebuild.

About that's part of the standard-C++-library: I think it's highly unlikely that problems with your programs stem from that.
Note: I don't use "Friend"-feature on this forum out of principle. Ah. And by the way: I'm not on Facebook either. So don't be offended if I don't accept your invitation/friend request
gschaider is offline   Reply With Quote

Old   July 31, 2006, 03:15
Default This looks like a problenm wit
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,810
Rep Power: 25
hjasak will become famous soon enough
This looks like a problenm with compiler relocation. I usually build mine into /usr/tmp, which makes it easier, but you should be able to easily build your own compiler. You can download gcc-4.1.1 source from one of the gcc sites. Then, remove the compiler from ~/OpenFOAM/linux/gcc-4.1.1 (just delete the directory + I am assuming you're using linux) and build your own using the following steps:

cd ~/OpenFOAM
mkdir linuxSrc
cd linuxSrc

Copy the compiler tar pack here (if you cannot find it, pls let me know and I will leave one for you somewhere convenient).

tar xzf gcc-4.1.1.tar.gz
mkdir gcc-4.1.1-obj
cd gcc-4.1.1-obj
../gcc-4.1.1/configure --prefix=~/OpenFOAM/linux/gcc-4.1.1 --enable-languages=c,c++ --enable-shared

Now build it:

gmake bootstrap

and install it:

gmake install

You can now delete the directories in ~/OpenFOAM/linuxSrc

As for the clean, OpenFOAM gives you a few scripts to clean the whole lot:

wcleanAll - cleans all the machines
wcleanMachile <build> - only cleans the named build, e.g. linuxGcc4DPDebug


Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting:
hjasak is offline   Reply With Quote

Old   August 2, 2006, 01:44
Default Thanks Bernhard and Hrv, 1)
Posts: n/a
Thanks Bernhard and Hrv,

1) The first solution seems to be the easiest, but I'm afraid of deleting something that I shouldn't... I guess the first solution requires something like:

a) cd ~/OpenFOAM/OpenFOAM-1.3/ instead of cd ~/OpenFOAM ?

b) find . \( -iname *.so -o -iname _.o \) ! -newer ~/OpenFOAM/OpenFOAM-1.3/lib/linuxGcc4DPDebug -exec rm (or similar?)

2) The second solution is much more difficult to understand, but at least I don't think I'll delete something I need. I don't know what "compiler relocation" means, but if I type "which gcc" I get:

/home/martin/OpenFOAM/linux/gcc-4.1.0/bin/gcc, so I would expect that everything was okay as it uses the gcc-binary "associated" with OF.

I followed the steps to create linuxSrc and downloaded gcc-4.1.1.tar.bz2 which is a 38 KB file. It was unzipped with tar -xvjf (filename) and put into OpenFOAM/linux. It made a lot of files into ~/OpenFOAM/linux/gcc-4.1.1

I then created ~/OpenFOAM/linuxSrc/gcc-4.1.1-obj and inside that directory I did:

../../ (path to linux/gcc-4.1.1).../configure --prefix=/home/martin/OpenFOAM/linux/gcc-4.1.1 --enable-languages=c,c++ --enable-shared

Compilation seem to take pretty long - my 2 GHz laptop is compiling right now at this moment.... I wonder what it might be doing in all that time....

I also want to disable compiler optimization so I can better debug into the OpenFOAM source-code without "jumping" like when optimization was enabled in some other windows source code I have tried... How to get rid of that -O2 option in my next step, where I'll make some new linuxGcc4DPDebug-files... ?

I'll let you know whether I succeed or not in this task (I really hope I do) :-)
  Reply With Quote

Old   August 2, 2006, 02:18
Default Oooh, damn... This is what
Posts: n/a
Oooh, damn...

This is what I did:

martin@laptop:~/OpenFOAM/linuxSrc/gcc-4.1.1-obj> ../../linux/gcc-4.1.1/configure --prefix=/home/martin/OpenFOAM/linux/gcc-4.1.1 --enable-languages=c,c++ --enable-shared

... followed by: "gmake bootstrap"

This is the last couple of lines from the above command:

............then mv -f ".deps/mf-runtime.Tpo" ".deps/mf-runtime.Plo"; else rm -f ".deps/mf-runtime.Tpo"; exit 1; fi
mkdir .libs
/home/martin/OpenFOAM/linuxSrc/gcc-4.1.1-obj/./gcc/xgcc -B/home/martin/OpenFOAM/linuxSrc/gcc-4.1.1-obj/./gcc/ -B/home/martin/OpenFOAM/linux/gcc-4.1.1/i686-pc-linux-gnu/bin/ -B/home/martin/OpenFOAM/linux/gcc-4.1.1/i686-pc-linux-gnu/lib/ -isystem /home/martin/OpenFOAM/linux/gcc-4.1.1/i686-pc-linux-gnu/include -isystem /home/martin/OpenFOAM/linux/gcc-4.1.1/i686-pc-linux-gnu/sys-include -DHAVE_CONFIG_H -I. -I../../../../linux/gcc-4.1.1/libmudflap -I. -Wall -ffunction-sections -fdata-sections -O2 -g -O2 -MT mf-runtime.lo -MD -MP -MF .deps/mf-runtime.Tpo -c ../../../../linux/gcc-4.1.1/libmudflap/mf-runtime.c -fPIC -DPIC -o .libs/mf-runtime.o
../../../../linux/gcc-4.1.1/libmudflap/mf-runtime.c:310: error: redefinition of 'struct option'
gmake[5]: *** [mf-runtime.lo] Error 1
gmake[5]: Leaving directory `/home/martin/OpenFOAM/linuxSrc/gcc-4.1.1-obj/i686-pc-linux-gnu/libmudflap'
gmake[4]: *** [all-recursive] Error 1
gmake[4]: Leaving directory `/home/martin/OpenFOAM/linuxSrc/gcc-4.1.1-obj/i686-pc-linux-gnu/libmudflap'
gmake[3]: *** [all] Error 2
gmake[3]: Leaving directory `/home/martin/OpenFOAM/linuxSrc/gcc-4.1.1-obj/i686-pc-linux-gnu/libmudflap'
gmake[2]: *** [all-target-libmudflap] Error 2
gmake[2]: Leaving directory `/home/martin/OpenFOAM/linuxSrc/gcc-4.1.1-obj'
gmake[1]: *** [all] Error 2
gmake[1]: Leaving directory `/home/martin/OpenFOAM/linuxSrc/gcc-4.1.1-obj'
gmake: *** [bootstrap] Error 2
  Reply With Quote

Old   August 2, 2006, 13:15
Default This is really really bad: if
Senior Member
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,810
Rep Power: 25
hjasak will become famous soon enough
This is really really bad: if your machine cannot compile gcc (one of the most standard and basic installations), you are likely to have more trouble later. I have seen something like this with some dodgy versions of RedHat Enterprise Edition, and they require additional packages to get them to work. I would suggest searching the web for help on compiling gcc.

This kind of thing should really just work with a decent version of linux.

Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting:
hjasak is offline   Reply With Quote

Old   August 3, 2006, 11:55
Default I have suse 10.1, which I thin
Posts: n/a
I have suse 10.1, which I think is decent... But I must have screwed something up, somewhere in this process...

How about solution number 1? Is that possible?

If everything fails, I think I eventually will remove OpenFOAM and try to experiment by starting from scratch again and give it a couple of more shots again... Perhaps it'll work if I outcomment the OF-stuff that sets environment variables in bashrc, so it'll compile using the gcc binary in /usr/bin or wherever it is normally, instead of having a PATH environment that finds /home/martin/OpenFOAM/linux/gcc-4.1.0/bin/gcc

I'll try to see what I can come up with...
  Reply With Quote

Old   August 20, 2006, 06:30
Default Hi Foamers, I now got throu
Posts: n/a
Hi Foamers,

I now got through the entire process and I don't think I got any serious errors... I think what might have caused me errors was that I probably forgot to remove the compiler from ~/OpenFOAM/linux/gcc-4.1.0 before starting out and the other thing I did was to compile as root (not sure if necessary though).

../gcc-4.1.1/configure --prefix=/home/martin/OpenFOAM/linux/gcc-4.1.1 --enable-languages=c,c++ --enable-shared

I now have gcc-4.1.1 in ~/OpenFOAM/linux, but many places (in path-environment) OF was looking for gcc-4.1.0 so since I didn't knew where to change that and be sure of having changed everything I did a "dirty" solution and created a symbolic/soft link in ~/OpenFOAM/linux: gcc-4.1.0 -> gcc-4.1.1

Then I did ./Allwmake and I think it worked...


Next problem: ParaFOAM won't start. It seems like some files are not compiled:

martin@laptop:~/OpenFOAM/martin-1.3/run/tutorials/icoFoam> paraFoam . cavity &
[1] 23693
martin@laptop:~/OpenFOAM/martin-1.3/run/tutorials/icoFoam> ErrorMessage
# Error or warning: ERROR: In ../../../../../paraview-2.4.2/Utilities/VTKClientServer/vtkClientServerInterpret er.cxx, line 866
vtkClientServerInterpreter (0x8065c98): Cannot find module "". The following paths were searched:
/home/martin/OpenFOAM/OpenFOAM-1.3/src/mico-2.3.11/platforms/linuxGcc4DPDebug/bi n

ERROR: In ../../../../../paraview-2.4.2/GUI/Client/vtkPVXMLPackageParser.cxx, line 677
vtkPVXMLPackageParser (0x88a4b40): Error loading Library component PVFoamReader

ErrorMessage end
# Error or warning: There was a VTK Error in file: ../../../../../paraview-2.4.2/GUI/Client/vtkPVWindow.cxx (2364)
vtkPVWindow (0x8251530): Cannot read file information when no reader is specified. This probably means that the reader for the file with name: /home/martin/OpenFOAM/martin-1.3/run/tutorials/icoFoam/cavity/cavity.foam cannot be found
ErrorMessage end
# Error or warning: There was a VTK Error in file: ../../../../../paraview-2.4.2/GUI/Widgets/vtkKWApplication.cxx (1335)
vtkPVApplication (0x80d7aa0):
Returned Error on line 11:
invalid command name ""
ErrorMessage end

[1]+ Done paraFoam . cavity


Okay, let's see if we can find module "":

martin@laptop:~/OpenFOAM> pwd

martin@laptop:~/OpenFOAM> find . -iname ""

Damn.... It only exists in the optimized compilation.

martin@laptop:~/OpenFOAM> pwd
martin@laptop:~/OpenFOAM> cd OpenFOAM-1.3/lib
martin@laptop:~/OpenFOAM/OpenFOAM-1.3/lib> ls -l linuxGcc4DPOpt | wc
57 450 3985
martin@laptop:~/OpenFOAM/OpenFOAM-1.3/lib> ls -l linuxGcc4DPDebug | wc
55 434 3953

Okay, it seems to me like 2 files are missing... What did I do in the first place?
In /home/martin/OpenFOAM/OpenFOAM-1.3/.OpenFOAM-1.3
I changed the file to this:

# Compilation options (default precision, optimised, debug or profiling)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~


export WM_JAVAC_OPTION=Debug


What now? How to get ParaFOAM to work? I guess it wasn't necessary to make WM_JAVAC_OPTION=Debug but I thought why not...

  Reply With Quote

Old   August 24, 2006, 01:41
Default Hrv? Perhaps I should add t
Posts: n/a

Perhaps I should add that after running wcleanMachine linuxGcc4DPDebug and running the Allwmake-script, sometimes I got a message like this:

`/home/martin/OpenFOAM/OpenFOAM-1.3/lib/linuxGcc4DPDebug/' is up to date.

So I need "" - how to get it, if the Allwmake script doesn't make it?
  Reply With Quote


Thread Tools
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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problems while compiling source sahas OpenFOAM Installation 2 October 20, 2007 12:47
Source-Code Peter FLUENT 2 October 11, 2006 06:10
when compiling UDF---erro code 1 occur lamlash FLUENT 0 July 15, 2006 05:00
the source code of "the are of MDS" ztdep Main CFD Forum 1 May 22, 2006 13:39
Problems with compiling CFD code! ravi Main CFD Forum 1 July 12, 2004 11:28

All times are GMT -4. The time now is 07:02.