Closed esthermations closed 4 years ago
I think there's more initialization needed.
Check initialize.adb
under OpenGLAda-examples/common/src
of the /flx/OpenGLAda-examples
repository.
Or perhaps have a look at one of the simple OpenGLAda-examples
.
One of the simplest is OpenGLAda-examples/superbible/simplest
This glfw based tutorial might help, https://capnramses.github.io//opengl/index.html
.
ld: framework not found Cocoa
This has nothing to do with your code, it's a linker error. Do you have Xcode installed? I am not quite sure about this, but I think you need a macOS SDK installed, which comes with Xcode.
I do have Xcode installed via the App Store, yes. I've just reinstalled it but that didn't help. Guess I'll look into this more, thanks for the help. Still, if you happen to have any other ideas, I'm all ears, this one's got me stumped. Thanks again.
Hmm, Xcode command line utilities installed?
I just checked on my machine, the framework should be in
/System/Library/Frameworks/Cocoa.framework
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Cocoa.framework/
I believe the second one is what Xcode would use but the first one is what GNAT requires because it has no clue about which macOS SDK to use. Not completely sure. The first option may be installed with Xcode command line tools, or it may be already there. Frankly, macOS moves it developer stuff around so much I lost track of how things are supposed to work.
If the first option is missing and you can't figure out how to create it, or if you want to just try out things, you can try modifying OpenGLAda's linker options in the opengl.gpr
file:
when "quartz" =>
for Linker_Options use
("-Wl,-F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks,-framework,OpenGL,-framework,CoreFoundation");
-F
gives the framework search path.
That's all I can think of. Let me know if something works :).
On my system the Cocoa framework is installed as /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk 1/System/Library/Frameworks/Cocoa.framework
.
Perhaps you could check that it is actually installed on your system?
Also, sometimes I get a dialog from Xcode requesting permission to install additional components; usually, I think, after an OS update.
Another thought is that you might need an appropriate gpr configure file (.cgpr). Perhaps run gprconfig?
But I doubt that that's your problem as I can't find any reference to cocoa in my gpr configure file.
I'm wondering if you need the reference to cocoa at all as my typical build command doesn't include any mention of cocoa:
gprbuild -d -eL -P/System/Volumes/Data/Ada_Source/OpenGLAda-examples/redbook/03_draw_commands/draw_commands.gpr
-XMode=debug -XLibrary_Type=static -XAuto_Exceptions=enabled -XWindowing_System=quartz -XGLFW_Version=3
/System/Volumes/Data/Ada_Source/OpenGLAda-examples/redbook/03_draw_commands/src/draw_triangles.adb -s
--config=/System/Volumes/Data/Ada_Source/default.cgpr -p
Just some thoughts and probably not much help. I'll try your code on my system and see what happens.
Ah, one more thing, you can set the environment variable DYLD_FRAMEWORK_PATH
to the folder where your frameworks are located, this is a better solution than tinkering with the opengl.gpr
file.
I tried your code on my system. It ran to completion but no window was displayed.
/System/Volumes/Data/Ada_Source/More_OglAda_Examples/tester/obj/testing
[2020-08-18 22:05:41] process terminated successfully, elapsed time: 03.36s
The command generated by GPS was:
gprbuild -d -eL -P/System/Volumes/Data/Ada_Source/More_OglAda_Examples/tester/testing.gpr -XGLFW_Version=3
-XLibrary_Type=static -XAuto_Exceptions=enabled -XMode=debug -XWindowing_System=quartz
/System/Volumes/Data/Ada_Source/More_OglAda_Examples/tester/src/testing.adb
-s --config=/System/Volumes/Data/Ada_Source/default.cgpr -p
Non-display of window possibly due to additional initialization needed for Mac?
@flyx Thanks so much for the info, that's quite helpful. I do seem to have both of those directories for Cocoa.framework, the contents of the latter look like this:
Exporting DYLD_FRAMEWORK_PATH any of the mentioned directories hasn't seemed to help.
I tried compiling the redbook example that @rogermc2 used, and it also fails to link with the same error:
@rogermc2 I don't believe the code does display a window, no. The C one doesn't, anyway. My main problem right now is that I can't get any OpenGLAda code at all to link on my system. Thanks for trying it on yours, it's strange that it works for you and not for me. I'm quite new to development on MacOS so all this 'framework' stuff is pretty new to me. 🤷♀️
Thanks so much for everyone's help.
I also remain "a novice at all this 'framework' stuff"!
Here is my gprbuild
command, generated by GPS for draw_triangles
:
gprbuild -d -eL -P/Ada_Source/OpenGLAda-examples/redbook/03_draw_commands/draw_commands.gpr
-XMode=debug -XLibrary_Type=static -XAuto_Exceptions=enabled -XWindowing_System=quartz
-XGLFW_Version=3 draw_triangles.adb -s --config=/Ada_Source/default.cgpr
I tried your method of just invoking gprbuild
on the terminal command line:
MacBook-Air:03_draw_commands rogermcmurtrie$ gprbuild
using project file draw_commands.gpr
Compile
[Ada] draw_triangles.adb
.
.
.
through to:
Link
[link] draw_triangles.adb
ld: library not found for -lfreetype
collect2: error: ld returned 1 exit status
gprbuild: link of draw_triangles.adb failed
From my limited experience of using gprbuild
from the command line, using just the command gprbuild
seems insufficient; additional parameters are usually required.
Again, in my limited experience, at least specifying a configuration file is required.
I suggest trying my gprbuild
command above for draw_triangles
or, rather, the one for the testing
program with parameters changed to suit your system. You might try it without the --config
parameter but it will probably fail in which case you will need to generate a configure file using gprconfig
.
I just tried the gprbuild
command above for draw_triangles
from the command line and it completed successfully.
Then tried it without the --config
parameter and it failed with:
ld: library not found for -lfreetype
so it seems that a configuration
file is essential.
I next tried it with only the --config
parameter and, surprisingly, it built and ran successfully:
MacBook-Air:03_draw_commands rogermcmurtrie$ gprbuild --config=/Ada_Source/default.cgpr
using project file draw_commands.gpr
Compile
[Ada] draw_triangles.adb
[Ada] main_loop.adb
.
.
.
It could be that the system "remembered" some of the other parameters.
@rogermc2 !!! 🥳 GPRconfig worked! I tried it when you suggested before but I selected the GCC compiler included with GNAT for both C and C++. Nothing changed, so I didn't mention it. I just tried again, but selecting the LLVM compilers in /usr/bin this time (probably Clang installed via Homebrew), and the program links and runs just fine now!
It generated a config file called default.cgpr, which gprbuild grabs by default according to the docs. So now just running gprbuild
on its own has the program compiling and linking properly!
Thanks so much!! I've even got my cargame-ada project compiling again, so now I can get back to work on it!
You guys really went above and beyond, thank you so much for the help! 🎉🎊🥳
Hey, I'm trying to get simple OpenGLAda programs to build on my Mac machine but I'm running into this issue:
To be clear upfront, this might not be an issue with OpenGLAda. I just have no idea what else it could be, so I'm starting here. No worries if you think this is not your bug, I'll probably take it to Homebrew next.
The program I'm testing is two files, testing.adb and testing.gpr. I'm basically just initialising a window, sleeping for three seconds, then destroying it.
testing.adb
:And
testing.gpr
:I installed GLFW via Homebrew and have LIBRARY_PATH=/usr/local/lib in my env.
As you saw above, building this with
gprbuild
results in theCocoa not found
error.An equivalent C program seems to work (but it also doesn't use Cocoa afaik...):
Compiling this works just fine:
If it's not too much trouble, could you possibly see if you're having this problem too? If not I'll assume it's something borked in my Homebrew setup or something.
Thanks very much!