• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
VCAlfox

How to import GLFW in eclipse C++ IDE

6 posts in this topic

Hi guys

I have a problem to correctly linking GLFW under eclipse Luna C/C++ IDE

I already read this post:

http://www.gamedev.net/topic/647428-glfw3-linker-errors/

I tried his solution

If you are trying to link the static version of the library, libglfw3.a, you have to link gdi32 in this order.

  1. libglfw3.a
  2. gdi32
  3. opengl32

If you are linking in the dynamic link version of the library, glfw3dll.a, you shouldn't need to link gdi32.

 

 

but I received this error:

cannot find -llibglfw3.a              C/C++ Problem

So I changed libglfw3.a with the entire path. But I still receive the same error:

cannot find -lC:\Users\Alfonso-PC\workspace\ProvaGLFW\libglfw3.a    C/C++ Problem

Of corse I also include the .h folder under "Includes"

/ProvaGLFW/glfw/include

And the lib-mingw folder under "Library paths"

/ProvaGLFW/glfw/lib-mingw

How Can I solve this issue?

 


 

0

Share this post


Link to post
Share on other sites

Create a lib folder, add libglfw3.a to it. Add -Llib to linker commandline. Now you can add -lglfw3 -lgdi32 -lopengl32 (also to linker commandline)

Do the same with glew: -lglew32s

You really want glew, because the whole context creation & extension lookup thing in OpenGL is a disaster.

 

Here is an example:

LFLAGS  = -Llib/win32 -static -lglfw3 -lgdi32 -lglew32s -lopengl32

Edited by Kaptein
1

Share this post


Link to post
Share on other sites

Thanks for reply!

So I created the lib folder inside the project with libglfw.a and glew32.dll inside,

under windows cmd, I wrote this:

g++ -LC:\Users\Alfonso-PC\workspace\ProvaGLFW\lib -static -lglfw3 -lgdi32 -lglew32s -lopengl32
-IC:\Users\Alfonso-PC\workspace\ProvaGLFW\glew\include -IC:\Users\Alfonso-PC\workspace\ProvaGLFW\glfw\include ProvaGLFW.cpp

this give me the same error:


c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot find -lglew32s
collect2.exe: error: ld returned 1 exit status
Edited by Alfox
0

Share this post


Link to post
Share on other sites

That's because you put a .dll there, it's not static, in fact its dynamic: DLL = Dynamically linked library

(.dll is on linux shared objects: .so)

 

When you add libraries, you basically add an archive (AR archive) of objects that can be added to your binary. It's basically the same as not having a .dll along with your .exe file, and instead putting it all inside your .exe, which means you can feel more pro.

Doing it this way means you don't need to depend on external stuff, and if you do it right you can just send your friends your exe and it will just work.

Static linking isn't the solution to everything, but it's very nice when you get it to work and on windows its pretty much the way to go.

 

So, open the GLEW binary archive from glew website. Go to the windows folder and find libglew32s.lib

Rename it to libglew32s.a, then copy it to your lib folder. Bam.

 

 

EDIT: I couldn't find any precompiled binaries for libglew, so I'm just giving you mine

http://dm.fwsnet.net/libglew32s.a

 

It's for win32 (not 64bit)

Edited by Kaptein
1

Share this post


Link to post
Share on other sites

Hello!

Really thanks for you availability, I downloaded your .a and I put it in the /lib folder.

Now the error is changed.

