0

So I've downloaded the most recent src for SOIL2 and premake5. I run the command premake5 vs2019 and build the static library, which works just fine. I then go to my project properties, and do two things- 1) I include the source files in the 'additional include directories' section under C/C++>Genereral and 2) I add the library file from the SOIL2 build to Linker>Input>Additional Dependencies.

Ok, now that I did both those things, I make sure to use #include <SOIL2.h> in my main.cpp (I've also tried #include "SOIL2.h"). However, when I try to build my project, I get a compilation error trying to call this method- SOIL_load_OGL_texture. The error reads

1>ld: error: undefined symbol: SOIL_load_OGL_texture
1>>>> referenced by Plane.cpp:49
1>>>>               x86\Debug\Plane.o:(Plane_setupGL(double, double))
1>>>> did you mean: _SOIL_load_OGL_texture
1>>>> defined in: C:\Users\------\source\repos\Sudoku\Linking\SOIL2\lib\soil2-debug.lib

Ok, so I try compiling it with that method instead (_SOIL_load_OGL_texture, same thing just with an underscore in front for some inexplicable reason...wtf??). I then get this compilation error-

1>Plane.cpp(49,12): error : use of undeclared identifier '_SOIL_load_OGL_texture'; did you mean 'SOIL_load_OGL_texture'?
1>        texture = _SOIL_load_OGL_texture("C:\\Users\\------\\source\\repos\\Sudoku\\Sudoku\\Sudoku.Android.Packaging\\Resources\\sudokuboard.png", SOIL_LOAD_AUTO, SOIL_CREATE_NEW_ID, SOIL_FLAG_MIPMAPS | SOIL_FLAG_INVERT_Y | SOIL_FLAG_NTSC_SAFE_RGB | SOIL_FLAG_COMPRESS_TO_DXT);
1>                  ^~~~~~~~~~~~~~~~~~~~~~
1>                  SOIL_load_OGL_texture
1>C:\Users\------\source\repos\Sudoku\Linking\SOIL2\include\SOIL2.h(166,2): note: 'SOIL_load_OGL_texture' declared here
1>        SOIL_load_OGL_texture

WTF??? I have no idea what's going on here. The project is an android/ios opengl c++ project, btw.

  • 1
    The first error is a linker error. The second error is a compiler error. The compiler error is saying that there is no _SOIL_load_OGL_texture in the header files you are including, which you can verify by looking. Apparently without the underscore it is in the header files, otherwise building without the underscore would not have made it all the way to linking. Why linking is failing I dont know. My guess would be something is wrong with how you built the static library. I'm also confused by "The project is an android/ios opengl c++ project" ... if you are builing in VS with a .lib etc. – jwezorek Jun 29 '21 at 23:30
  • This is the type of project I have- https://learn.microsoft.com/en-us/cpp/cross-platform/build-an-opengl-es-application-on-android-and-ios?view=msvc-160 – Adrian Wheeler Jun 29 '21 at 23:37
  • So update, I rebuilt the library in x64 and used 'clang' as my compiler since that's what appears my project uses, and the error is now 'not an elf file' – Adrian Wheeler Jun 29 '21 at 23:38
  • i mean i don't know anything about building cross-platform mobile apps in VS (I didnt actually even know this was a thing) but your original linker error is trying to link to a .lib file which is clearly wrong. A .lib file is a Windows thing. On either iOS or Android that would be a .a file, I believe. Are iOS and Android even ABI compatible? I dont know. – jwezorek Jun 30 '21 at 14:22
  • SO basically you need to google "linking to external libraries from a OpenGLES Application project in Visual Studio" or something like that. Otherwise, you could bring all of the code for SOIL2 into your project and build it into your executable rather than trying to link to it. Or just use stb-image directly without the wrapper. – jwezorek Jun 30 '21 at 14:24

0 Answers0