Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issues linking SOIL through g++ in Yosemite

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?

like image 340
beisbeis Avatar asked Nov 10 '22 05:11

beisbeis


1 Answers

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.

like image 191
Jihui Xu Avatar answered Nov 15 '22 04:11

Jihui Xu