C:\Users\ALFONS~1\AppData\Local\Temp\ccXaI1XL.o:ProvaGLFW.cpp:(.text+0x17): unde
fined reference to `glfwInit'
C:\Users\ALFONS~1\AppData\Local\Temp\ccXaI1XL.o:ProvaGLFW.cpp:(.text+0x51): unde
fined reference to `_imp__glewInit@0'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: C:\Users\A
LFONS~1\AppData\Local\Temp\ccXaI1XL.o: bad reloc address 0x0 in section `.ctors'

c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link
 failed: Invalid operation
collect2.exe: error: ld returned 1 exit status

this is my little main:

#include <iostream>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
using namespace std;

int main() {
	if( !glfwInit() )
	{
		cout << "fail init glfw" << endl; // prints Hello World!!!
		return -1;
	}

	if (glewInit() != GLEW_OK) {
		cout << "fail init glew" << endl; // prints Hello World!!!
			return -1;
		}
	cout << "Hello World!!!" << endl; // prints Hello World!!!

	return 0;
}

===========EDIT==============

My bad, I forgot the:

#define GLEW_STATIC

And I changed the compile command as follow

g++ -IC:\Users\Alfonso-PC\workspace\ProvaGLFW\glfw\include -IC:\Users\Alfonso-PC\workspace\ProvaGLFW\glew\include ProvaGLFW.cpp -LC:\Users\Alfonso-PC\workspace\ProvaGLFW\lib -static -lglfw3 -lgdi32 -lglew32s -lopengl32

Now it compiles: but give me a

Warning: corrupt .drectve at end of def file

and when I launch the a.exe the program (above) enter in the glewInit() "if" and always print

fail init glew
Edited by Alfox
0

Share this post


Link to post
Share on other sites

As for GLEW_STATIC just add -DGLEW_STATIC to commandline

Remember to make yourself a basic makefile, as it makes things really simple: make --> done.

In your case it would be mingw32-make instead of just make

 

I don't know the value of GLEW_OK, but this is what I do:

if (glewInit() != GLEW_OK)
{
    // nothing to do, just exit
    std::cout << "(glewInit() != GLEW_OK) this should never happen" << std::endl;
    return EXIT_FAILURE;
}

First I glfwInit(), then I open glfw window, then I glewInit()
Either way its not good because I believe glew creates a context, gets the pointers, then destroys it. This is bad practice, but it just happens to work. I don't really care as long as it works.
 
With that out of the way, at least your program runs now, even if you don't initialize glew.
I have a shitty window opener here if you need something to look at: https://github.com/fwsGonzo/library/blob/master/library/opengl/window.cpp
 
Btw. you need to get rid of those absolute paths in your call to g++ as there is no reason for them to be there. All that's required is for NetBeans (in your case) to set the current directory to your ProvaGLFW folder. It should do that automatically, and if it doesn't, uninstall it and install something else, like CodeLite.
In a normal scenario you would add -Iinc and -Llib.
Edited by Kaptein
1

Share this post


Link to post
Share on other sites

Hello!

I modified my program, as you suggest

First I glfwInit(), then I open glfw window, then I glewInit()

as follow.

#define GLEW_STATIC

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <GL/glew.h>
#include <GLFW/glfw3.h>
#include "TryClass.h"
using namespace std;

int main() {
	if( !glfwInit() )
	{
		cout << "fail init glfw" << endl; 
		return -1;
	}

	GLFWwindow* window = glfwCreateWindow( 1024, 768, "Window", NULL, NULL);

	if( window == NULL ){
		cout << "failed to open window" << endl;
		glfwTerminate();
		return -1;
	}
	glfwMakeContextCurrent(window);

	if (glewInit() != GLEW_OK) {
		cout << "fail init glew" << endl; 
		return -1;
	}
	glfwSetInputMode(window, GLFW_STICKY_KEYS, GL_TRUE);
	do{

		// Swap buffers
		glfwSwapBuffers(window);
		glfwPollEvents();

	}
	while( glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS &&
		glfwWindowShouldClose(window) == 0 );
	
	glfwDestroyWindow(window);
	glfwTerminate();
	return 0;
}

And add -DGLEW_STATIC in commandline

g++ -IC:\Users\Alfonso-PC\workspace\ProvaGLFW\glfw\include -IC:\Users\Alfonso-PC\workspace\ProvaGLFW\glew\include TryClass.cpp ProvaGLFW.cpp -LC:\Users\Alfonso-PC\workspace\ProvaGLFW\lib -static -lglfw3 -lgdi32 -lglew32s -lopengl32 -DGLEW_STATIC

Now I have a "nice" well-functioning black window happy.png

 

Thanks a lot!

now I'll search how to make a "make file"

Again Thanks

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0