Setting up OpenGL library on windows - c++

I'm totally new to OpenGL, so I'm trying to compile my application at home. At my university I have everything settle by my professor in the lab and there I use Linux. At home I'm using windows 8 with visual studio 2013.
I'm trying to build a sphere in my app which contain the includes below:
#include <GL/glut.h>
#include <math.h>
#include <iostream>
So, since it contains Glut.h I went to http://www.opengl.org/resources/libraries/glut/glut_downloads.php#2 to download the library and make it rock, but I had some problems.
I thought the windows version would come compiled and it didn't. The dlls are not inside the package as I expected to link them in my project properties so I tryed to use CMake to compile the glut but it didn't work. CMake returns to me the following log:
CMake Error: Cannot open file for write: C:/Program Files/Glut 3.7 Build/CMakeCache.txt.tmp
CMake Error: The source directory "C:/Program Files/Glut 3.7/glut-3.7" does not appear to contain CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
CMake Error: : System Error: No such file or directory
CMake Error: Unable to open cache file for save. C:/Program Files/Glut 3.7 Build/CMakeCache.txt
CMake Error: : System Error: No such file or directory
It says that the folder doesn't contain the CMake file.
My download link to glut (supposed to be windows, not sure cos of the error) is this http://www.opengl.org/resources/libraries/glut/glut37.zip
Normally I programm java, which I dont have so many headaches to setup the IDE..so take it easy please and now I ask:
What am I missing to make my OpenGL code run?

Your teacher should help you at the first place.
I would like to inform you that GLUT library was abandoned since 1998. Last version is [3.7].But you are lucky!
"freeglut" is alternative to the OpenGL Utility Toolkit (GLUT) library.
Everything you need is here, I recommend reading it all.
And to help you out, here you can find Windows binaries, look for link called: "Download freeglut 2.8.1-1 for MSVC".
After download, you must link the library folder, include folder and copy freeglut.dll to you project folder (inside Debug or Release folder). You can find dll files inside a bin folder.
And after that, you can call #include "GL/glut.h" with no problems.
Good luck!

It doesn't compile with CMake. Open a Visual Studio command prompt and type nmake in the top level directory of the glut source code.

At my university I have everything settle by my professor in the lab and there I use Linux. At home I'm using windows 8 with visual studio 2013.
Then the very first thing you absolutely must do is heading to your GPU maker's website, download the newest drivers from there and install them. That is, because the drivers installed by default with Windows 8 lack proper OpenGL functionality.
So, since it contains Glut.h
You mean glut.h – file names are case sensitive on most operating systems (Windows not among them). So for portability reasons you should care to write them with the proper spelling.
I went to http://www.opengl.org/resources/libraries/glut/glut_downloads.php#2 to download the library
The old GLUT library isn't maintained for over a decade. Use an alternative implementation like FreeGLUT and use that.
so I tryed to use CMake to compile the glut but it didn't work.
Okay, here you got no technical problem, but a lack of understanding. Essentially your brain got what I call "IDE rot": All those sugar coating and clicky-pointy action of IDEs obscure what actually is going on when a program is built. You'll have to bit the bullet there and understand how the interaction between the build control generators the build system the compiler and the linker works.
CMake is a build control generator: In CMake you describe the build dependencies of your program sources. From that CMake generates the actual build information for the build system used (GNU make and GCC on Linux; NMake and MSVC++ compiler on Windows for example).
Of course for CMake to work there must be an appropriate CMake configuration present. And in the case of GLUT that's definitely not there (the last official release of GLUT predates the first release of CMake.
Now you should really wonder: Why did you call "cmake" in the first place? I bet, because you always did it so far, or you read it somewhere, without even trying to understand what's going on.
What you did was folloing a Cargo Cult – it somehow resembles the actual process, it looks like it from the outside, but it doesn't yield results. Feynman's speech later coined the term Cargo Cult Programming; interesting enough I was using that term (consistently with its definition, just due to being familiar with Feynman's speech) without knowing that other people already had coined it in exactly the same way. Such a often it happens, that people will come up independently with the same term for it.
Normally I programm Java, which I don't have so many headaches to setup the IDE
Well, that's your problem right there. You only know how to click around in an IDE. Even when programming Java, with an IDE, you should get intimately familiar with the actual build process: Java compiler, JAR file creating, and so on.
What am I missing to make my OpenGL code run?
I bet not very much. It's a lack of understanding how the build process for software works and is controlled. You'll have to bite the bullet and learn that first. And for that I suggest you install Linux or FreeBSD, or at least Cygwin on your computer.
Windows is not a very good system to learn those things, because its been built around clicky GUIs. That is not to say that Windows was a bad operating system. It's juat that you want to have something you can experiment with and quickly go through various iterations of build tool option switches. A GUI can't give you that.

Related

Using Lapack Fortran in eclipse C++ project?

I've recently inherited a code that makes quite a lot of calls to Lapack functions, with this syntax :
F77_NAME(dgemm)(&trans,&trans,&n,&n,&n,&alpha,&D[0][0],&n,&P[0][0],&n,&beta,&temp[0][0],&n);
With the following includes :
#include <blas.h>
#include <lapacke.h>
On windows, and with eclipse CDT, the compilation works fine. I've installed Lapacke with an executable and I have had absolutely no problems with this library.
On Linux (and still with eclipse CDT), however, it's been difficult to say the least. I managed to make the include works, but I can't seem to do it for . I've managed to include but the syntax is then wrong and that would be quite long to change it all.
Do you have an idea how I could resolve this ? I've tried various thing, like linking an absolute path, but I can't find blas.h anywhere on my system despite all the libraries I installed through synaptic. Maybe I didn't install the right ones ?
Additionally, I've had some issues with github with this project. To make things short, I started developping on Windows, created the git project from there and went on. When I switched to Linux for testing purpose, I for some reason kept the windows configuration (So C:/Program Files includes, building a .exe ...), I guess I didn't set up the git properly (wouldn't be the first time) but I have no idea how to fix this ... I currently have two different git : one with the Windows configuration and the other with the Linux one .. Not ideal since we're two working on the project.
Thanks for your help !

How build harfbuzz without dependencies

I want build latest harfbuzz-ng library on Windows 7. But in build system by default I must go through long quest to gain: ragel, pkg-config, gtkdocize and other stuff. Even in the end if I get all what need for build system I get errors (sorry cannot say which concrete errors), last time I tried to build this library 2 month ago). Maybe on Linux system it is easy to get and build all this stuff but on Windows always something doesn't want to be compiled. Or the problem is that I don't find instructions which guide me on Windows, only Linux.
What I want to get is simple instructions how build only harfbuzz-ng with freetype dependency (and maybe add ICU) by MinGW compiler on Windows.
Thanks you very much.
For anyone reading this, have a look at harfbuzz.cc in the project which makes you able to use harfbuzz without any build system, just include it in one of your sources, no build system is required, define HB_NO_MT or even HB_TINY (which brings a minimal harfbuzz) if you don't use harfbuzz in multithread mode.
I don't know i this is the answer you are looking for. I am trying to work with Harfbuzz as well and did this through several attempts which did not work out for various reasons.
One (old) example you could use as a starter is: HarfBuzz static lib. The .lib-file generated works with UCDN and just needs this file plus a source for the Freetype-functions to provide the necessary FT_Face-parameter (i did this by compiling another .lib via the freetype-sourcecode (freetype.org/download.html).
But I am unsure if this will work out for the MinGW-compiler (you don't use VC++ as IDE do you??).
You may find of interest the MSYS2 build system. It is essentially a linux-style packaging system built on top of Windows(TM). You can download and install binary packages with simple commands (including automatic dependency solving). If you want to download a source package you can do that as well. http://msys2.github.io

How to convert a cmake project into a Visual Studio equivalent?

The situation is the following: I have the source code of one programm (lets call it programA) (written in C and C++), as well as the CMakeLists.txt and CTestConfig.cmake files. I already installed programA using CMake's graphical user interface and, as it is obvious, it worked. It created the .exe file (I'm working on Windows 7 OS).
The problem is that, right now, I've been asked to edit the program (and so, I must be able to edit the code and degugging it as changes are made). I also need to compile it but not in .exe anymore but in .dll so I can add it to a website we have.
I've read in forums that CMake can compile programA into a .dll if I need to, but as I would need to make some changes I consider that CMake debugging is not as useful and easy as using entirely VS. From the little I know from CMake language, the CMakeLists.txt is mainly used to check the OS of the user as well as adding some libraries in case they are not found.
I have to admit I have no idea in programming CMake directives, as I have been working with ASP.NET, C, C++ and C# mostly. Then, my idea is to try to work only in visual studio 2010 instead of using cmake as well, so once I have the program 'adapted' to VS and can be compiled just using VS, I'm ready to start my job. So the question I have is how can I perform the same task CMake did just using Visual Studio (Is there any way of implementing CMake directives in VS?), can VS compile by receiving as an argument something similar to that CMake.txt file (though it needs to be translated into another language)?
To skip the use of CMake I tried to copy the source code into a new project in VS. However as it does not use the CMake directives when compiling, it gives several errors, most of them related to the fact that some headers.h can't be found (cause they might be in a subfolder). And there are so many subfolders to add the paths to the predefined directories of search that it would take ages.
I'm sorry I can't be more precise in my explanation. I'm good at programming little projects on my own, but it's the first time I have to work on other's programm. Please don't hesitate to ask if anything was not properly understood
I would appreciate a lot any suggestion / advice /guidance you can give.
To make a dll, use add_library command and the SHARED keyword
add_library(mylib SHARED ${files})
this is easy with CMake, don't go back in visual that will be harder at the end
The Good News
Fortunately, cmake can generate VS Projects automaticaly for you (this tutorial s specific for OpenTissue, but Steps 1 to 3 should be the same for you).
The [not so] Bad News
Depending on the complexity of the project, VS Projects automaticaly generated by cmake can get pretty nasty, to the point of illegibility. It will, for example, hard link any library dependencies using the specific paths of your machine, so the project will most certainly not be portable across setups. In any case, that's the intended bahavior, because the primary idea of supporting this generator is simply making it work, thus allowing users to easily compile projects using MSVC, so there's not much you can do here. Nonetheless, it should work in your machine and will certainly be a great starting point for you, just create a project yourself from scratch copying the relevant parts out of the automatic generated version.

Setting up midiIO library on Windows

I've downloaded the midiIO library and in the readme it says:
edit the file Makefile.library and set the OSTYPE and OSSUBTYPE to match your hardware/os setup.
type "make library" to compile the library. It will be created as lib/libmidiio.a in unix.
edit the file Makefile.examples and set the OSTYPE and OSSUBTYPE to match your hardware/os setup.
Also, if you are using ALSA, then uncomment out the POSTFLAG to use the alsa library (-lasound).
type "make examples" to compile the example programs in the examples directory. The example programs will be place in the bin directory.
1 + 3 are fine but 2 + 4 are over my head. I've worked in a unix environment before and have used gcc with flags but I need to get this done in Windows. I typically use Visual Studio but don't know how to achieve this with that.. I've downloaded Dev-C++ if that's any use but I don't know what to do with the makefiles?
Ignore the makefiles and set up a fresh project in Visual C++. Make your target a static library (which will be a .lib file in Win32, not a .a file as in unix as you probably know). It is unlikely that the project will build out of the box, so you might have to deal with some compilation errors relating to unix-specific symbols. I took a quick look at the source code, and it looks fairly well-written, so I don't think you should have many problems building it directly in Windows.
Alternately, you could build the source using the real make tool in cygwin, but this means that you would need to distribute the cygwin library with your final product. This may or may not be more trouble than it's worth, especially if you are already using VC++ for the rest of your project's code.

Poppler library for QT4 on windows

I am making a program in which I will include datasheets of PIC processors. I now want to display these inside the QT program itself as a widget. I wanted to use poppler for this, but I am having a very hard time trying to get hold of these binaries! I can't seem to Cmake the poppler for QT4. Could anyone help me on how to make these libraries on Windows 7.
(I have never compiled/build anything yet on Windows, only Unix, I downloaded the CMAKE program, and tried to use this to generate it with the CMakeLists.txt file, but no luck so far.)
The best solution (because this way I could learn it myself, and never have this problem again) is a 'tutorial' on how to do it myself.
If not then giving me the libraries itself would be very much appreciated!
I'd wanted to point you to SumatraPDF, but it looks like they're not using poppler any more. You could have a look at the mupdf subdirectory though, it has MSVC makefiles for several libraries required for poppler. You might have some luck adapting them for building libpoppler itself.
You could also use Cygwin or MingW to get/build poppler.
You might have to take a look at this: Poppler: Displaying PDF Files with Qt
You can use the KDEWin installer to automatically get all the appropriate binaries for your machine. This is very useful and is the strategy used in many projects (including my CarMusTy, Carnatic Music Typesetting application).
Check out: http://www.winkde.org/pub/kde/ports/win32/installer/
It automatically downloads all the required dependencies when you ask it download the required binaries. And you can get the dlls suited for your particular compiler. (MSVC, MingW supported)
Also you can get the source code for poppler. KDEWin supports versions, so you can get the latest version binaries or any previous version you like.
Check out http://windows.kde.org/ for more details.
All the best
Gopalakrishna Palem
Creator of CFugue and CarMusTy
http://gpalem.web.officelive.com/