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

Author Topic: unresolved external symbol _sfWindow_Create  (Read 6943 times)

0 Members and 1 Guest are viewing this topic.

FarTreX

  • Guest
unresolved external symbol _sfWindow_Create
« on: July 03, 2012, 09:08:38 pm »
Howdy,

My problems started after I decided to join the Clang/LLVM master race.

First of all, my code:

Code: [Select]
#include <stdio.h>

#include <SFML\Window.h>

extern sfWindow* sfWindow_Create();

int main()
{
sfWindow* window;

sfVideoMode vmode =
{
.width = 1280,
.height = 720,
.bitsPerPixel = 32
};

sfContextSettings csettings =
{
.depthBits = 24,
.stencilBits = 8,   
.antialiasingLevel = 2,
.majorVersion = 3,
.minorVersion = 3
};

window = sfWindow_Create(&vmode, "TEST", sfClose, &csettings);
getchar();
return 0;
}


(click to show/hide)

So this compiles OK with:
Code: [Select]
clang -I "[truncated]\CSFML-2.0-rc\include" -c -v ..\test.c -o ..\test.obj

But when I use the LINKer:
Code: [Select]
link /OUT:..\test.exe /NOLOGO /LIBPATH:"[truncated once more]\CSFML-2.0-rc\lib\msvc" /DEFAULTLIB:csfml-window /DEFAULTLIB:libcmt /DEFAULTLIB:csfml-main /DEFAULTLIB:csfml-system ..\test.obj /VERBOSE

I get:
Code: [Select]
test.obj : error LNK2019: unresolved external symbol _sfWindow_Create referenced in function _main
..\test.exe : fatal error LNK1120: 1 unresolved externals

Any ideas what exactly I might be doing wrong?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: unresolved external symbol _sfWindow_Create
« Reply #1 on: July 03, 2012, 11:12:58 pm »
Quote
/DEFAULTLIB:csfml-main /DEFAULTLIB:csfml-system
That's not how you're supposed to link libraries. Just put them on the linker command line with no specific switch.
Laurent Gomila - SFML developer

FarTreX

  • Guest
Re: unresolved external symbol _sfWindow_Create
« Reply #2 on: July 03, 2012, 11:25:41 pm »
Quote
/DEFAULTLIB:csfml-main /DEFAULTLIB:csfml-system
That's not how you're supposed to link libraries. Just put them on the linker command line with no specific switch.
I tried it now and it appears to be doing the exact same thing. Failing as well.

Still am absolutely positive that it's my fault and that it is something minor and stupid, though.

EDIT: LINK is doing its job, because everything works with sfWindow_Create() commented out.
« Last Edit: July 03, 2012, 11:33:47 pm by FarTreX »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: unresolved external symbol _sfWindow_Create
« Reply #3 on: July 04, 2012, 08:09:28 am »
Quote
extern sfWindow* sfWindow_Create();
Why do you declare the function? It's declared in the CSFML headers.

Quote
LINK is doing its job, because everything works with sfWindow_Create() commented out.
But it fails with any other CSFML function, right?
Laurent Gomila - SFML developer

FarTreX

  • Guest
Re: unresolved external symbol _sfWindow_Create
« Reply #4 on: July 04, 2012, 10:39:42 am »

Quote
Quote
extern sfWindow* sfWindow_Create();
Why do you declare the function? It's declared in the CSFML headers.
If I don't, it gives me warnings. Doesn't work as well with that line deleted.

Quote
Quote
LINK is doing its job, because everything works with sfWindow_Create() commented out.
But it fails with any other CSFML function, right?
Yup. Seems to fail only with functions. Could it be the compiler or me compiling it wrong?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: unresolved external symbol _sfWindow_Create
« Reply #5 on: July 04, 2012, 12:04:59 pm »
Quote
If I don't, it gives me warnings.
Which ones?
By the way, your own declaration is wrong, the parameters are missing.
Laurent Gomila - SFML developer

FarTreX

  • Guest
Re: unresolved external symbol _sfWindow_Create
« Reply #6 on: July 04, 2012, 12:34:59 pm »
Quote
Quote
If I don't, it gives me warnings.
Which ones?

This:
Code: [Select]
implicit declaration of function 'sfWindow_Create' is invalid in C99
(Don't think I should care about this one)

and this:
Code: [Select]
incompatible integer to pointer conversion assigning to 'sfWindow *' (aka 'struct sfWindow *') from 'int'

Quote
By the way, your own declaration is wrong, the parameters are missing.

But when I add the parameters, it says that I'm passing them.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: unresolved external symbol _sfWindow_Create
« Reply #7 on: July 04, 2012, 12:45:19 pm »
Which version of CSFML are you using?
Laurent Gomila - SFML developer

FarTreX

  • Guest
Re: unresolved external symbol _sfWindow_Create
« Reply #8 on: July 04, 2012, 01:39:19 pm »
Quote
Which version of CSFML are you using?
2.0-rc, the 'official' one (don't know if it's the correct term).

The latest one on GitHub doesn't compile (some days... :D).

EDIT: It's just the graphics lib that doesn't compile, gives one error:
Code: [Select]
unresolved external symbol "public: static struct sf::Shader::CurrentTextureType sf::Shader::CurrentTexture"
(?CurrentTexture@Shader@sf@@2UCurrentTextureType@12@A)
referenced in function _sfShader_setCurrentTextureParameter
« Last Edit: July 04, 2012, 01:44:06 pm by FarTreX »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: unresolved external symbol _sfWindow_Create
« Reply #9 on: July 04, 2012, 01:48:56 pm »
Quote
2.0-rc
Names have changed, all functions are lowerCamelCase now. So for example it's sfWindow_create.

Quote
It's just the graphics lib that doesn't compile, gives one error
You mean, with the latest sources?
Laurent Gomila - SFML developer

FarTreX

  • Guest
Re: unresolved external symbol _sfWindow_Create
« Reply #10 on: July 04, 2012, 02:02:30 pm »
Quote
Names have changed, all functions are lowerCamelCase now. So for example it's sfWindow_create.
Wow, just wow. It works. Thank you very much!

Quote
You mean, with the latest sources?
Yes.

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: unresolved external symbol _sfWindow_Create
« Reply #11 on: May 18, 2013, 03:54:02 pm »
How did you get it to work? Because I get undefined reference to sfWindow_create even though I am linking against the library?
(Though I am sitting on Linux using GCC)
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

 

anything