enzo1982 / BoCA

A component library used by the fre:ac audio converter
https://www.freac.org/
GNU General Public License v2.0
36 stars 9 forks source link

Startup Crash on macOS #10

Closed jiemojiemo closed 3 years ago

jiemojiemo commented 3 years ago

macOS version: 10.15.7 branch: master

image

enzo1982 commented 3 years ago

Not 100% sure what's causing this without seeing your application code, but I guess that you need to include smooth/main.h in your program and use smooth::Main instead of the regular main function. smooth::Main will make sure that smooth::Init gets called which will initialize some objects, such as the mutex used by smooth::Threads::Access.

So instead of this:

int main(int argc, char **argv) {
  return 0;
}

Do this:

#include <smooth.h>
#include <smooth/main.h>
#include <smooth/args.h>

using namespace smooth;

Int smooth::Main(const Array<String> &args) {
  return 0;
}

And if you're using BoCA:

#include <smooth.h>
#include <smooth/main.h>
#include <smooth/args.h>

#include <boca.h>

using namespace smooth;

Int smooth::Main(const Array<String> &args) {
  BoCA::Init("Your application name");

  ...

  BoCA::Free();

  return 0;
}

Feel free to ask questions here if you're getting stuck. But it would be great if you could refer to the fre:ac source code first and try to figure out a solution on your own. If that fails, though, I'll be glad if I can help.

jiemojiemo commented 3 years ago

Thanks, it works!