I've been trying to link SOIL for a project I am working on with OpenGL. I'm running Yosemite 10.10.4.
When I try to use the SOIL library in my code, I get the following error (updated):
ld: warning: ignoring file /usr/local/lib/libSOIL.a,
file was built for archive which is not the architecture being linked (x86_64): /usr/local/lib/libSOIL.a
Undefined symbols for architecture x86_64:
"_SOIL_load_image", referenced from:
init() in main-93f615.o
ld: symbol(s) not found for architecture x86_64
My Steps
I followed the process indicated by the make file in SOIL: make, make install. It placed the libSOIL.a file in /usr/local/lib and SOIL.h in /usr/local/include. I included in my code:
#include "SOIL.h"
int width, height;
unsigned char* image = SOIL_load_image("CrayonBox2.png", &width, &height, 0, SOIL_LOAD_RGB);
And my Makefile contained this g++ target:
g++ -I/usr/X11R6/include -I/usr/local/include -I/opt/local/include -L/usr/local/lib/ -L/opt/local/lib -lSOIL -framework GLUT -framework OpenGL -framework CoreFoundation -o main main.cpp
Then the above error appeared.
I then tried a number of different things: I installed this guy's version of SOIL for Mac OS (which places libSOIL.a and libSOIL.dylib in /opt/local/lib and SOIL.h in /opt/local/include); I tried adding '-arch 1386 -arch x86_64'
as per this answer's suggestion. With each of these, I still receive the same error as before.
Any recommendations on what might be the issue?
I have the same problem, what my solution is modify the makefile, to let gcc support 64 through add -m64.
also see Simple OpenGL Image Library/projects/makefile/makefile:
CXXFLAGS = -O2 -s -Wall -m64
Make install and replace libSOIL.a again.
I hope the answer can help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With