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

Author Topic: Makefile & MinGW problems  (Read 4031 times)

0 Members and 1 Guest are viewing this topic.

GregC

  • Newbie
  • *
  • Posts: 3
    • View Profile
Makefile & MinGW problems
« on: August 13, 2009, 12:38:17 pm »
Hi,

I have a problem compiling the Clock tutorial under MinGW, while under Linux it compiles nicely. I'm using a Makefile so developers can use different IDEs under Linux or Windows. But even without an IDE, using make from the command line, I get errors. I'm using the following simple makefile:
Code: [Select]
CC=g++
CFLAGS=-Wall
SFMLFILES=-I "../SFML-1.5/include" -L "../SFML-1.5/lib/mingw"

all: game

game: main.cpp
$(CC) $(CFLAGS) $(SFMLFILES) -o game.exe -lsfml-system main.cpp


The include and library files are the appropriate relative positions (but I have tried putting them explicitly in the MinGW's dirs and changing the Makefile, no improvement). I get a bunch of errors:
Code: [Select]
undefined reference to `sf::Clock::Clock()'
undefined reference to `sf::Clock::GetElapsedTime() const'
undefined reference to `sf::Clock::GetElapsedTime() const'


Both the include files and the library files are found, because if I break their names in the Makefile, I get not found errors. If I comment out all references to SFML in the code but keep the include clause, the program compiles nicely.

Any clues?

Imbue

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Makefile & MinGW problems
« Reply #1 on: August 13, 2009, 04:36:51 pm »
In the tutorials, time is listed under the windows package. Maybe try that?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Makefile & MinGW problems
« Reply #2 on: August 13, 2009, 05:20:22 pm »
No, sf::Clock belongs to the system module. The "time" tutorial is more a generic discussion about time handling rather than a sf::Clock reference, that's why it is under "window".
Laurent Gomila - SFML developer

GregC

  • Newbie
  • *
  • Posts: 3
    • View Profile
Makefile & MinGW problems
« Reply #3 on: August 14, 2009, 09:43:51 am »
I tried downloading Code::Blocks and rebuilding the library. That worked, but the tutorial still doesn't compile for me :(

A question: where do I have to put SFML_DYNAMIC to use the DLLs - in the makefile, or somewhere in the code?

Edit: I found in the tutorial where to put it in Code::Blocks, no change, still getting 'undefined reference' errors. But I would still like to know where to put SFML_DYNAMIC when I'm not using Code::Blocks..

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Makefile & MinGW problems
« Reply #4 on: August 14, 2009, 10:33:42 am »
Maybe the arguments provided to g++ in your makefile are not in the correct order?
You should also try to invoke the compiler and the linker with two separate commands. You should find more explanations in any beginners tutorial about makefiles ;)

Quote
I would still like to know where to put SFML_DYNAMIC when I'm not using Code::Blocks

Code: [Select]
CFLAGS=-Wall -DSFML_DYNAMIC
Laurent Gomila - SFML developer

GregC

  • Newbie
  • *
  • Posts: 3
    • View Profile
Makefile & MinGW problems
« Reply #5 on: August 14, 2009, 10:52:40 am »
Quote from: "Laurent"
Maybe the arguments provided to g++ in your makefile are not in the correct order?

Oh wow, that worked!

I tried moving them around and at a certain point, it started working.. I had no clue this could be the problem, I assumed that the parameter order was correct after it had compiled successfuly on Linux.

Thank you very much, for helping out a C# & Java spoiled coder :)