Jump to content

  • Log In with Google      Sign In   
  • Create Account

SOIL: new lightweight image loading lib


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
130 replies to this topic

#121 Nashenas88   Members   -  Reputation: 100

Like
0Likes
Like

Posted 02 March 2010 - 10:25 AM

Hey, so I was wondering if anyone could help with an issue I have compiling a game in cygwin.

Previously I wrote my own image loader for bitmaps, however, bitmaps kinda sucked in terms of size, so I wanted something to load PNGs. I decided to implement SOIL and it's worked perfectly under Mac OS X. However, when I attempt to compile the SOIL lib and then my game, I get the following errors due to undefined references:


$ make
g++ -Wall -o game_name.exe -I/usr/include/opengl -I/usr/include/w32api
-I./Simple\ OpenGL\ Image\ Library/src drawable.cpp texture.cpp player.cpp
character.cpp main.cpp map.cpp collideable.cpp state.cpp -L/usr/lib/w32api
-L./Simple\ OpenGL\ Image\ Library/lib -lglut32 -lglu32 -lopengl32 -lSOIL

./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0x253): undefined reference to `_glReadPixels'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0x34a): undefined reference to `_glGetString'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0x37c): undefined reference to `_glGetString'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0x3ba): undefined reference to `_glGetString'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0x3ed): undefined reference to `_glGetString'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0x40e): undefined reference to `_glGetString'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0x45a): more undefined references to `_glGetString' follow
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0x4cb): undefined reference to `_glXGetProcAddressARB'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0x8af): undefined reference to `_glTexImage2D'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0x9cd): undefined reference to `_glTexImage2D'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0xa23): undefined reference to `_glDeleteTextures'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0xaa3): undefined reference to `_glTexParameteri'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0xac3): undefined reference to `_glTexParameteri'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0xaed): undefined reference to `_glTexParameteri'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0xb0d): undefined reference to `_glTexParameteri'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0xb2d): undefined reference to `_glTexParameteri'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0xc2b): undefined reference to `_glGenTextures'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0xc65): undefined reference to `_glTexParameteri'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0xc85): undefined reference to `_glTexParameteri'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0xd09): undefined reference to `_glTexParameteri'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0xfb6): undefined reference to `_glGetIntegerv'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0x1305): undefined reference to `_glTexImage2D'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0x1465): undefined reference to `_glTexImage2D'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0x14ad): undefined reference to `_glTexImage2D'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0x14d4): undefined reference to `_glTexParameteri'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0x14f1): undefined reference to `_glTexParameteri'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0x151e): undefined reference to `_glTexParameteri'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0x1531): undefined reference to `_glTexParameteri'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0x157a): undefined reference to `_glTexParameteri'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0x1594): more undefined references to `_glTexParameteri' follow
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0x1611): undefined reference to `_glGenTextures'
./Simple OpenGL Image Library/lib/libSOIL.a(SOIL.o):SOIL.c:(.text+0x1748): undefined reference to `_glTexImage2D'
collect2: ld returned 1 exit status
make: *** [flock_you.exe] Error 1





Edit: removed warnings related to my code

Sponsor:

#122 speciesUnknown   Members   -  Reputation: 527

Like
0Likes
Like

Posted 02 March 2010 - 10:49 AM

HI,

1) Congratulations on necro'ing a thread from 3 years ago...

2) gcc (including g++) on OS X uses frameworks, which contain headers and object code in one package. I dont know the full details, but there are various things for you to find online. Mostly they recommend g++ <your various files> -framework OpenGL -framework glut or similar.




#123 Nashenas88   Members   -  Reputation: 100

Like
0Likes
Like

Posted 02 March 2010 - 11:41 AM

I probably should have rewritten the last line as:

However, when I attempt to compile the SOIL lib and then my game in cygwin, I get the following errors due to undefined references:

This is what compiling on Mac OS X looks like:

$ make
g++ -Wall -o game_name -I./Simple\ OpenGL\ Image\ Library/src drawable.cpp
texture.cpp player.cpp character.cpp main.cpp map.cpp collideable.cpp state.cpp
-L./Simple\ OpenGL\ Image\ Library/lib -framework OpenGL -framework GLUT -framework
CoreFoundation -lSOIL
$


It's very beautiful. But when compiling under cygwin as in my previous post, I seem to get a lot of undefined references to OpenGL library functions. My original code also uses some of the same function, but has no issue compiling them. What do I have to do so that it won't complain about the OpenGL code inside of the SOIL library?

I originally tried linking opengl when recompiling the library, but it said I couldn't link in OpenGL when making a static library.

#124 Nashenas88   Members   -  Reputation: 100

Like
0Likes
Like

Posted 03 March 2010 - 07:42 AM

So I managed to remove a whole bunch of the undefined references by changing the order in which I called the static libraries, e.g.:


$ make
g++ -Wall -o game_name.exe -I/usr/include/opengl -I/usr/include/w32api
-I./Simple\ OpenGL\ Image\ Library/src drawable.cpp texture.cpp player.cpp
character.cpp main.cpp map.cpp collideable.cpp state.cpp -L/usr/lib/w32api
-L./Simple\ OpenGL\ Image\ Library/lib -lSOIL -lglut32 -lglu32 -lopengl32

