I downloaded GLUI from https://github.com/libglui/glui, but I am not clear on how to get it to work on my Xcode. I read this step:
To include GLUI in your own apps, add the glui library to your makefile (before the glut library 'libglut.a'), and include "glui.h" in your sources.
Where would I find my makefile since I am using Xcode?
I was able to get #include to compile, but if I try GLUI *glui from the manual, I get "Unknown type name 'GLUI'". There is something on the front page: https://lukecyca.com/2008/glui-235-framework-for-mac-os-x.html where it mentions #include, but I don't know where I can get GLUI/glui.h.
After you build the lib, you'll have two directories lib and include which you have to move to your Xcode project. It'll look like this:
If Xcode does not see the includes nor links to the library, you'll have to add them to search paths (headers and libraries) like so:
NOTE: In order to use them in Obj-C you'll have to change file extension to .mm (obj-c++ file).
Related
I'm trying to build GLFW from source for Code Blocks. I used Cmake and it made a directory and I opened the Code blocks project file and clicked the gear to build. The only thing new in src is libglfw3.a and I'm not sure what to do with it.
I think you're following the LearnOpenGL tutorial. Actually, i tried to do the same as he recommended, but i ended up following this tutorial which is way more simple to apply https://www.youtube.com/watch?v=0WrSGMuU964&t=0s . It's using the pre-compiled binaries folder, that's why it is not using Cmake. To make it short (under windows), you only need to copy/paste the include and lib-mingw folders in your project folder. Then open your project with Code::Blocks and go in Project/Build options... . In Search directories under the compiler tab, you need to add the include directory you just copy/pasted and under the linker tab, you do the same thing with the lib-mingw dir. Now in the linker settings tab (next to search directories) you need to add glw3, gdi32, and opengl32, and that's all it should be working now :) I only wrote the tutorial in case one day it disappears from youtube :p
This was posted a while ago but I think I built the static GLFW library for linux with WSL CMake instead of Windows CMake.
I have a "cross platform" application that uses two code repositories at the moment, maintained relatively independently, and built with VS / Xcode depending on the target platform (win or mac respectively). I fell in love with Premake after using it on a few previous projects and am trying to pull all of my code for this application together into a single cross-compilable codebase.
I don't want to rely on Xcode, and instead want any developer to be able to build on Mac using either Xcode or gmake. I have a non-standard framework that I want to link to and include in the repository (it won't be located in /Library/Frameworks or any of the default mac framework search paths). I've added the framework file in a directory in my project /lib/TheFramework.framework. My premake file contains the following under the project definition:
includedirs {".", "lib", "lib/TheFramework.framework/Headers"}
libdirs {"lib"}
links {"TheFramework.framework"}
When I compile, (running $ premake5 gmake and then $ make), I get a header file not found error. Is there something wrong with my search paths? Am I missing a path or a flag somewhere?
Thanks!
Before looking at what you need to do with premake, let's first look at what needs to happen under the hood.
When compiling a mac program with a non-standard framework on gcc or clang (which is what your resulting make file does) it is necessary to do two things:
Specify the name of the framework, via -framework TheFramework - This is what premake does when you provide it with links {"TheFramework.framework"
Specify the location of the framework, via -F /Path/To/Framework/ - This is currently not being handled automatically by premake.
I've made a simple test c program that uses the SDL2 framework and compiled it with gcc: https://gist.github.com/JohannesMP/6ff3463482ebbdc82c2e - notice how when I leave off the -F /... flag I get an error that is probably similar to what you described.
So what is happening is, although you are providing premake with the include dir, premake will not add that the proper -F flag.
One way around this is to do the following:
configuration {"macosx", "gmake"}
buildoptions {"-F /Path/To/Framework"}
linkoptions {"-F /Path/To/Framework"}
(See here for an example project: https://gist.github.com/JohannesMP/9a9b5263c127103f1861#file-premake5-lua-L24-L26 )
In premake5 this will blindly append the code provided to both the build step as well as the link step. It is necessary to do it both for build as well as link.
Just keep in mind that, because premake doesn't process or check the build/link options for being valid, a user will receive an error if the provided path doesn't exist on their machine. For example while you might have a framework in your user-specific directory ~/Library/Frameworks, since that folder doesn't exist by default another user might be using the global /Library/Frameworks instead, and when they try to compile your premake project with gmake they will get a warning:
ld: warning: directory not found for option '-F/Users/<NAME>/Library/Frameworks'
At this point, it seems that there is no 'safe' way to get premake5 to try to include the framework path, but that may change in the future.
Check out this issue I posted on the premake repo: https://github.com/premake/premake-core/issues/196
I am trying to get some open source C++ code to compile in xcode. It uses the SDL library. I downloaded SDL 2.0 for OS X and installed it and things are working -- but the download didn't seem to include the file SDL_mixer.h -- which is referenced in the code, as shown below.
#include <SDL/SDL_mixer.h>
What happened to this file? Did it get dropped from SDL? What do I do to work around the missing file to get the code working?
SDL Mixer has always been a separate library you have to install next to your SDL.
To fix your problem, download and install the library in such a way that SDL_mixer.h is located in an SDL/ folder of your include paths.
Install the SDL Mixer framework and add a reference to it in your project.
Include the SDL_Mixer.h header like so:
#include <SDL2_Mixer/SDL_Mixer.h>
I have downloaded and installed Gtk2 with MacPorts:
sudo port install gtk2
And I have made sure that the system configuration with this too:
pkg-config --cflags gtk+-2.0
But when it comes the time that I put down this line in Xcode:
#include <gtk/gtk.h>
I still get the following error msg:
Gtk/gtk.h: No such file or directory
What am I missing here? Any configuration in XCode or something?
Thanks
You need to tell your project where gtk lives.
Best way to do this is to go into your project's "Build Settings" and look for the setting named "Header Search Paths". Add a direct path to your Gtk's include directory there. I suggest just a direct path like /usr/local/lib/gtk or whatever the true location of it is (and don't use fancy aliases or relative paths or things like this just yet, until you get really accustomed to them).
Then, make sure the framework (.framework, .dylib) or static library (a .a lib file) or whatever is included in your project so the linker knows which Gtk library to link against.
I also noticed a potentially useful tutorial here.
I'd like to add the libevent library to my Xcode project. I want to include it in the executable, because libevent isn't installed by default on Mac OS X.
I can compile the library from source using ./configure && make. I expected to find a .a library file, but there isn't. What do I do then? What files are relevant and how do I add them to Xcode?
Sorry for this very basic question, but I don't even know where to start.
First off, let's find out if your library truly got built. In the terminal, type in cd / and then find . -name libevent\* -print and see if the path for your libevent.a file actually appears.
If you can't find it, try running sudo make install from the top level of the library source code and then the library may end up getting installed in /usr/local/lib or some other appropriate place.
Once you do find the library, you can drag & drop it into your Project's list of Files in Xcode. Or you can include -levent in the link settings for your project.
Note that Xcode has this nasty "feature" that if it sees both dynamic and static versions of a library, it will always link against the dynamic one, even you specify the static one (.a) in your project. There's no way to override this "feafure" and you have to move or delete the dynamic one out of the library search paths.