Problems related to SOIL through g ++ in Yosemite

I tried to bundle SOIL for a project I'm working on with OpenGL. I am launching 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. He placed the file libSOIL.a 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.

: SOIL Mac OS ( libSOIL.a libSOIL.dylib in/opt/local/lib SOIL.h /opt/local/include ); '-arch 1386 -arch x86_64' . , .

- , ?

+4
3

, make , gcc 64 add -m64.

. Simple OpenGL Image Library/projects/makefile/makefile:

CXXFLAGS = -O2 -s -Wall -m64

libSOIL.a.

, .

+1

(-l -l):

g++ main.cpp -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 myexe, a.out...

0

You are probably using a precompiled static library. Better compile SOIL for your system. A fairly common compilation pipeline uses CMake and Make. Clone https://github.com/DeVaukz/SOIL move to the downloaded directory.

mkdir build
cd build
cmake ..
make
sudo make install
0
source

Source: https://habr.com/ru/post/1607581/


All Articles