Mendes
Mendes

Reputation: 18441

Eclipse CDT Post-Build commands error

I have a C++ project and I´m using Eclipse CDT 3.8.1 as the IDE tool, with a workspace of 5 different projects...

One of my projects is a shared library, and at the end of compilation I want to copy its code to a test/bin directory for testing.

I´ve gone to Project Properties -> C/C++ Build -> Settings -> Build Steps and at "Post-build steps", "Command", I´ve added:

cp *.so ../../../bin

(OBS: ../../../bin is the correct path from the Debug folder - I´ve checked already).

What happens is that I get the following error on post build:

cp *.so ../../../bin 
cp: cannot stat ‘*.so’: No such file or directory

I said: ok, this may be a permission problem, so I changed the post commands to:

whoami;ls -al; ls *.so;

And I got on Eclipse console:

    whoami 
    aeidev
    ls -al 
    total 264
    drwxrwxr-x 3 aeidev aeidev   4096 Apr 25 15:55 .
    drwxrwxr-x 5 aeidev aeidev   4096 Apr 22 16:27 ..
    -rwxrwxr-x 1 aeidev aeidev 242556 Apr 25 15:55 libaeirtuaccess.so
    -rw-rw-r-- 1 aeidev aeidev   1763 Apr 23 20:47 makefile
    -rw-rw-r-- 1 aeidev aeidev    245 Apr 23 20:46 objects.mk
    -rw-rw-r-- 1 aeidev aeidev    526 Apr 23 20:47 sources.mk
    drwxrwxr-x 2 aeidev aeidev   4096 Apr 25 15:41 src
     ls *.so 

15:55:11 Build Finished (took 1s.80ms)

And them I changed again to ls *.so and I got:

ls -al *.so 
ls: cannot access *.so: No such file or directory

15:57:50 Build Finished (took 715ms)

It´s a very strange behaviour. In the same workspace I have a different shared library and the original cp *.so works fine...

Any ideas of what´s going on here ? Is it a known Eclipse bug ?

Thanks for helping...

Upvotes: 0

Views: 1011

Answers (1)

AndiDog
AndiDog

Reputation: 70108

I believe the commands are not executed in a shell by default, so wildcards are not evaluated. Try executing like /bin/sh -c 'cp *.so ../../../bin/'. Also you should use Eclipse's built-in variables to copy to the desired path.

Upvotes: 1

Related Questions