First, the real mistake is very simple, but you might not know; you pass 'n' for the first argument, but you really need to pass 'n' (despite what is written in the header). With this fix, your code works.
Now, having said that you are doing a couple of more subtle things โwrongโ (ish).
First, do not use vecLib. It has been replaced by Accelerate.framework (at 10.4!). vecLib.framework is only supported for older versions. Any new development should refer to Accelerate.
Secondly, do not use the v * functions defined in vectorOps.h . They have also been replaced by the standard BLAS functions defined in cblas.h . Because they are standard, there are many public documents on how to use them, and they are also supported by much faster implementations; vectorOps functions are only supported for legacy support. cblas.h also supports many more operations and data types. If this was not enough, if you decide to port your code to iOS, you will find that the vectorOps functions are not available at all. Use the cblas.h functions.
Re-write your example:
#include <Accelerate/Accelerate.h>
and its launch gives:
scanon$ gcc test.c -framework Accelerate -o test scanon$ ./test 1.0000 2.0000 3.0000 12.0000 5.0000 5.0000 7.0000 8.0000
source share