I installed SOIL on my Mac (BigSur) in the normal way with make and make install. When I do cmake . to my OpenGL Project, everything is ok and SOIL is found. But when i do make, i get following warning/error: ld: warning: ignoring file /usr/local/lib/libSOIL.a, building for macOS-x86_64 but attempting to link with file built for macOS-x86_64.
I tried everything i found on the internet. I also included -m64 in the Makefile.
Does somebody know to solve this issue?
libSOIL uses the Carbon API (see here). The Carbon API has been deprecated with Montain Lion and removed with Catalina. I have removed libSOIL from a project for this reason, it is unlikely you can get it to work without rewriting some of its code.
A possible replacement would be libSDL along with SDL_image. These libs are much more heavy-weight, but can be used while still doing raw OpenGL rendering and ignoring the SDL rendering API.
You can use SOIL2 replace libSOIL, see SOIL2 for more.
Related
I have a peculiar setup, but necessary out of business decisions outside of my control.
I am running macOS 12 on Apple Silicon, have Xcode 9.2, am able to compile and link, by specifying the actual compilers inside the Xcode package, and specifying a more up to date version of ar and ranlib to CMake (the Xcode 9.2 versions give runtime errors on newer systems), basically like this:
-DCMAKE_C_COMPILER=/Applications/Xcode_10.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang
-DCMAKE_CXX_COMPILER=/Applications/Xcode_10.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++
-DCMAKE_OSX_SYSROOT=/Applications/Xcode_10.1.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
-DCMAKE_OSX_ARCHITECTURES=x86_64
-DCMAKE_AR=/usr/bin/ar
-DCMAKE_RANLIB=/usr/bin/ranlib
These options work and let e.g. Xcode 10.1 tools be usable and we can build our software on newer OS versions, but in the XCode 9.2 case, we fail in linking OpenGL:
ld: can't map file, errno=22 file '/Applications/Xcode_9.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework' for architecture x86_64
Due to the commandline option passed to Clang:
/Applications/Xcode_9.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework
Which seems to think that it is a file, while it's a framework (directory). Changing this manually to
-framework OpenGL
makes everything work as expected. But that's not what CMake provides.
The question now is: how do I make CMake use this option instead of just passing the OpenGL framework directory path to Clang (with as little change to our CMake files as possible). We currently link any targets using OpenGL using the imported targets provided by find_package(OpenGL REQUIRED):
target_link_libraries(... PRIVATE OpenGL::GL)
And ideally I'd like to keep this the same as there's many of these in our solution.
UPDATE: I hit an additional snag, which seems to be that things like Qt5's cmake scripts are also adding the OpenGL framework directories outside of my OpenGL::GL usage. So perhaps a better approach would be to find a functional ar/ranlib on M1 that can handle what Xcode 9.2's ar/ranlib can handle.
If you want to link specifically with -framework OpenGL, you should change your target_link_libraries line to look like this instead:
target_link_libraries(${PROJECT_NAME} LINK_PUBLIC "-framework OpenGL")
I believe this removes the need for find_package(OpenGL) as well.
The issue is about linking x86_64 macOS executables statically against libavcodec, libavdevice, etc, which have some object files built against freestanding as they use YASM which isn't able to embed the macOS "tag" in the binary (see Building for macOS, but linking in object file built for free standing for detailed information on that issue).
Everything works fine under Xcode 11.6 - the following messages are here, but they are warnings.
With the Xcode 12 update they become an error.
How to make them warnings again ? I could not find anything relevant in the ld man page.
ld: in ffmpeg/lib/libavcodec.a(aacencdsp.o), building for macOS, but linking in object file built for free standing, for architecture x86_64
There is no option I have found to revert the error to a warning. Apple has been warning us about this issue for a few releases of XCode now and the warning has become an error.
Until NASM is modified, or we can use some other assembler, the only option that allows me to build and link against the libav libraries in my application is to disable assembly when compiling ffmpeg.
./configure --disable-asm
This works my my case, as the performance of the non-assembly code path is acceptable in my desktop authoring tool. The server-based renderer still uses the assembly code path as it is linux based.
You may have to configure any libaries that you are including in your ffmpeg build to also disable assembly.
Once again, this is an acceptable solution for my case, as the non-assembly code paths are fast enough for my use case.
I am beginning openGL in xcode. I followed the instructions on how to begin detailed here.
In short, I linked the libglfw3.3.1.dylib, libGLEW.1.13.0.dylib and OpenGL framework under build settings, and added /usr/local/include to header search paths.
However, I run into the following error:
ld: library not found for -lglfw3.3.1
I saw other posts about 'library not found' errors recommending linking the frameworks which I assumed to have done from build settings with the 3 libraries mentioned above.
Does anyone have any advice?
You need to add /usr/local/lib to your library search paths as well, assuming that you have installed GLFW there, and assuming that it is in fact libglfw3.3.1.dylib or libglfw3.3.1.a that you have installed there.
Okay I've been searching for hours to try and solve this but nothing has worked. This problem is very similar to other posts, but I none of their solutions work.
So I am writing an OpenGL program using glew and glfw and for some reason I am unable to get the program to compile. The error is on the include statement:
#include <GL/glfw.h>
and the error says 'GL.glfw.h' file not found.
I have followed all the instructions on the
GLFW-2.7.8 Release Notes
web page, which includes making glfw, and then importing the static library libglfw.a into Xcode. The library does show up under Build Phases -> Link Binary with Libraries, but apart from that Xcode doesn't seem to recognize it. For example, under the File Inspector it detects the file type as "Default - data".
The static library is configured for 64-bit architecture, which I am running.
I have tried changing the search paths under Build Settings.
I have the following frameworks included: Cocoa, OpenGL, and IOKit.
Please let me know if there is any more information you need to help me solve this problem and thank you for reading.
It turns out my glew was not importing correctly and so glfw did not work either.
These are the steps I took:
Changed the Base SDK from Latest OSX (10.8) to Current OSX.
After doing this, I "reduced" the error to an Apple Mach-O Linker (Id) error. Next:
Added -lGLEW to Other Linker Flags.
Added /opt/local/include/ to the header search paths
Added /opt/local/lib/ to the library search paths
Here is where I found my answer.
I'm trying to build a project (namely, Angband's source - http://rephial.org/downloads/3.3/angband-v3.3.2.tar.gz) with Emscripten's emcc in order to port it to Javascript and ultimately build an online version.
I've managed to get the process started with
emconfigure ./configure
make
which begins to successfully start generating LLVM bitcode .o files, but then it hangs up on main-gcu.c with 'main-gcu.c:43:11: fatal error: 'ncurses.h' file not found'
I believe main-gcu.c is the only file that references ncurses, but I just can't figure out how to include the library while compiling. Is there a way to specify including ncurses with 'make', or should I compile the main-gcu.c file individually, with 'emcc main-gcu.c -c -lncurses'? I tried doing that but that led to another error with emcc being unable to find other actually included header files two levels down (it couldn't find headers that were included by a header included by main-gcu.c - anyway to fix that?).
I'm also not certain if I have/need to install the ncurses library on Mac OSX. All I can really find are references to libncurses5-dev for Linux.
Thanks!
I think you misunderstand the compilation via Emscripten. I will try to point out a few problems you are facing.
The general rule is that all tools of Emscripten ONLY can turn LLVM formats (e.g. BITCODE) into JavaScript. emconfigure, emmake, ... modify the build environment so that your sourcecode is compiled to one of the LLVM formats (there are exceptions to the rule but nevermind). So anything you want to link against your final result has to be in a LLVM format, as well (which by default ncurses is not).
Since the output is JavaScript, there is no chance to execute any program code in different threads. While a lot of C/C++ code does use a thread for the UI and others for processing, such a model does NOT work for Emscripten. So in order to get the software compiling/running you will have to rewrite the parts that use threading. See emscripten_set_main_loop for pointers.
Even if you have the libraries compiled you then have to statically link them to Emscripten. At this point it is less of a technical problem but more of a license issue since if your library is licensed under e.g. LGPL due to static linking the GPL terms are effective.
I hope all clarity finally vanished ;)