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

Author Topic: SFML in Netbeans  (Read 20004 times)

0 Members and 1 Guest are viewing this topic.

Niall

  • Newbie
  • *
  • Posts: 18
    • View Profile
SFML in Netbeans
« on: January 19, 2011, 04:56:31 pm »
Hey guys, I'm trying to get SFML set up in Netbeans 6.9.1 for Windows. I found this and could follow it to a degree but it's for Linux and things seem to work a bit differently.

Currently I've linked things up as in that blog post and defined the _WIN32 preprocessor token, having a simple setup like this:

Code: [Select]
#define _WIN32
#include <iostream>

using namespace std;

int main() {
    return 0;
}


Produces these errors: http://pastebin.com/heTw6i18

Does anybody know how to fix this, if it's even possible?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML in Netbeans
« Reply #1 on: January 19, 2011, 05:13:59 pm »
You must tell g++ where to find SFML libraries with the -L option.
Quote
g++ ... -Lpath/to/SFML/lib -lsfml-system etc.
Laurent Gomila - SFML developer

Niall

  • Newbie
  • *
  • Posts: 18
    • View Profile
SFML in Netbeans
« Reply #2 on: January 21, 2011, 04:28:41 pm »
What should I be linking to? -lsfml-system and the others don't exist in lib/ but it's looking for them somewhere - do I just link to the sfml-system.a files and so on? Also, should I be putting these command line additional options in the C++ Compiler section or Linker?
Sorry, a bit new to all of this.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML in Netbeans
« Reply #3 on: January 21, 2011, 04:31:25 pm »
Quote
-lsfml-system and the others don't exist in lib/ but it's looking for them somewhere - do I just link to the sfml-system.a files and so on?

-lsfml-system tells the linker to look for the libsfml-system.a file.

Quote
Also, should I be putting these command line additional options in the C++ Compiler section or Linker?

This is linker stuff.
Laurent Gomila - SFML developer

Niall

  • Newbie
  • *
  • Posts: 18
    • View Profile
SFML in Netbeans
« Reply #4 on: January 23, 2011, 01:31:51 am »
Okay, I've changed the command line options to g++ -LC:\SFML\Lib -lsfml-system and I've added the sfml-system.a file to the libraries. At first it compiled fine, then I added the #include <SFML/System.hpp> line and got the error "Main.cpp:3:27: SFML/System.hpp: No such file or directory" - which is odd as it's in my include configuration and when I typed #include <SFML/ it popped up with the possible files.
Then, I removed that line completely and tried to compile it again (expecting it to work again) and I was greeted by "g++: g++: No such file or directory".

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
SFML in Netbeans
« Reply #5 on: January 23, 2011, 07:40:14 pm »
The command line shouldn't be «-LC:\...» (without g++)  :?:
SFML / OS X developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML in Netbeans
« Reply #6 on: January 23, 2011, 09:30:15 pm »
Quote from: "Hiura"
The command line shouldn't be «-LC:\...» (without g++)  :?:

Nop. -L is an option of gcc.

I don't know Netbeans at all, so I can't help more, sorry.
Laurent Gomila - SFML developer

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
SFML in Netbeans
« Reply #7 on: January 23, 2011, 10:11:21 pm »
I meant the same command line but without the leading «g++». Because I get the same error if I type
Code: [Select]
$g++ g++
SFML / OS X developer

Niall

  • Newbie
  • *
  • Posts: 18
    • View Profile
SFML in Netbeans
« Reply #8 on: January 25, 2011, 11:40:26 pm »
Quote from: "Hiura"
I meant the same command line but without the leading «g++». Because I get the same error if I type
Code: [Select]
$g++ g++

Do you mean I should try the -L command without the "g++" preceding it? Doing that produces the "cannot find -lsfml-system" error.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
SFML in Netbeans
« Reply #9 on: January 26, 2011, 09:32:05 am »
Yes that was what I meant. Now I think your current problem is that you haven't install correctly SFML lib files into C:\SFML\Lib.
SFML / OS X developer

Niall

  • Newbie
  • *
  • Posts: 18
    • View Profile
SFML in Netbeans
« Reply #10 on: January 29, 2011, 01:14:31 am »
Quote from: "Hiura"
Yes that was what I meant. Now I think your current problem is that you haven't install correctly SFML lib files into C:\SFML\Lib.

Hmm, I'm not sure where I could have slipped up - I added C:\SFML\include to the includes, added sfml-system in the libraries and currently my command stands at "-LC:\SFML\lib -lsfml-system" but it's still giving me those errors. I wonder if anyone's ever successfully gotten SFML running in Netbeans before..

Annuate

  • Newbie
  • *
  • Posts: 1
    • View Profile
SFML in Netbeans
« Reply #11 on: February 01, 2011, 04:49:58 pm »
Quote
I wonder if anyone's ever successfully gotten SFML running in Netbeans before..


Not sure I'm having some problems with this in netbeans as well. Though I am using linux(ubuntu) and I think you are using windows? I've tried to follow the instructions at http://trevoke.net/blog/2009/03/08/howto-sfml-with-netbeans/ but cant seem to get it working. Though I think I have made it a bit farther as in I can get my files to compile with the include and and g++ linker options. But once I try to use some of the code from the tuts it complains and fails; reason of undefined refs. Its a shame since I generally enjoy using netbeans. Funny thing is I can get it working if I just use the command-line with g++ so I'm assuming its something wacky perhaps in netbeans itself or I'm reading the options wrong ;/. Either way I'll continue on my quest to get this to work!

Travnick

  • Newbie
  • *
  • Posts: 12
    • View Profile
SFML in Netbeans
« Reply #12 on: February 02, 2011, 01:51:00 pm »
In my opinion you should copy/move/install your SFML libraries into the Cygwin library folder, and after that everythink will be working fine. The include dir from SFML also should be copied into the Cygwin include directory.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
SFML in Netbeans
« Reply #13 on: February 02, 2011, 01:59:43 pm »
Quote
In my opinion you should copy/move/install your SFML libraries into the Cygwin library folder, and after that everythink will be working fine. The include dir from SFML also should be copied into the Cygwin include directory.

This is not the right thing to do, in my opinion. Libraries should be installed to a clean location, and then the environment/compiler variables must be updated accordingly. There's no need to copy things into the cygwin/mingw/whatever install folder.
Laurent Gomila - SFML developer

Travnick

  • Newbie
  • *
  • Posts: 12
    • View Profile
SFML in Netbeans
« Reply #14 on: February 02, 2011, 02:03:08 pm »
for me it was te easiest way.

another way to link libraries in netbeans:
(project)->properties->build->linker->libraries->add library file

 

anything