bkaradzic / bgfx

Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.
https://bkaradzic.github.io/bgfx/overview.html
BSD 2-Clause "Simplified" License
15.03k stars 1.95k forks source link

Build problem on OSX 10.10.5 with SDK 10.11 #663

Closed sesores closed 8 years ago

sesores commented 8 years ago

Hello Everyone!

I have the same problem like here (https://github.com/bkaradzic/bgfx/issues/564), the issue is closed right now. I'm trying to build bgfx (latest master) on OSX 10.10.5, with:

make osx

And it fails with:

==== Building example-00-helloworld (debug32) ====
Creating ../../osx32_clang/obj/x32/Debug/example-00-helloworld
Creating ../../osx32_clang/obj/x32/Debug/example-00-helloworld/examples/00-helloworld
helloworld.cpp
Creating ../../osx32_clang/bin/example-00-helloworld.app/Contents/MacOS
Linking example-00-helloworld
ld: framework not found Metal
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [../../osx32_clang/bin/example-00-helloworld.app/Contents/MacOS/example-00-helloworldDebug] Error 1
make[1]: *** [example-00-helloworld] Error 2
make: *** [osx-debug32] Error 2

It's the same with osx-debug32, osx-debug64, osx-release32, osx-release64. Do you have any idea, what's going wrong? I think this lib could be the perfect choice for my needs.

Thank you! Timo

Ps.: Of course delete this Issue if you'll reopen the one I've just linked above.

sesores commented 8 years ago

Another step. As I see, the lib itself was built, but it fails compiling the demos (and maybe the release lib?)

If I run:

make clean
make

it creates all the project files for all targets, and libbgfxDebug.a. If I open eg. example-01-cubes.xcodeproj, set the working directory properly, and hit run, it compiles, but right after start it fails with:

dyld: Symbol not found: _OBJC_CLASS_$_CAMetalLayer
  Referenced from: /......../bgfx/.build/osx_universal/bin/example-01-cubesDebug.app/Contents/MacOS/example-01-cubesDebug
  Expected in: /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
 in /......../bgfx/.build/osx_universal/bin/example-01-cubesDebug.app/Contents/MacOS/example-01-cubesDebug
bkaradzic commented 8 years ago

Supporting multiple versions of OSX is PITA. You'll need to upgrade to newer version of OSX/XCode, or manually disable Metal.

Latest builds with newer version of XCode, see here version info: https://travis-ci.org/bkaradzic/bgfx/jobs/104024853

sesores commented 8 years ago

Happy news!

I've manually disabled Metal in config.h. I've changed Metal specific return value from:

||  BX_PLATFORM_IOS \
|| (BX_PLATFORM_OSX >= 101100) \
? 1 : 0)

to (to ensure it returns 0):

||  BX_PLATFORM_IOS \
|| (BX_PLATFORM_OSX >= 101100) \
? 0 : 0)

Now I can compile and run the demos! It's an awesome lib, thank you for this amazing stuff!

(Now my next task, to get it work with an already existing GL context... :D)

bkaradzic commented 8 years ago

Cool.

(Now my next task, to get it work with an already existing GL context... :D)

https://bkaradzic.github.io/bgfx/bgfx.html#_CPPv2N4bgfx15setPlatformDataERK12PlatformData

sesores commented 8 years ago

Thanks for the tip, and the quick answers!

I've got these errors with my test JUCE (http://juce.com) project.

ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks//QuickTime.framework/QuickTime.tbd, missing required architecture x86_64 in file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks//QuickTime.framework/QuickTime.tbd
Undefined symbols for architecture x86_64:
  "bgfx::setPlatformData(bgfx::PlatformData const&)", referenced from:
      MyJuceBaseGLComponent::newOpenGLContextCreated() in Canvas.o
  "bgfx::setDebug(unsigned int)", referenced from:
      MyJuceBaseGLComponent::newOpenGLContextCreated() in Canvas.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

with the code:

void MyJuceBaseGLComponent::newOpenGLContextCreated ()
{
    jassert(OpenGLHelpers::isContextActive());

    bgfx::setDebug(BGFX_DEBUG_TEXT);

    bgfx::PlatformData pd;

    pd.ndt          = NULL;
    pd.nwh          = getPeer()->getNativeHandle();
    pd.context      = context.getRawContext();
    pd.backBuffer   = NULL;
    pd.backBufferDS = NULL;

    bgfx::setPlatformData(pd);
}

I've linked all the necessary frameworks, I've added all the header paths, I've doublechecked the Xcode Build Settings on both projects (my test, and the working demo), I have access to the HWND and CONTEXT void ptrs, what went wrong?

I know it's a completely new era with another lib, but I've used the existing context with GLUT before, and more or less with other engines, but as you mentioned your system is ready to deal with them.

bkaradzic commented 8 years ago

You didn't link bgfx.

Also that bgfx::setDebug cannot be called until you call bgfx::init.

bkaradzic commented 8 years ago

Also bgfx::setPlatformData must be called prior calling bgfx::init.

sesores commented 8 years ago

Thanks! Now I finally can build and run the 00-helloworld sample in my own JUCE test app. BGFX gets the context, and it draws perfectly inside it. NICE!

But of course here is the next issue. :D When I resize the window, it resizes the GL component. Without BGFX the only thing I had to do is to call the following in the next render cycle:

glViewport(0, 0, getWidth(), getHeight());

With BGFX it fails in the next cycle here:

bgfx::setViewRect(0, 0, 0, getWidth(), getHeight());

To be more precise in:

bx::debugBreak()

Should I call something before setViewRect() with the new dimensions?

Beside this, my next goal is to get work the 01-cubes demo. I've got the following linker error:

Undefined symbols for architecture x86_64:
  "__main_", referenced from:
      entry::main(int, char**) in example-commonDebug.a(entry.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

(I've linked both bgfxDebug.a and example-commonDebug.a.)

And again, thank you very much for the quick answers, and sorry for the noob questions! :)

bkaradzic commented 8 years ago

You should not mix entry with JUCE.

In order to resize bgfx's backbuffer you need to call bgfx::reset.