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

Author Topic: Static Library Linking  (Read 1816 times)

0 Members and 1 Guest are viewing this topic.

JollyRoger

  • Newbie
  • *
  • Posts: 17
    • View Profile
Static Library Linking
« on: April 01, 2010, 10:11:45 pm »
I'm trying to create a Static Library (.a) based on SFML with Code::Blocks.  I've created a simple library to test, but even that isn't working.

Here is the code of the library:
Code: [Select]

// File Test.h
#ifndef TEST_H
#define TEST_H

class Test
{
    public:
        Test( );
        void Function( );
};

#endif

// File Test.cpp
#include <iostream>
#include <SFML/System.hpp>
#include "Test.h"

Test::Test( )
{
    std::cout << "Test::Test( ) " << sf::Randomizer::Random( 0, 10 ) << std::endl;
}

void Test::Function( )
{
    std::cout << "Test::Function( ) " << sf::Randomizer::Random( 50, 100 ) << std::endl;
}


I then add libsfml-system-s.a into the library using ar.
Code: [Select]

ar x libsfml-system-s.a
ar rs libStaticSFMLTest.a *.o

I'm pretty sure it works, since the file size of the library increases, after adding SFML System.

When I try to compile a project using the new library, I get linker errors:
Code: [Select]

C:\Documents and Settings\Eternal Warrior\My Documents\CodeBlocksProjects\StaticSFMLTest\libStaticSFMLTest.a(Test.o):Test.cpp:(.text+0x2f)||undefined reference to `sf::Randomizer::Random(int, int)'|


I'm sure I'm doing something wrong, but I can't figure out what.  Any help is appreciated.

 

anything