Hello world code crashed at open_window - Mac OS Mojave

I downloaded the official precompiled Panda3D SDK for mac os and built a C++ hello world program following this tutorial using CLion. The compilation was smooth but code always crashed at framework.open_window() and returned code 11. More specifically was at make_default_pipe.

Here is my code:

#include <iostream>
#include "pandaFramework.h"
#include "pandaSystem.h"
using namespace std;
int main(int argc, char *argv[]) {
	PandaFramework framework;
	framework.open_framework(argc, argv);
	framework.set_window_title("My Panda3D Window");
	cout << "mark1" << endl;
	WindowFramework *window = framework.open_window();
	cout << "mark2" << endl;
	if (window != nullptr) {
		cout << "Opened the window successfully!\n";
	} else {
		cout << "Could not load the window!\n";
	return 0;

Running result is

Known pipe types:
(all display modules loaded.)

Process finished with exit code 11


cmake_minimum_required(VERSION 3.14)
set(PANDA3D_LIB -lp3framework -lpanda -lpandaexpress -lp3dtoolconfig -lp3dtool -lp3pystub -lp3direct)
add_executable(Panda3D main.cpp)
target_link_libraries(Panda3D ${PANDA3D_LIB})

And here’s my project structure:


I copied the folders include lib Frameworks and etc from the precompiled SDK to my Demo folder without any modification.
I tried to compile Panda3D source code on my Mac but always failed at:

[T1] Linking dynamic library built/panda3d/ai.so

[T1] Building C object built/tmp/cpython-27m/deploy-stubw.o

[T1] Linking executable built/bin/deploy-stubw

7 warnings generated.

[T1] Waiting for tasks...

[T3] Waiting for tasks...

[T4] Waiting for tasks...

7 warnings generated.

[T1] Linking dynamic library built/panda3d/_rplight.so

[ 0%] Compressing built/models/misc/Dirlight.egg.pz

dyld: Symbol not found: __ZNSsD1Ev

Referenced from: /Users/hezhenbang/Downloads/panda3d/built/bin/../lib/libpanda.1.10.dylib

Expected in: flat namespace

in /Users/hezhenbang/Downloads/panda3d/built/bin/../lib/libpanda.1.10.dylib

Storing dependency cache.

Elapsed Time: 22 min 32 sec

The following command returned a non-zero value: built/bin/pzip built/models/misc/Dirlight.egg

Build terminated.

Anyone can help?

Both problems are probably because you are mixing two c++ libraries, libc++ and libstdc++. The official Panda SDK is compiled against MacOS SDK 10.6 and is using libstdc++ (7.9.0). If you compile a module or link with panda with code compiled against libc++ your program will crash almost immediately as one of the two libraries will not be initialised properly. SO you have to recompile your program using

--std=gnu++11  -mmacosx-version-min=10.6

And have a 10.6 SDK installed.

If you recompile Panda on your machine, you also need to recompile the third-party packages with the same SDK and c++ library, otherwise you just move the problem somewhere else (__ZNSsD1Ev is a string constructor and usually libc++ incompatibilities are popping up in string related code)

1 Like

Hi eldee! Thanks for your reply.
Since Apple removed libstdc++ support from Xcode 10, there is no way to use precompiled Panda3D SDK on my mac. So I just tried to recompile the third-party packages on my mac which was downloaded from rdb’s panda3d-thirdparty.
But I got tons of errors compiling the third-party packages. So I decide to use Panda3D on my Windows machine.
Thank you anyway!

Sorry for the trouble on this; we hope to be soon publishing new macOS builds that are built with libc++ and a newer macOS SDK.

You can install an older SDK by downloading an older Xcode, open the dmg file, extract the SDK and copy it into your local copy of Xcode. This work starting with SDK 10.7 (Xcode 4.3.6) installing SDK 10.6 is trickier but feasible.

Except for bullet, the third-party package should compile fine, I tested on SDK 10.6, 10.7, 10.14 and 10.15. However I’m a heavy user of Homebrew so there might be some missing dependencies.

Wow, that’s great! Thanks! :smile:

Thanks. got it. I will have a try sometime.:smiley: