Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Few loose ends compiling custom static SFML VS2012  (Read 3451 times)

0 Members and 1 Guest are viewing this topic.

Bobbo

  • Newbie
  • *
  • Posts: 16
    • View Profile
Few loose ends compiling custom static SFML VS2012
« on: June 04, 2013, 11:55:37 am »
Hi,

I've setup my own VS2012 project for compiling a static linking SFML 2.0. I instruct the linker to include the additional .lib deps (in the extlibs/libs-msvc folder).

The resulting .lib file then, when used in another project had some unresolved symbols involving GL, so I included opengl32.lib in the SFML .lib project and retried, but now I am left with a number of unresolved symbols referring to GLEW. Since GLEW is one of the deps in the provided extlibs folder, I'm a little confused about what I'm missing out in the link.

Apart from the 5 libs provided by the SFML 2.0 source (and opengl32.lib), what other lib deps need to be included?

Here is the linking errors when using this SFML in a project:

Quote
1>sfml.lib(RenderTarget.obj) : error LNK2001: unresolved external symbol __imp____glewBlendFuncSeparateEXT
1>sfml.lib(RenderTarget.obj) : error LNK2001: unresolved external symbol __imp____GLEW_EXT_blend_func_separate
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____glewActiveTextureARB
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____glewAttachObjectARB
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____glewCompileShaderARB
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____glewCreateProgramObjectARB
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____glewCreateShaderObjectARB
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____glewDeleteObjectARB
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____glewGetHandleARB
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____glewGetInfoLogARB
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____glewGetObjectParameterivARB
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____glewGetUniformLocationARB
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____glewLinkProgramARB
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____glewShaderSourceARB
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____glewUniform1fARB
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____glewUniform1iARB
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____glewUniform2fARB
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____glewUniform3fARB
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____glewUniform4fARB
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____glewUniformMatrix4fvARB
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____glewUseProgramObjectARB
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____GLEW_ARB_fragment_shader
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____GLEW_ARB_shader_objects
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____GLEW_ARB_shading_language_100
1>sfml.lib(Shader.obj) : error LNK2001: unresolved external symbol __imp____GLEW_ARB_vertex_shader
1>sfml.lib(Texture.obj) : error LNK2001: unresolved external symbol __imp____GLEW_ARB_texture_non_power_of_two
1>sfml.lib(GLCheck.obj) : error LNK2019: unresolved external symbol __imp__glewInit referenced in function "void __cdecl sf::priv::ensureGlewInit(void)" (?ensureGlewInit@priv@sf@@YAXXZ)
1>sfml.lib(GLCheck.obj) : error LNK2019: unresolved external symbol __imp__glewGetErrorString referenced in function "void __cdecl sf::priv::ensureGlewInit(void)" (?ensureGlewInit@priv@sf@@YAXXZ)
1>sfml.lib(JoystickImpl.obj) : error LNK2019: unresolved external symbol __imp__joyGetPosEx@8 referenced in function "public: static bool __cdecl sf::priv::JoystickImpl::isConnected(unsigned int)" (?isConnected@JoystickImpl@priv@sf@@SA_NI@Z)
1>sfml.lib(JoystickImpl.obj) : error LNK2019: unresolved external symbol __imp__joyGetDevCapsW@12 referenced in function "public: bool __thiscall sf::priv::JoystickImpl::open(unsigned int)" (?open@JoystickImpl@priv@sf@@QAE_NI@Z)
1>..\..\..\..\Main\Libraries\Debug\x86\OasisMain.dll : fatal error LNK1120: 30 unresolved externals

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Few loose ends compiling custom static SFML VS2012
« Reply #1 on: June 04, 2013, 12:02:17 pm »
When you compile a static library there's no link step, it's just an archive of compiled files. So you cannot link dependencies directly to a static library, you must link them to the final app that will use this static lib. So you have to link all the SFML dependencies to your final app.

But may I ask why you're not following the official instructions? Doing your own thing will only cause more errors, if you want a customized build you can do it with CMake, there's no need to write your own VS project from scratch.
Laurent Gomila - SFML developer

Bobbo

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Few loose ends compiling custom static SFML VS2012
« Reply #2 on: June 04, 2013, 12:13:08 pm »
VS2012 allows you to archive the deps into your output so that you link your project to the one .lib file.

If I do not specify any of the deps in the extlib\libs-msvc during my compilation of SFML then my app, using sfml,  is required to provide the .libs during it's link, but if I tell the "librarian" about your deps during the compilation of SFML then my app no longer needs to provide them.

That is, all except the ones in my original post, which I'm unsure how to resolve.

In contrast, when I link to your static .libs (sfml-xxxxx-s.lib) then everything is fine, I presume because everything required is provided in that .lib

I'm simply trying to create a single .lib containing everything, and so that I can get a PDB.


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Few loose ends compiling custom static SFML VS2012
« Reply #3 on: June 04, 2013, 12:17:02 pm »
Quote
VS2012 allows you to archive the deps into your output so that you link your project to the one .lib file.
Yes, that's what I do for SFML.

Quote
That is, all except the ones in my original post, which I'm unsure how to resolve.
Ok, sorry I thought your problem was more generic. To statically link GLEW you must define the GLEW_STATIC macro (in fact it might be another one, I don't remember, you should have a look at the doc or at the SFML CMake files).

To solve the joyXxx unresolved functions, you must link to winmm.lib.

Quote
I'm simply trying to create a single .lib containing everything
This is not a good idea, why do you want to do that?

Quote
and so that I can get a PDB.
To get the PDB files you just need to recompile SFML, no need to setup a custom project.
Laurent Gomila - SFML developer

Bobbo

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Few loose ends compiling custom static SFML VS2012
« Reply #4 on: June 04, 2013, 12:21:27 pm »
Thanks for the help.

I'm interested in your comment on this not being a good idea. My understanding is that the linker would be able to include (into a project using this single .lib) only the parts it needs.

This seems to be case (with some simple tests I did), I'm guessing I've missed some other glaring reason not to do this?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Few loose ends compiling custom static SFML VS2012
« Reply #5 on: June 04, 2013, 12:36:38 pm »
So you mean that your app doesn't depend on openal32.dll and libsndfile-1.dll if you don't use any audio class?

But anyway, what's the benefit of this?
Laurent Gomila - SFML developer

Bobbo

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Few loose ends compiling custom static SFML VS2012
« Reply #6 on: June 04, 2013, 01:03:27 pm »
Well to just update, I followed your advise on the previous posts and everything compiles and links fine now, so thanks for that.

The benefit was suppose to be that I only required one .lib file to use SFML (+get the PDBs, +the libs for all configs and platforms would adhere to a common naming scheme, allowing use of VS macros when building against it), but it seems that given the way SFML uses OpenAL and SND, you will still require at least these 2 dlls.

Am I to understand from this that using a static linking version of these libs was not possible/practical?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Few loose ends compiling custom static SFML VS2012
« Reply #7 on: June 04, 2013, 01:07:49 pm »
Exactly, because of their license which is LGPL. But if your project's license is compatible with the LGPL, you can recompile and link them statically.
Laurent Gomila - SFML developer

Bobbo

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: Few loose ends compiling custom static SFML VS2012
« Reply #8 on: June 04, 2013, 11:03:32 pm »
Damn the license issue slipped my mind totally.

Looks like compiling openal and libsnd for static linking (and in windows) is a real pain in the ass. Don't suppose anyone has experience with this?