Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

nuhriko

macrumors newbie
Original poster
Sep 7, 2015
8
1
Japan
So I have a C code that I am trying to translate from windows into mac. I am trying to call LTspice application using the sample syntax below.

For windows, it is originally:
char *strPath ="\"C:/Program Files/LTC/LTspiceIV/scad3.exe\" -b 111219_10.net ";

Changed it to this for Mac:
char *strPath ="\"/Applications/LTspice.app\" -b 111219_10.net ";

And then I get this error:
sh: /Applications/LTspice.app: is a directory

I've been googling everywhere and I couldn't find an appropriate solution for this one. Can somebody help me fix this? Thanks in advance!

Kind regards,
Bern
 
Don't have a system handy to test but try

char *strPath ="open \"/Applications/LTspice.app\" -b 111219_10.net ";

Thanks for your response. I tried as you say but I'm not really sure if the initial problem has been solved because I then get the error below:

LSGetApplicationForInfo() failed with error -10814 while trying to determine the application with bundle identifier {filename}.net.

When I searched, what I understood is that this happens when Mac OSX doesn't know the default program to open this kind of file. However, I already set LTspice as default program for all .net files but this error still occur. Is this relevant or should I post a new thread about this?

Thank you very much for your help.

Kind regards,
Bern
 
What function are you using to execute the program?

system?
popen?

Can you include a little more of your source code to indicate that bit.
 
What function are you using to execute the program?

system?
popen?

Can you include a little more of your source code to indicate that bit.

Hmm, I hope this is more complete. System function is executed for this.

else if( (*x) ==1 ){
char *strPath ="open \"/Applications/LTspice.app\" -b 111219_10.net ";
system( strPath);}

Thanks a lot.
 
And then I get this error:
sh: /Applications/LTspice.app: is a directory

It's because LTspice.app is a directory, these are known as app bundles. The executable file is inside the bundle. Normally this would be found in /Applications/LTspice.app/Contents/MacOS/
 
  • Like
Reactions: nuhriko
It's because LTspice.app is a directory, these are known as app bundles. The executable file is inside the bundle. Normally this would be found in /Applications/LTspice.app/Contents/MacOS/

Do you mean that I should modify the segment as:
Code:
else if( (*x) ==1 ){
char *strPath ="open \"/Applications/LTspice.app/Contents/MacOS\" -b 111219_10.net ";
system( strPath);}

I did this, however, the error this time says that:
The file /Applications/LTspice.app/Contents/MacOS does not exist.

It is possibly linked on how LTspice was installed. From a virtual drive, I just copied the application file to my mac's application folder, pasted it there. Opening LTspice alone is alright, but for some reason the C program codes cannot open it.

Another thing. I also tried changing "-b" to "-a", like
Code:
else if( (*x) ==1 ){
char *strPath ="open \"/Applications/LTspice.app\" -a 111219_10.net ";
system( strPath);}

However, I also get the error:
sh: /Applications/LTspice.app: is a directory.
 
Last edited by a moderator:
Do you mean that I should modify the segment as:

else if( (*x) ==1 ){
char *strPath ="open \"/Applications/LTspice.app/Contents/MacOS\" -b 111219_10.net ";
system( strPath);}

I did this, however, the error this time says that:
The file /Applications/LTspice.app/Contents/MacOS does not exist.

You have to locate the executable file inside the .app bundle, in your Windows example it was called scad3 no? I have no idea what the significanse of the -a or -b is, these are options to the executable file and has nothing to do with where it is located.
 
Last edited:
  • Like
Reactions: nuhriko
You have to locate the executable file inside the .app bundle, in your Windows example it was called scad3 no? I have no idea what the significanse of the -a or -b is, these are options to the executable file and has nothing to do with where it is located.

You are correct, for Windows it is scad3.exe.

Thank you so much for your clarification. Problem solved! :)
 
I would like you to try

char *strPath ="open -a \"/Applications/LTspice.app\" -b 111219_10.net ";

Instead of your current solution as I believe it will more properly set up the application runtime for the Mac GUI needs.

If it doesn't work go back your current solution.
 
I would like you to try

char *strPath ="open -a \"/Applications/LTspice.app\" -b 111219_10.net ";

Instead of your current solution as I believe it will more properly set up the application runtime for the Mac GUI needs.

If it doesn't work go back your current solution.

Open is redundant in this case since the link points to the executable file, system() hands over the execution to the shell and in this case there are arguments involved. Secondly, we don't know if scad3 is a GUI application. So this should do:

Code:
system("/Applications/LTspice.app/Contents/MacOS/scad3 -b 111219_10.net");
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.