Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello:
This question is addressed to specialists in C/C++ programming.
On patching a plugin to a computational C code everything runs plainly unless lapack libraries and C++ libraries are linked, as required for a special feature of the plugin. I tried linking along many routes, including full paths, as with:
With the line "LIBS= " left blank, patching occurs. With lapack, and dependencies, and c++ libs defined, as above, the error is:
...........................
...........................
Hunk #4 succeeded at 403 with fuzz 3 (offset 51 lines).
Hunk #5 succeeded at 429 (offset 53 lines).
-- Executing post script
plumed.inc:39: *** missing separator. Stop.
- DONE!
xxxxxxxxxxxxxxxxxx
Up to "Hunk #5", it is normal output, and hunking is complete. The "missing separator" error comes out whichever is done, except leaving the line "LIBS=" blank.
My question is whether the information given is sufficient to understand whether a correction is needed to the patch code. In the area where "plumed.inc" is mentioned, it reads:
{
echo -n "PLUMED_OBJECTS="
for file in $plumedir/common_files/*.c
do f=${file##*/}
echo " \\"
echo -n " \$(DSTDIR)/${f%.c}.o"
done
echo
if [ "$RECON_LIBS" != "" ] ; then
for file in $plumedir/recon_src/*.cpp
do f=${file##*/}
echo " \\"
echo -n " \$(DSTDIR)/${f%.cpp}.o"
done
echo " "
echo "RECON_FLAGS=\$(COPTD)RECONMETAD"
else
echo " "
echo "RECON_FLAGS="
fi
echo "RECON_LIBS="$RECON_LIBS
} > $WHERE_LINKS/plumed.inc
cd $myarch ; ln -s $WHERE_LINKS/plumed.inc .; make depends ; cd ../
}
To me ":39" is particularly confusing. If it refers to line number, then it is not pointing to the area where "plumed.in" is first mentioned. Rather, much earlier.
It looks like you have more need of help from someone knowing bash programming, not someone knowing C/C++ programming.
Quote:
Originally Posted by chiendarret
To me ":39" is particularly confusing. If it refers to line number, then it is not pointing to the area where "plumed.in" is first mentioned.
The 39 is a line number. But it is a line number inside the file plumed.inc, not a line number in the script that creates and uses plumed.inc
The code you quoted creates plumed.inc
Some other code, that I don't think you showed uses plumed.inc. But I don't know how plumed.inc is used nor what exactly prints the error message about line 39 of plumed.inc
I expect that after the whole action fails, the file plumed.inc ought to still exist. If you look at the portion around line 39, you ought to get some idea what is wrong with it, which then could be back tracked to what is wrong with the bash code that created it.
hello:
You are right (believe me, after posting I also realized that :39 refers to plumed.inc but badly failed to find the file; a simple "locate' was now enough). That plumed.inc is formed, on patching, into /maindir/src and reads:
(line 39 is the mere "/" after line "$(DSTDIR)/testderivatives.o")
In contrast, when the line RECON_LIBS= is left blank, patching occurs, "make depends" does its job, and "make" compiles the patched main code. In this case, the last portion of /src/plumed.inc reads:
Must add, if relevant, that, as opened with emacs, the whole block after line 39 "/" is left displaced by 8 characters from the preceding block of PLUMED_OBJECTS.
Perhaps I should also add that when patching with line "RECON_LIBS=" left blank, the patching command triggers a large number of dependencies, the same that are later seen on command "make depends".
When the libraries are linked, patching ends at "missing separator", no depencies are made and "make depends' does not work.
I am most definitely NOT a skilled bash programmer. So you still might need help from such a programmer.
But it seems obvious where the extra newline is getting injected into the constructed file. I marked in red the command that I think should not be there.
Code:
{
echo -n "PLUMED_OBJECTS="
for file in $plumedir/common_files/*.c
do f=${file##*/}
echo " \\"
echo -n " \$(DSTDIR)/${f%.c}.o"
done
echo
if [ "$RECON_LIBS" != "" ] ; then
for file in $plumedir/recon_src/*.cpp
do f=${file##*/}
echo " \\"
echo -n " \$(DSTDIR)/${f%.cpp}.o"
done
echo " "
echo "RECON_FLAGS=\$(COPTD)RECONMETAD"
else
echo " "
echo "RECON_FLAGS="
fi
echo "RECON_LIBS="$RECON_LIBS
} > $WHERE_LINKS/plumed.inc
cd $myarch ; ln -s $WHERE_LINKS/plumed.inc .; make depends ; cd ../
}
Quote:
Originally Posted by chiendarret
(line 39 is the mere "/" after line "$(DSTDIR)/testderivatives.o")
...
What is wrong about line 39? Or what else?
What is wrong is that the \ alone on line 39 was supposed to be at the end of line 38.
I don't know what harm is done by having a \ alone on line 39. Most likely no harm. But not having a \ on the end of line 38 totally messes up the parsing of the file, so the next thing that gets read (line 39) will be misunderstood.
That clarifies the issue. Thanks indeed.
However, how to get "\" at the end of line 38? Generation of plumed.inc is from the patching script, a portion of which (dealing with plumed.inc) I posted initially. Below the full patching script, which is simply run with
./patchingscript.sh -patch
It would be great if you suggest a correction.
chiendarret
#!/bin/bash
# PATCH SCRIPT FOR NAMD 2.7
#
# USER DEFINED ARCHITECTURE:
myarch="Linux-x86_64-g++"
# this script needs to be launched from the root directory of the host code
destination="$PWD"
# definitions specific to this code
CODE="namd2.9"
LINKED_FILES="$plumedir/common_files/*.h $plumedir/common_files/*.c"
RECON_LINKS="$plumedir/recon_src/*.cpp $plumedir/recon_src/*.h"
WHERE_LINKS="./src/"
# Leave this line here blank for normal patching of plumed
RECON_LIBS=
# CVS version only : for reconnaissance metadynamics enter here information on the
# locations of the lapack and lstdc++ libraries.
RECON_LIBS="/usr/lib/lapack/liblapack.so.3gf.0 /usr/lib/x86_64-linux-gnu/libstdc++.so.6"
# this changes the names from .c to .C
PLUMED_RENAME_RULE=plumed_rename_rule
function plumed_rename_rule (){
case "$1" in
(*.c) echo "${1%.c}.C" ;;
(*) echo "$1" ;;
esac
}
# this changes the names from .cpp to .C
RECON_RENAME_RULE=recon_rename_rule
function recon_rename_rule (){
case "$1" in
(*.cpp) echo "${1%.cpp}.C" ;;
(*) echo "$1" ;;
esac
}
function to_do_before_patch () {
echo > /dev/null
}
function to_do_after_patch () {
{
echo -n "PLUMED_OBJECTS="
for file in $plumedir/common_files/*.c
do f=${file##*/}
echo " \\"
echo -n " \$(DSTDIR)/${f%.c}.o"
done
echo
if [ "$RECON_LIBS" != "" ] ; then
for file in $plumedir/recon_src/*.cpp
do f=${file##*/}
echo " \\"
echo -n " \$(DSTDIR)/${f%.cpp}.o"
done
echo " "
echo "RECON_FLAGS=\$(COPTD)RECONMETAD"
else
echo " "
echo "RECON_FLAGS="
fi
echo "RECON_LIBS="$RECON_LIBS
} > $WHERE_LINKS/plumed.inc
cd $myarch ; ln -s $WHERE_LINKS/plumed.inc .; make depends ; cd ../
}
function to_do_before_revert () {
rm $myarch/plumed.inc; rm $WHERE_LINKS/plumed.inc
}
function to_do_after_revert () {
cd $myarch ; make depends ; cd ../
}
There is an echo command in the script which I think should be removed. I identified that in red in my previous post. (I hope your browser is showing you colors).
That echo command is responsible for the line break between lines 38 and 39 of plumed.inc. If you remove that echo command, then those two lines of plumed.inc will be merged together (which I think is what you need).
Quote:
It would be great if you suggest a correction.
Remove line 52 of the full script you quoted, that is the echo right before: if [ "$RECON_LIBS" != "" ] ; then
Hello:
I corrected plumed.inc according to your suggestion: moved "\" from line 39 to the end of line 38 and no blank line with the following. "make depends" issued the dependencies and "make" compiled the main program.
Still to check if everything is in order (which will also depends on the link to the libraries) but the main program executables were generated. I'll check in a few days, now busy.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.