./Simple OpenGL Image Library/lib/libSOIL.a(stb_image_aug.o):stb_image_aug.c:(.text+0x6c1): undefined reference to `__assert'
./Simple OpenGL Image Library/lib/libSOIL.a(stb_image_aug.o):stb_image_aug.c:(.text+0x939): undefined reference to `__assert'
./Simple OpenGL Image Library/lib/libSOIL.a(stb_image_aug.o):stb_image_aug.c:(.text+0xc7a): undefined reference to `__assert'
./Simple OpenGL Image Library/lib/libSOIL.a(stb_image_aug.o):stb_image_aug.c:(.text+0x2d44): undefined reference to `__assert'
./Simple OpenGL Image Library/lib/libSOIL.a(stb_image_aug.o):stb_image_aug.c:(.text+0x2ee6): undefined reference to `__assert'
./Simple OpenGL Image Library/lib/libSOIL.a(stb_image_aug.o):stb_image_aug.c:(.text+0x2fb5): more undefined references to `__assert' follow



Any ideas as to how to remove these?

#125 Nashenas88   Members   -  Reputation: 100

Like
0Likes
Like

Posted 03 March 2010 - 12:36 PM

Figured everything out now. In one of the stb files, you have to add a #define NDEBUG before the line #include <assert.h> so that asserts are turned off. So to recap, if you want to use SOIL in a project that's going to be compiled in cygwin, you need to make sure when you compile that the -lSOIL flag comes before the -lopengl32 flag and that you define NDEBUG before assert.h is included. Hope this helps anyone else who decides to use cygwin to compile.

#126 bkdi   Members   -  Reputation: 100

Like
0Likes
Like

Posted 05 May 2010 - 10:13 AM

Hi,

I would like to use SOIL with VS 2008, but I have a problem with the library.
File libSOIL.lib I copied to VC\lib and SOIL.h to VC\include and in VS 2008 I added libSOIL.lib to the Project Properties>Configuration Properties>Linker>Input>Additional Dependencies.

#include "stdafx.h"
#include <gl\glut.h>
#include "SOIL.h"
int _tmain(int argc, _TCHAR* argv[])
{
GLuint tex_2d = SOIL_load_OGL_texture
(
"bow.bmp",
SOIL_LOAD_AUTO,
SOIL_CREATE_NEW_ID,
SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT
);
return 0;
}


This code ganeretes these errors:
Error 1 error LNK2019: unresolved external symbol __alloca referenced in function _stbi_zlib_decode_noheader_buffer libSOIL.lib
Error 2 error LNK2019: unresolved external symbol _sqrtf referenced in function _RGBE_to_RGBdivA2 libSOIL.lib

Please help!

#127 tom_mai78101   Members   -  Reputation: 577

Like
0Likes
Like

Posted 10 May 2010 - 09:15 PM

I would like to ask about SOIL:

Can it flip sprites "horizontally" instead of "vertically"?

Just making sure, because it didn't say anything about horizontal flipping in this page. I'm really worried about it.

[Edited by - tom_mai78101 on May 11, 2010 3:15:42 AM]

#128 Kylotan   Moderators   -  Reputation: 3338

Like
0Likes
Like

Posted 11 May 2010 - 01:57 AM

You shouldn't need to flip an image horizontally with the loading library. You will probably have to use something else if you really need that functionality.

#129 kiaran   Members   -  Reputation: 122

Like
0Likes
Like

Posted 17 May 2010 - 12:55 PM

Thank you for this great library. I ripped out 2 pages of code from my old and clunky image loader (based on SDL_image) and replaced it with SOIL.

It compiled, linked and worked as expected on the first try! :)



#130 wittyameta   Members   -  Reputation: 100

Like
0Likes
Like

Posted 26 May 2010 - 12:22 AM

Hi, I am working on redhat.
Can someone exactly tell me how to link the library.
I put libSOIL.a in /usr/lib folder and SOIL.h file in /usr/include folder.

I included this line in my C++ program #include <SOIL.h>

On compiling it gives the following errors:

/tmp/cc1dkSnQ.o(.text+0x166): In function `glutDisplay()':
: undefined reference to `SOIL_load_OGL_texture'
/tmp/cc1dkSnQ.o(.text+0x17d): In function `glutDisplay()':
: undefined reference to `SOIL_last_result'
collect2: ld returned 1 exit status

Can someone please tell me what's wrong?

#131 GenPFault   Members   -  Reputation: 160

Like
0Likes
Like

Posted 28 May 2010 - 12:12 PM

Quote:
Original post by wittyameta
Hi, I am working on redhat.
Can someone exactly tell me how to link the library.
I put libSOIL.a in /usr/lib folder and SOIL.h file in /usr/include folder.

I included this line in my C++ program #include <SOIL.h>

On compiling it gives the following errors:

/tmp/cc1dkSnQ.o(.text+0x166): In function `glutDisplay()':
: undefined reference to `SOIL_load_OGL_texture'
/tmp/cc1dkSnQ.o(.text+0x17d): In function `glutDisplay()':
: undefined reference to `SOIL_last_result'
collect2: ld returned 1 exit status

Can someone please tell me what's wrong?


How are you invoking gcc? You'll probably need (iirc) a -LSOIL.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS