BlendInt icon indicating copy to clipboard operation
BlendInt copied to clipboard

error when compiling the sample code

Open xzwang2005 opened this issue 9 years ago • 15 comments

hi,

Would you please outline the steps to build the sample code in XCode? I managed to compile the library, but failed to do so with the "hello world" example. Thanks!

update: here's some more info about the error: c++locale.h: no member named 'vsnprintf' in namespace std:: other errors are similar to this one. I tried other c++ dialect in xcode settings, but still get the errors

xzwang2005 avatar Apr 06 '15 16:04 xzwang2005

I'll check this issue on my Mac tonight.

zhanggyb avatar Apr 07 '15 03:04 zhanggyb

I cannot reproduce this kind of error. What's the OS X and Xcode versions are you using?

zhanggyb avatar Apr 07 '15 14:04 zhanggyb

I'm using OSX 10.10.1, Xcode 6.2. The errors are not related to BlenderInt codebase, but come from compiling c++ standard library and boost. It seems there are a mismatch of compiler/c++ library. I tried different c/c++ dialect without luck. Here's what I did so far:

  1. download the BlenderInt source code and generate xcode project with cmake gui
  2. compile the source code, succeeded
  3. create a new project (console program) in Xcode, copy the "Hello World" example and set the search path for the headers and compiled library from 2)

I checked the settings for the source project, both c/c++ dialect are set to "compiler default" with c++11 std library. I got errors with the same settings. I'm not sure why the example end up compiling the std library either.

xzwang2005 avatar Apr 08 '15 03:04 xzwang2005

Aha, I see. I'll try and provide a simple guide of how to write your program in Xcode in wiki. But won't be soon, maybe this weekend.

You could also use cmake to generate Xcode project, I have some demo code in https://github.com/zhanggyb/BlendInt_Demos. See https://github.com/zhanggyb/BlendInt/wiki/build to know how to checkout the submodule and build the demo.

zhanggyb avatar Apr 08 '15 03:04 zhanggyb

I tried to create a Xcode project today and found it's really difficult to configure the xcode project and I failed too.

That's because you have to set the headers/libraries/definitions required by this project manually in xcode. For example, the header files of freetype, platform macro required by CppEvent.

This problem not only occurs in Xcode, but also in other IDEs. I need more time to clean up the code and solve this issue.

Currently, if you just want to have a look at a real example, please checkout "demo" submodule and build with cmake.

zhanggyb avatar Apr 12 '15 12:04 zhanggyb

the glfw3 demo (including 'tutorial01') can be build thru command line successfully. But it failed to compile with xcode project(generated with cmake gui, with default settings plus build glfw demo option), due to an old glfw3 version (3.0.4) installed by brew. Because the source code bundled with BlenderInt is glfw 3.1, which does not match the header. Uninstall previous glfw fixes the problem.

still, a tutorial on writing a program with your library from scratch is very much needed. Thanks.

xzwang2005 avatar Apr 12 '15 12:04 xzwang2005

ok. since create a xcode project is too much work, maybe it's easier to outline steps to add new targets within BlendInt project?

xzwang2005 avatar Apr 12 '15 13:04 xzwang2005

Yes, it's already in plan and I'll do this as soon as I finish another c++ project -- libCppEvent to replace the CppEvent which is used in current code.

libCppEvent is more clean and comprehensible due to the C++11 features.

zhanggyb avatar Apr 12 '15 14:04 zhanggyb

thanks for the update, and keep up the good work!

xzwang2005 avatar Apr 14 '15 22:04 xzwang2005

I've fixed some code bugs in recent commits. you can build the latest code, install to /usr/local (by default), and now you can configure Xcode to use this project. (Don't be supprised if you get other bug, it's still under development).

A step-by-step guide will be posted on wiki page soon.

zhanggyb avatar Apr 30 '15 03:04 zhanggyb

See this page: https://github.com/zhanggyb/BlendInt/wiki/compile

zhanggyb avatar May 03 '15 15:05 zhanggyb

hi,

I noticed that the external packages (glfw3, glm) are removed from the source. This requires that glfw3 being installed before BlendInt can be compiled. However, if use Homebrew, the installed glfw version is 3.0.4, which is not compatible with BlendInt. To make things worse, once it's installed thru Homebrew, XCode will use the installed header first, even if the glfw 3.1 path were set correctly thru cmake.

So I guess it might be helpful to clarify that for mac, user should:

  1. make sure glfw3 is not installed thru Homebrew
  2. build latest glfw, version 3.1 at least, also note that it should be built as a dynamic library
  3. specify header folder and the path to glfw.dylib in cmake
  4. compile with cmake or generate Xcode and compile

xzwang2005 avatar May 18 '15 00:05 xzwang2005

GLFW in Homebrew has already been upgraded to 3.1.x, the latest is 3.1.1. Could you update/upgrade homebrew and try to build BlendInt again:

$ brew update
$ brew upgrade --all

zhanggyb avatar May 18 '15 01:05 zhanggyb

you are right, it's fixed now. Thanks.

xzwang2005 avatar May 23 '15 13:05 xzwang2005

So I'm going to close this issue. By the way, if you're using a Mac with retina display, the current code is not working. I'm fixing this in the "retina" branch.

zhanggyb avatar May 24 '15 15:05 zhanggyb