You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Developer Forums relocated!

Need help with Apple Developer tools and technologies? Want to share information with other developers and Apple engineers? Visit Developer Forums at Apple.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Error while running a c++ program on terminal.

How to solve the following issue:

I am running a c++ program on terminal. I got an error

"can't open output file for writing '/vector.ld_JehG5c', errno=30 for architecture x86_64


clang: error: linker command failed with exit code 1 (use -v to see invocation)"

I run the same code on online compliers it works(run successfully).

please help me

Posted on Mar 17, 2020 5:24 AM

Reply
11 replies

Mar 17, 2020 7:29 AM in response to adarsh1130

Is this just a standard C++ application, or does it involve Cocoa libraries, or C++nn/C++2a standard code? There are extensive clang++ compiler switches available, including some that may be beneficial for a vector application:


[xcrun] clang++ --help



This will automatically use the standard c++ library libc++, but does not account for helping it find custom header, or library locations, or any other C++ code dependencies:

clang++ -Oz -o vector ./vector.cpp


What C++ libraries are available? Deliberately issue a bogus library name:

[xcrun] clang++ -Oz -o vector ./vector.app -std=cxx17

note: use 'c++11' for 'ISO C++ 2011 with amendments' standard
note: use 'gnu++11' for 'ISO C++ 2011 with amendments and GNU extensions' standard
note: use 'c++14' for 'ISO C++ 2014 with amendments' standard
note: use 'gnu++14' for 'ISO C++ 2014 with amendments and GNU extensions' standard
note: use 'c++17' for 'ISO C++ 2017 with amendments' standard
note: use 'gnu++17' for 'ISO C++ 2017 with amendments and GNU extensions' standard
note: use 'c++2a' for 'Working draft for ISO C++ 2020' standard
note: use 'gnu++2a' for 'Working draft for ISO C++ 2020 with GNU extensions' standard


If you are using the command-line tools, you can ignore the [xcrun] as that is used when only Xcode is installed.

Mar 17, 2020 7:32 AM in response to VikingOSX

this is a standard c++ application


my code is given below



#include<iostream>

using namespace std;

int main()

{

int i,j,k,t,n,max,min,max_in,min_in,ans,tag1,tag2,tag;


cin>>t;

for(k=0;k<t;k++)

{

cin>>n;

int arr[n];

for(j=0;j<n;j++)cin>>arr[j];


min=arr[0];max_in=0;min_in=0;

max=arr[0];

ans=0;

for(i=1;i<n;i++)

{

if(arr[i]-i>max-max_in)

{

max=arr[i];

max_in=i;

tag=arr[i]-min+i-min_in;

if(tag>ans)ans=tag;


}

if(arr[i]+i<min+min_in)

{

min=arr[i];

min_in=i;

tag=max-arr[i]+i-max_in;

if(tag>ans)ans=tag;


}

else

{

tag1=max-arr[i]+i-max_in;

tag2=arr[i]-min+i-min_in;

if(tag1>tag2)

{if(tag1>ans)ans=tag1;}

else if(tag2>ans)ans=tag2;


}


}

cout<<ans<<endl;

}


return 0;




}



Error while running a c++ program on terminal.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.