Say under directory /usr/local/boost_1_52_0/stage/lib, I have a symbolic link: libboost_timer.so, which points to the regular file libboost_timer.so.1.52.0 in the same directory.

How can I cp the symbolic links to directory /usr/local/lib while pointing to the same file /usr/local/boost_1_52_0/stage/lib/libboost_timer.so.1.52.0.

I have searched and tried several options. First one copies the regular file to the destination directory using the name of the link. Second one just copies the link itself, but the link is not valid in the new directory. Third one makes new link points to the original link, so it would de-reference twice to get the regular file. And I want to use the link file name, so directly making the links of the regular file would not work.

How can I do this?


It seems the symbolic link links to file with relative directory. I would recommend to create a symbolic link with ln -s /usr/local/boost_1_52_0/stage/lib/libboost_timer.so /usr/local/lib/ instead of copying it.

| improve this answer | |
  • As mentioned in the op, apparently it would de-reference twice to get the file. – WiSaGaN Jan 17 '13 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.