hxsdl icon indicating copy to clipboard operation
hxsdl copied to clipboard

working with cpp on mac?

Open lewislepton opened this issue 8 years ago • 19 comments

im having troubles getting this working with heaps on mac.

building to html works fine. but once it comes to cpp it does spit out trouble.

i have the setup of putting glext.h inside the SDL2 [sdk download] include folder. but am getting nothing. still more errors

Error: In file included from ./src/sdl/Sdl.cpp:10:
In file included from include/sdl/Sdl.h:10:
/usr/local/lib/haxelib/hxsdl/git/SDLSupport.h:11:10: fatal error: 'GL/GLU.h' file not found
#include <GL/GLU.h>

lewislepton avatar Jan 03 '16 00:01 lewislepton

just help with hopefully some screenshots would be great ;)

lewislepton avatar Jan 03 '16 00:01 lewislepton

I don't have an OSX to test on here, but I've commit a fix, tell me how it works

ncannasse avatar Jan 03 '16 11:01 ncannasse

My bad, try again

ncannasse avatar Jan 03 '16 13:01 ncannasse

hmmmm. this is the output

Error: ./src/sdl/Sdl.cpp:62:2: error: use of undeclared identifier 'timeBeginPeriod'
        timeBeginPeriod(1);
        ^
./src/sdl/Sdl.cpp:213:2: error: use of undeclared identifier 'timeEndPeriod'
        timeEndPeriod(1);
        ^
2 errors generated.
Error: ./src/sdl/GL.cpp:63:14: error: use of undeclared identifier 'GLLoadAPI'
        bool tmp = (GLLoadAPI() == (int)0);             HX_STACK_VAR(tmp,"tmp");
                    ^
./src/sdl/GL.cpp:852:64: warning: cast to 'void *' from smaller integer type 'int' [-Wint-to-void-pointer-cast]
                glVertexAttribPointer(index, size, type, normalized, stride, VOIDPTR(position));
                                                                             ^
/usr/local/lib/haxelib/hxsdl/git/SDLSupport.h:28:21: note: expanded from macro 'VOIDPTR'
#define VOIDPTR(v)      ((void*)(v))
                         ^
./src/sdl/GL.cpp:919:37: warning: cast to 'void *' from smaller integer type 'int' [-Wint-to-void-pointer-cast]
                glDrawElements(mode, count, type, VOIDPTR(start));
                                                  ^
/usr/local/lib/haxelib/hxsdl/git/SDLSupport.h:28:21: note: expanded from macro 'VOIDPTR'
#define VOIDPTR(v)      ((void*)(v))
                         ^
2 warnings and 1 error generated.
Error: Build failed

also this is what my hxsdl looks like. just to make it easier ;) screen shot 2016-01-03 at 13 27 51

also where the glext is, which is inside the SDL2 folder screen shot 2016-01-03 at 13 28 05

lewislepton avatar Jan 03 '16 13:01 lewislepton

One more try? :)

ncannasse avatar Jan 03 '16 13:01 ncannasse

ha. it built quite a bit more this time. but then came up with some other errors

here is the last portion which has the errors

lib/x86/SDL2.lib opengl32.lib winmm.lib
clang: error: no such file or directory: '/usr/local/lib/haxelib/hxsdl/git/SDL2/lib/x86/SDL2.lib'
clang: error: no such file or directory: 'opengl32.lib'
clang: error: no such file or directory: 'winmm.lib'
Error: error running g++ -o Main -stdlib=libstdc++ -framework Cocoa -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -m64 @/Users/lepton/Developer/Heaps/GAMES/MIORA/bin/obj/darwin64/all_objs /usr/local/lib/haxelib/hxsdl/git/SDL2/lib/x86/SDL2.lib opengl32.lib winmm.lib
Error: Build failed
[Finished in 76.1s with exit code 1]

this is the first part which has some warnings

-o/Users/lepton/Developer/Heaps/GAMES/MIORA/bin/obj/darwin64/5a0e3030_NativeWrapper.o
./src/sdl/GL.cpp:856:64: warning: cast to 'void *' from smaller integer type 'int' [-Wint-to-void-pointer-cast]
                glVertexAttribPointer(index, size, type, normalized, stride, VOIDPTR(position));
                                                                             ^
/usr/local/lib/haxelib/hxsdl/git/SDLSupport.h:30:21: note: expanded from macro 'VOIDPTR'
#define VOIDPTR(v)      ((void*)(v))
                         ^
./src/sdl/GL.cpp:923:37: warning: cast to 'void *' from smaller integer type 'int' [-Wint-to-void-pointer-cast]
                glDrawElements(mode, count, type, VOIDPTR(start));
                                                  ^
