0

I am trying to write a DYLIB, (in Code::Blocks), which is to be called from a Mac application, that simply calls the standard C system() function, while giving the option of whether to wait for finishing, in the second argument, (1 or 0).

I put my sample code on pastebin, instead of embedding it here, because for whatever reason, the post editor is not letting me place the entire code snippet inside the code box, like it's supposed to, which is a little annoying.

http://pastebin.com/0ZfbD3Dx

Now when calling the DYLIB, (I can't remember the compiler I used, either GCC or LLVM), I use this code within GameMaker Studio:

ExecuteShell('open /Applications/Calculator.app',0);

However, calculator does not run. Trying to change the second argument to 1, and I get the same result. Calculator does not run. No errors. It seems to be ignoring my code all together, so I was wondering if there was something wrong with how I wrote my DYLIB.

I look at this question someone else had:

https://stackoverflow.com/questions/859517/osx-equivalent-of-shellexecute#=

string command = "open " + filePath;
system(command.c_str());

I see they used .c_str(). Should I be using .c_str()? Is that the problem? The code I use right now is system(fname);. Should I change that to system(fname.c_str());? Is it OK that I'm using the type char * for the argument fname? Or because I'm using that type, do I have to cast/convert it to the type string?

I'm using someone else's Mac to port this small project of mine to work on Mac, anyway I'm trying to get help on here, before trying to build it again, because I'm trying to minimize how much I'm asking to use my friend's Mac computer. The hope is, the next build I do, with very little tweak, will finally work and run calculator.

Thanks in advance!

Community
  • 1
  • 1
  • "calls the standard C system() function, while giving the option of whether to wait for finishing, in the second argument, (1 or 0)." - not possible; system() always waits for the executed command to finish. –  Mar 11 '17 at 22:01
  • @NeilButterworth Whether I use the code in the pastebin link, or a fork(), on Linux, the code doesn't wait for finishing. It runs alongside the game code. Is this different on Mac? –  Mar 11 '17 at 22:19

0 Answers0