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

Author Topic: Trouble with Self-Compiled Static Libs  (Read 1679 times)

0 Members and 1 Guest are viewing this topic.

Noegddgeon

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • Soundcloud
Trouble with Self-Compiled Static Libs
« on: July 15, 2014, 05:24:08 am »
Hi all!

Thought I'd give SFML another go (it's been a while!). However, I'm running into a stumbling block; whereas I've gotten it to work fine on my Mac, it's been troublesome on Windows. My issue for a long time was that I was just using the wrong compiler version of GCC, so I couldn't compile with the distributed binaries; after tinkering and switching to using CMake to make my own static libraries, I'm finding that I'm still having difficulties getting things to work; here is the simple example I've been trying to compile:

#define SFML_STATIC
#include <SFML/Graphics.hpp>

int main()
{
    sf::RenderWindow window(sf::VideoMode(800, 600), "My window");

    while (window.isOpen())
    {
        sf::Event event;

        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
            {
                window.close();
            }
        }

        window.clear(sf::Color::Black);

        window.display();
    }

    return 0;
}
 

And here is the output of my CMake-made static library compilation trial:

Code: [Select]
Z:\sfml_dev>g++ > error.log main.cpp -o main.exe -Ic:/sfml/include -Lc:/sfml/lib
 -lsfml-window-s -lsfml-graphics-s -lsfml-system-s -DSFML_STATIC
main.cpp:1:0: warning: "SFML_STATIC" redefined [enabled by default]
 #define SFML_STATIC
 ^
<command-line>:0:0: note: this is the location of the previous definition
c:/sfml/lib/libsfml-graphics-s.a(RenderWindow.cpp.obj):RenderWindow.cpp:(.text+0
x304): undefined reference to `glReadPixels@28'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x10e): undefined reference to `glClearColor@16'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x11d): undefined reference to `glClear@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x3f0): undefined reference to `glMatrixMode@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x3f6): undefined reference to `glPopMatrix@0'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x402): undefined reference to `glMatrixMode@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x408): undefined reference to `glPopMatrix@0'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x414): undefined reference to `glMatrixMode@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x41a): undefined reference to `glPopMatrix@0'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x41f): undefined reference to `glPopClientAttrib@0'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x4ff): undefined reference to `glViewport@16'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x50e): undefined reference to `glMatrixMode@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x527): undefined reference to `glLoadMatrixf@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x534): undefined reference to `glMatrixMode@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x600): undefined reference to `glBlendFunc@8'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x628): undefined reference to `glBlendFunc@8'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x650): undefined reference to `glBlendFunc@8'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x678): undefined reference to `glBlendFunc@8'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x6a5): undefined reference to `glDisable@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x6b2): undefined reference to `glDisable@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x6bf): undefined reference to `glDisable@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x6cc): undefined reference to `glDisable@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x6f3): undefined reference to `glMatrixMode@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x700): undefined reference to `glEnableClientState@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x70d): undefined reference to `glEnableClientState@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x71a): undefined reference to `glEnableClientState@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x746): undefined reference to `glLoadMatrixf@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x808): undefined reference to `glPushClientAttrib@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x815): undefined reference to `glPushAttrib@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x822): undefined reference to `glMatrixMode@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x828): undefined reference to `glPushMatrix@0'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x834): undefined reference to `glMatrixMode@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x83a): undefined reference to `glPushMatrix@0'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x846): undefined reference to `glMatrixMode@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x84c): undefined reference to `glPushMatrix@0'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
xa0c): undefined reference to `glVertexPointer@16'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
xa36): undefined reference to `glColorPointer@16'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
xa60): undefined reference to `glTexCoordPointer@16'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
xa86): undefined reference to `glDrawArrays@12'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
xaf7): undefined reference to `glLoadMatrixf@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
xb4b): undefined reference to `glLoadMatrixf@4'
c:/sfml/lib/libsfml-graphics-s.a(RenderTarget.cpp.obj):RenderTarget.cpp:(.text+0
x427): undefined reference to `glPopAttrib@0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: c:/sfml/li
b/libsfml-graphics-s.a(RenderTarget.cpp.obj): bad reloc address 0x6 in section `
.text.startup'
collect2.exe: error: ld returned 1 exit status

I appreciate your time and look forward to getting this finally resolved! :]

Best,
Colton
Whether you think you can or you can't, you're right.

Noegddgeon

  • Jr. Member
  • **
  • Posts: 53
    • View Profile
    • Soundcloud
Re: Trouble with Self-Compiled Static Libs
« Reply #1 on: July 15, 2014, 05:30:04 am »
Okay, so I actually got it to work; the issue was that I was linking in window before graphics and in reading other posts about linking, that seems to be a common mistake.

However..... now the executable just stops working as soon as the program starts. Any idea what that might be caused by? For what it's worth, I also removed the redundant #define SFML_STATIC. If this is of any help, here's what the dialog spits out in Additional Details:

Code: [Select]
Problem Event Name: APPCRASH
  Application Name: main.exe
  Application Version: 0.0.0.0
  Application Timestamp: 0326f0d0
  Fault Module Name: main.exe
  Fault Module Version: 0.0.0.0
  Fault Module Timestamp: 0326f0d0
  Exception Code: c0000005
  Exception Offset: 0005c57f
  OS Version: 6.1.7600.2.0.0.256.1
  Locale ID: 1033
  Additional Information 1: 0a9e
  Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
  Additional Information 3: 0a9e
  Additional Information 4: 0a9e372d3b4ad19135b953a78882e789


EDIT (7/17/14):

So I went ahead and tried running it through gdb to see what the issue was; it spat out this for me:

Code: [Select]
Starting program: Z:\sfml_dev/main.exe
[New Thread 6384.0xff8]

Program received signal SIGSEGV, Segmentation fault.
0x0045c56b in sf::String::String(char const*, std::locale const&) ()

It appears (based also on my research into similar issues with related threads) that the issue is with the string that's being passed into the RenderWindow constructor; I tried adjusting the above code to have a declared sf::String that's initialized as sf::String title("My window"); that's then passed into the constructor based on someone who said that had fixed it for them, but I still get the same crash with similar gdb output. My GCC version is 4.8.1, and I'm running static libraries that I have compiled myself from SFML with that compiler. Hope this may be prove useful in determining the problem a bit more.

Thanks so much for your time and help!

Best,
Colton
« Last Edit: July 17, 2014, 07:57:14 am by Noegddgeon »
Whether you think you can or you can't, you're right.