/usr/local/lib/haxelib/hxsdl/git/SDLSupport.h:30:21: note: expanded from macro 'VOIDPTR'
#define VOIDPTR(v)      ((void*)(v))
                         ^
2 warnings generated.

lewislepton avatar Jan 03 '16 13:01 lewislepton

on more try :)

ncannasse avatar Jan 03 '16 17:01 ncannasse

little bit better here is the output

@/Users/lepton/Developer/Heaps/GAMES/MIORA/bin/obj/darwin64/all_objs
Undefined symbols for architecture x86_64:
  "_SDL_CreateWindow", referenced from:
      sdl::Window_obj::__construct(String, int, int) in 5a0e3030_Window.o
  "_SDL_GL_CreateContext", referenced from:
      sdl::Window_obj::__construct(String, int, int) in 5a0e3030_Window.o
  "_SDL_GL_SetAttribute", referenced from:
      sdl::Window_obj::__construct(String, int, int) in 5a0e3030_Window.o
  "_SDL_GL_SetSwapInterval", referenced from:
      sdl::Window_obj::set_vsync(bool) in 5a0e3030_Window.o
  "_SDL_GL_SwapWindow", referenced from:
      sdl::Window_obj::present() in 5a0e3030_Window.o
  "_SDL_GetWindowSize", referenced from:
      sdl::Window_obj::get_width() in 5a0e3030_Window.o
      sdl::Window_obj::get_height() in 5a0e3030_Window.o
  "_SDL_Init", referenced from:
      sdl::Sdl_obj::init() in 5a0e3030_Sdl.o
      sdl::__Sdl_objinit() in 5a0e3030_Sdl.o
  "_SDL_PollEvent", referenced from:
      sdl::Sdl_obj::loop(Dynamic, Dynamic) in 5a0e3030_Sdl.o
  "_SDL_Quit", referenced from:
      sdl::Sdl_obj::quit() in 5a0e3030_Sdl.o
      sdl::__Sdl_objquit() in 5a0e3030_Sdl.o
  "_SDL_SetWindowFullscreen", referenced from:
      sdl::Window_obj::set_fullScreen(bool) in 5a0e3030_Window.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: error running g++ -o Main -stdlib=libstdc++ -framework Cocoa -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -m64 -framework OpenGL @/Users/lepton/Developer/Heaps/GAMES/MIORA/bin/obj/darwin64/all_objs
Error: Build failed

lewislepton avatar Jan 03 '16 17:01 lewislepton

Right, SDL linking is missing, could you try again?

ncannasse avatar Jan 03 '16 18:01 ncannasse

just tried and it seemed to have. but said about SDL missing

ld: framework not found SDL2

lewislepton avatar Jan 03 '16 19:01 lewislepton

though am sure i have installed it in hxsdl. plus do have it in my local frameworks folder

lewislepton avatar Jan 03 '16 19:01 lewislepton

the pictures i posted before show the layout of the hxsdl setup

lewislepton avatar Jan 03 '16 19:01 lewislepton

Could you check replacing SDL2 by SDL in native.xml ?

ncannasse avatar Jan 03 '16 20:01 ncannasse

hmmm. same thing. says that it is not found

lewislepton avatar Jan 03 '16 20:01 lewislepton

@hughsando any insight? PS: I'm using the following config file https://github.com/ncannasse/hxsdl/blob/master/native.xml

ncannasse avatar Jan 03 '16 21:01 ncannasse

I guess checking the link line to make sure it has the flags you want. Also, do you need to install the sdl2 framework somehow on mac - third party installer? FYI, there is also a similar project https://github.com/snowkit/linc_sdl

hughsando avatar Jan 04 '16 05:01 hughsando

i do have sdl instaled in my framework folder. did just try another time that im back from work, but again, not working

lewislepton avatar Jan 04 '16 17:01 lewislepton

linc_sdl directly compiles the SDL sources, whereas hxsdl usually uses the precompiled shared library. @lewislepton it seems that you need the SDL library actually installed to be used in OSX toolchain, not sure exactly how to do that.

Look at https://developer.apple.com/library/mac/documentation/MacOSX/Conceptual/BPFrameworks/Tasks/InstallingFrameworks.html

ncannasse avatar Jan 04 '16 19:01 ncannasse

normally in mac-land. to install SDL [or any packed framework], you just need to plop SDL2, into your global frameworks folder. so it affects everything no matter what user. which actually, the link you gave is just that

but SDL installing is probably the fifth thing i do when i either do a clean install or on a new mac computer ;)

lewislepton avatar Jan 04 '16 20:01 lewislepton