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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - hatfarm

Pages: [1]
1
General / Re: Problem Linking when using Threads
« on: August 30, 2013, 09:35:05 pm »
Gah, I feel like an idiot.  I accidentally commented out "ADD_DEFINITIONS( -DSFML_STATIC )".  I just happened to see it when I went to look for that information.  Now it works fine... oops.

2
General / Re: Problem Linking when using Threads
« on: August 30, 2013, 02:32:57 am »
Here's the code, I thought it'd be best to just post it in case there's some way that's a problem.

LoadState::LoadState(BatE::MANAGER_PTR master_manager) : m_loadThread(&LoadState::loadFunc, this){
        m_sceneManager = master_manager;
}

void LoadState::init() {
        BatE::Camera *cam = m_sceneManager->createCamera("Ortho");
    cam->setProjection(glm::ortho(0.0f, float(m_windowWidth), float(m_windowHeight), 0.0f));
        m_sceneManager->addFontFromFile("LibSans44","LiberationSans-Bold.ttf", 44);
        m_sceneManager->addTextToFont("LibSans44", "Loading", "Loading...", 300, 300, true, glm::vec4(0.0, 1.0, 0.0, 1.0));
    m_sceneManager->addTextToFont("LibSans44", "Secs", "0", 300, 344, true, glm::vec4(1.0, 0.0, 0.0, 1.0));
        m_sceneManager->connectCameraToTextScene("LibSans44", "Ortho");
    m_ballsScene = m_sceneManager->add2dScene("Balls");
    m_loadingDone = false;
    m_loadThread.launch();
}

void LoadState::loadFunc(){
    sf::Context context;
    int ms = 100;
    m_ballsScene->addImageFromFile("BlackBall", "black.png");
    sf::sleep(sf::milliseconds(ms));
    m_ballsScene->addImageFromFile("BlackBall", "blue.png");
    sf::sleep(sf::milliseconds(ms));
    m_ballsScene->addImageFromFile("BlackBall", "green.png");
    sf::sleep(sf::milliseconds(ms));
    m_ballsScene->addImageFromFile("BlackBall", "light_blue.png");
    sf::sleep(sf::milliseconds(ms));
    m_ballsScene->addImageFromFile("BlackBall", "purple.png");
    sf::sleep(sf::milliseconds(ms));
    m_ballsScene->addImageFromFile("BlackBall", "red.png");
    sf::sleep(sf::milliseconds(ms));
    m_ballsScene->addImageFromFile("BlackBall", "white.png");
    sf::sleep(sf::milliseconds(ms));
    m_ballsScene->addImageFromFile("BlackBall", "yellow.png");
    sf::sleep(sf::milliseconds(ms));
    sf::Lock lock(m_doneMutex);
    m_loadingDone = true;
}
 

Thanks again for any help anyone can give.

3
General / Problem Linking when using Threads
« on: August 30, 2013, 02:28:22 am »
Hello all, I wasn't sure if I should put this here or in the System forum, but since this isn't a problem with the Thread class so much as linking, I decided it should go here.  The problem is that I'm trying to load resources from a separate thread, I've read a lot of the posts here and I think I have a working implementation, but I get a linking error when I try to build.  Here's the error:

ballswindow.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Thread::~Thread(void)" (__imp_??1Thread@sf@@QAE@XZ) referenced in function "public: __thiscall LoadState::~LoadState(void)" (??1LoadState@@QAE@XZ)
3>loadstate.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Thread::~Thread(void)" (__imp_??1Thread@sf@@QAE@XZ)
3>loadstate.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: void __thiscall sf::Thread::launch(void)" (__imp_?launch@Thread@sf@@QAEXXZ) referenced in function "public: virtual void __thiscall LoadState::init(void)" (?init@LoadState@@UAEXXZ)
3>loadstate.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Context::~Context(void)" (__imp_??1Context@sf@@QAE@XZ) referenced in function "private: void __thiscall LoadState::loadFunc(void)" (?loadFunc@LoadState@@AAEXXZ)
3>loadstate.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall sf::Context::Context(void)" (__imp_??0Context@sf@@QAE@XZ) referenced in function "private: void __thiscall LoadState::loadFunc(void)" (?loadFunc@LoadState@@AAEXXZ)
3>C:\Users\hatfarm\GitHome\balls-to-the-walls\bin\Debug\Balls to the Walls.exe : fatal error LNK1120: 4 unresolved externals
3>

I'm building this in VS 2010 and I'm using CMake to put together my solution.  It worked fine until I decided to add a separate thread, so it's got to be something with that.  I've been using sf::Clock for a while now, so it's not a problem with the System library.  Anyone have any ideas?  I'm building against SFML 2.1.  If you need code, let me know and I'll get it here.  Thanks!

EDIT:  Also, here's my cmake for SFML:

IF(WIN32)
        set(SFML_STATIC_LIBRARIES TRUE)
        find_package(SFML 2.1 COMPONENTS main graphics window system REQUIRED)
        #set(GLEW_LIBRARIES $ENV{SFML_ROOT}/extlibs/libs-msvc/x86/glew.lib)
        #set(FREETYPE_LIBRARY $ENV{SFML_ROOT}/extlibs/libs-msvc/x86/freetype.lib)
ENDIF()

4
General / Re: Linking in Linux
« on: August 19, 2013, 05:59:46 am »
Gah!  I resolved the issues with my own linking, but now it's having problems with X11.  I've got this in my CMakeLists.txt files:

IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
    find_package(X11 REQUIRED)
    set(LIB_INCLUDES
        ${LIB_INCLUDES}
        ${X11_INCLUDE_DIR})
    set(LIB_LINKS
        ${LIB_LINKS} ${X11_LIBRARIES} )
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")

However, I get this error when it goes to link:

/usr/bin/ld: /home/hatfarm/SFML-2.1//lib/libsfml-window-s.a(WindowImplX11.cpp.o): undefined reference to symbol 'XGetWindowAttributes'
/usr/bin/ld: note: 'XGetWindowAttributes' is defined in DSO /usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/libX11.so so try adding it to the linker command line
/usr/lib/gcc/i686-linux-gnu/4.7/../../../i386-linux-gnu/libX11.so: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status

I have it print out LIB_LINKS and it shows exactly the libx11.so is found.  I know that LIB_LINKS and LIB_INCS are not the problem, because it doesn't complain about my library or OpenGL.  I know x11 is installed, because I can see that file, and I was able to build SFML.

Anyone have any ideas?

5
General / Re: Linking in Linux
« on: August 18, 2013, 09:57:46 pm »
Ah, that wasn't exactly the problem, but that lead me to figure out what the problem was.  The problem was that I copied the code from my executable's CMakeLists.txt into my library, and I didn't change the target name, so it was telling me that EXEC_NAME didn't have a build target, because it was supposed to be LIBR_NAME.  That resolved the linking with SFML issues, now I'm having issues where it's not able to link my library to my executable, but since that's not an SFML issue,  I'll keep that outta here.  Thanks for all your help everyone, much appreciated!

6
General / Re: Linking in Linux
« on: August 18, 2013, 04:03:46 am »
Alright, doing the example following, I added find_package(OpenGL REQUIRED) and I link it, but now I get an error in CMake that says:

Cannot specify link libraries for target
  "/usr/lib/i386-linux-gnu/libGLU.so" which is not built by this project.

When I try to link ${OPENGL_LIBRARIES}

Any ideas?

7
General / Re: Linking in Linux
« on: August 17, 2013, 11:11:31 pm »
The problem I'm having is that I already wrote my CMake files and didn't have any issues with Windows, but now with Linux I have to link all of these libraries separately.  I've looked through the SFML CMake files and I can't find where the variables are actually defined.  There is, for instance, the "OPENGL_INCLUDE_DIR" but I cannot find where that is defined.  I actually wrote a python script to search for that in all .txt files under the main SFML directory(and subdirectories) and was unable to find it.  Any recommendations?

8
General / Re: Linking in Linux
« on: August 16, 2013, 04:55:06 pm »
So, it's not linking any of the libraries that are needed by SFML.  Is there anywhere I can find the "-l"s that I need to build all of it.  Is there any easy way to do that in CMake?  Thanks for all your help.

9
General / Re: Linking in Linux
« on: August 16, 2013, 03:33:56 am »
I am linking statically, when I tried to use the so.2.1 files, it said that it didn't have a build option (or something like that) for those libraries.  How do I go about linking OpenGL then?  Would I be better off using the dynamic libraries?

10
General / Re: Linking in Linux
« on: August 16, 2013, 01:34:24 am »
Here's the tail end of the linking errors:

Quote
Texture.cpp:(.text+0x18be): undefined reference to `glGetTexImage'
/home/hatfarm/SFML-2.1//lib/libsfml-graphics-s.a(Texture.cpp.o): In function `sf::Texture::operator=(sf::Texture const&)':
Texture.cpp:(.text+0x1bec): undefined reference to `glDeleteTextures'
/home/hatfarm/SFML-2.1//lib/libsfml-graphics-s.a(TextureSaver.cpp.o): In function `sf::priv::TextureSaver::TextureSaver()':
TextureSaver.cpp:(.text+0x13): undefined reference to `glGetIntegerv'
/home/hatfarm/SFML-2.1//lib/libsfml-graphics-s.a(TextureSaver.cpp.o): In function `sf::priv::TextureSaver::~TextureSaver()':
TextureSaver.cpp:(.text+0x35): undefined reference to `glBindTexture'
/home/hatfarm/SFML-2.1//lib/libsfml-graphics-s.a(GLCheck.cpp.o): In function `sf::priv::glCheckError(char const*, unsigned int)':
GLCheck.cpp:(.text+0x34): undefined reference to `glGetError'
/home/hatfarm/SFML-2.1//lib/libsfml-graphics-s.a(GLCheck.cpp.o): In function `sf::priv::ensureGlewInit()':

The funny thing is, I specifically link to the glew.a library from the extlibs directory.  Any suggestion?  I didn't just sudo apt-get install sfml-dev because I think I read that 2.1 isn't there yet, and I'd like to be working off of 2.1.  Any help here would be greatly appreciated.

11
General / Linking in Linux
« on: August 15, 2013, 07:42:21 am »
Hey everyone.  I've been using SFML on Windows for the past 6 months, but I've been using CMake for my build system so that I could ensure that I could build it in Linux at least.  So, I've hit a milestone in my engine and I want to ensure that everything works in Linux as well, because I would like to be able to release Windows/Linux at least.  Anyway, I've fixed all the issues with my code, and I've even got the .a library linking, but unfortunately g++ is having issues linking the libraries linked to by SFML (for instance x11).  I build SFML with these directions:

http://sfmlcoder.wordpress.com/2011/08/16/building-sfml-2-0-with-make-for-gcc/

I added all of the libraries needed, but for whatever reason g++ isn't finding them when it goes to link my application.  Anyone have any ideas on how to possibly resolve this? 

Pages: [1]