How to link GLEW and GLFW and OpenGL to MingW's g++ - c++

I am doing a course on OpenGL.
So I have run my project in Visual Studio 2019 and it works.
What I needed to do in Visual Studio was:
Add GLEW's and GLFW's additional include directories. (when you download the libraries it is simply the location of the include file)
Add GLEW's and GLFW's additional library directories. (lib folder locations)
Add the additional dependencies. (opengl32.lib, glew32.lib, glfw3.lib)
Copy and paste GLEW.dll into the project files, next to main.cpp.
And I run my code and it works.
But I don't want to use Visual Studio 2019, I would much rather work in Notepad++ or VSCode, what I really want is to just make a project out of pure notepad and compile it with the new Windows Terminal.
My question:
How can I do all of the things I did in visual studio 2019 from Power Shell?
I heard that MingW comes with its own power shell or command prompt, I imagine I need to find it and give it some commands to link everything up before I start coding.
Where do I find MingW's power shell equivalent and what commands do I need to type?
I have been stuck on this for ages now and could not find any information about it online. (except for what -L and -l does, but these are not power shell commands)

The MingGW and mingw-w64
compilers are Windows commandline tools. They are Windows ports of (some of)
the GCC compilers. tdm-gcc is yet another choice.
Commandine tools for any operating
system don't need their own shell. You can run them in any shell you've got
on that operating system. On Windows today
you have a choice of at least PowerShell and the old CMD shell.
The MinGW project provides, as well as its GCC toolchain, a minimal unix-like
environment for Windows called MSYS, which includes a shell. You don't need
MSYS to run the compiler.
As long as the GCC tools can be located in
the value of the PATH environment variable that is operative in
the shell at compiletime, then you run the compiler at the shell prompt:
>gcc [options...]
>g++ [options...]
the same way it is run on any operating system. If you want to work with a GCC toolchain then the question:
How can I do all of the things I did in visual studio 2019 from Power Shell?
is simply the question, How do you run GCC? That's a question of
sweeping generality. You need to study relevant books
and documentation
Very sketchily, if you want to compile and link a C++ program that has source files main.cpp and other.cpp and depends on libraries
foo and bar that have their C++ APIs defined in header files and are implemented in DLLs,
you will do it with commands of the following form:
To compile the source files to object files:
>g++ -c -o main.obj main.cpp -I/path/to/foo/header/files -I/path/to/bar/header/files [any other compilation options....]
>g++ -c -o other.obj other.cpp -I/path/to/foo/header/files -I/path/to/bar/header/files [any other compilation options....]
To link the object files and libraries to make an excutable program:
>g++ -o prog main.obj other.obj -L/path/to/foo_dll -L/maybe/a/different/path/to/bar_dll -lfoo -lbar [any other linkage options...]
And if all that is successful then the program will be prog.exe and you can run it:
>prog
just like you ran g++, provided that foo.dll and bar.dll can be found at runtime by the OS loader's DLL search protocol
As I think you appreciate, in real life nobody builds programs by typing the all the
commands in a shell except for instructional purposes. They use a build system or an IDE to automate it. But it is true that building programs though the medium of a build system or IDE presents fewer difficulties if you do it with a basic grasp of how the tools behind it work.

Related

exe file won't run on other devices [duplicate]

I have been working on a project (a game to be specific) and I feel that I should start over with different libraries. So when doing this I reinstalled Code::Blocks and setup my new libraries and includes.
But as of now Im having a problem starting u[ my new project to test if all of the includes work. This problem is: libstdc++-6.dll was not found. At first i wondered if I could just find this file online, but its nowhere to be found(or at least the many places I have searched...) Soon after, I tried loading up my old project, and the same problem happened again(wierd... ._.) I was thinking its maybe my compiler, so I used my older compiler and it did the same thing! At this moment I held the problem off for tomorrow(which is today)
So my question is: If anyone else had this problem, how would you solve it?
Im using Code::Blocks with MinGW as the compiler on Windows Vista 32 bit.
*****EDIT*****
Here are the Build options in my project. Note that these are the settings in the Project, not the global compiler:
In (project name)->Compiler settings->Otehr options:
(I use // to seperate the commands)
-mthreads//
-fmessage-length=0//
-fexceptions//
-fident//
In (project name)->Compiler settings->#define:
WIN32//
_WINDOWS//
In (project name)->Linker settings->Other linker options:
-static-libstdc++//
-static-libgcc//
-Wl,--enable-auto-image-base//
-Wl,--add-stdcall-alias//
-Wl,--enable-auto-import//
In linker->link libraries i have various links to files with a .a extension, these files include Bullet PHysics, Ogre3D, and SFML
In the search directories i have links to the MinGW/bin, and the MinGW/lib directories, along with other links to different libraries.
My Compiler is MinGW, a GNU GCC compiler for windows 32 bit. and the IDE is Codeblocks. Also note that in Debug and Release settings on the project, there is nothing.
Most of these setings are also pieces that i got from the Ogre3D Application setup tutorial if that is of any help.
If you are using MingW to compile C++ code on Windows, you may like to add the options -static-libgcc and -static-libstdc++ to link the C and C++ standard libraries statically and thus remove the need to carry around any separate copies of those. Version management of libraries is a pain in Windows, so I've found this approach the quickest and cleanest solution to creating Windows binaries.
As far as I know, this is the C++ Runtime Library. So it depends on the compiler you use to create your program (A new version will include some C++0x stuff, an older version will probably not for instance. It depends of the compiler and of its version).
If you use MinGW then you should use the libstdc++-6.dll found into the folder of this compiler. MinGW/bin folder should be the place to search for it on your computer.
If you copy this file in the same directory as your executable, it should be OK.
Simply removing libstdc++-6.dll.a \ libstdc++.dll.a from the mingw directory fixes this.
I tried using the flag -static-libstdc++ but this did not work for me.
I found the solution in: http://ghc.haskell.org/trac/ghc/ticket/4468#
This error also occurred when I compiled with MinGW using gcc with the following options:
-lstdc++ -lm, rather than g++
I did not notice these options, and added: -static-libgcc -static-libstdc++
I still got the error, and finally realized I was using gcc, and changed the compiler to g++ and removed -stdc++ and -lm, and everything linked fine.
(I was using LINK.c rather than LINK.cpp... use make -pn | less to see what everything does!)
I don't know why the previous author was using gcc with -stdc++. I don't see any reason not to use g++ which will link with stdc++ automatically... and as far as I know, provide other benefits (it is the c++ compiler after all).
useful to windows users who use eclipse for c/c++ but run *.exe file and get an error: "missing libstdc++6.dll"
4 ways to solve it
Eclipse ->"Project" -> "Properties" -> "C/C++ Build" -> "Settings" -> "Tool Settings" -> "MinGW C++ Linker" -> "Misscellaneous" -> "Linker flags" (add '-static' to it)
Add '{{the path where your MinGW was installed}}/bin' to current user environment variable - "Path" in Windows, then reboot eclipse, and finally recompile.
Add '{{the path where your MinGW was installed}}/bin' to Windows environment variable - "Path", then reboot eclipse, and finally recompile.
Copy the file "libstdc++-6.dll" to the path where the *.exe file is running, then rerun. (this is not a good way)
Note: the file "libstdc++-6.dll" is in the folder '{{the path where your MinGW was installed}}/bin'
I use Eclipse under Fedora 20 with MinGW for cross compile.
Use these settings and the program won't ask for libstdc++-6.dll any more.
Project type - Cross GCC
Cross Settings
Prefix: x86_64-w64-mingw32-
Path: /usr/bin
Cross GCC Compiler
Command: gcc
All Options:
-I/usr/x86_64-w64-mingw32/sys-root/mingw/include -O3
-Wall -c -fmessage-length=0
Includes: /usr/x86_64-w64-mingw32/sys-root/mingw/include
Cross G++ Compiler
Command: g++
All Options: -I/usr/x86_64-w64-mingw32/sys-root/mingw/include -O3
-Wall -c -fmessage-length=0
Includes: /usr/x86_64-w64-mingw32/sys-root/mingw/include
Cross G++ Linker
Command: g++ -static-libstdc++ -static-libgcc
All Options: -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib -L/usr/x86_64-w64-mingw32/sys-root/mingw/bin
Library search path (-L):
/usr/x86_64-w64-mingw32/sys-root/mingw/lib
/usr/x86_64-w64-mingw32/sys-root/mingw/bin
I just had this issue.. I just added the MinGW\bin directory to the path environment variable, and it solved the issue.
I placed the libstdc++-6.dll file in the same folder where exe file is generated.
You only need to add your "mingw-install-directory"/bin/ to your Path in your System environment variables ... that's it !!
I had same problem. i fixed it. i was using Codeblocks and i save my .cpp file on desktop instead of saving it in Codeblocks file where MinGW is located. So i copied all dll files from MinGW>>bin folder to where my .cpp file was saved.
You can also copy the dll files in the directory of your exe file
I had this problem too. I was compiling in command prompt and used the flag -static.
My command before:
"g++ test.cpp -o test.exe"
and afterwards:
"g++ test.cpp -o test.exe -static"
I had the same problem and I solved it by running the compiled exe as an administrator.

C++ windows executable compiled with Linux needs additional DLL [duplicate]

I have been working on a project (a game to be specific) and I feel that I should start over with different libraries. So when doing this I reinstalled Code::Blocks and setup my new libraries and includes.
But as of now Im having a problem starting u[ my new project to test if all of the includes work. This problem is: libstdc++-6.dll was not found. At first i wondered if I could just find this file online, but its nowhere to be found(or at least the many places I have searched...) Soon after, I tried loading up my old project, and the same problem happened again(wierd... ._.) I was thinking its maybe my compiler, so I used my older compiler and it did the same thing! At this moment I held the problem off for tomorrow(which is today)
So my question is: If anyone else had this problem, how would you solve it?
Im using Code::Blocks with MinGW as the compiler on Windows Vista 32 bit.
*****EDIT*****
Here are the Build options in my project. Note that these are the settings in the Project, not the global compiler:
In (project name)->Compiler settings->Otehr options:
(I use // to seperate the commands)
-mthreads//
-fmessage-length=0//
-fexceptions//
-fident//
In (project name)->Compiler settings->#define:
WIN32//
_WINDOWS//
In (project name)->Linker settings->Other linker options:
-static-libstdc++//
-static-libgcc//
-Wl,--enable-auto-image-base//
-Wl,--add-stdcall-alias//
-Wl,--enable-auto-import//
In linker->link libraries i have various links to files with a .a extension, these files include Bullet PHysics, Ogre3D, and SFML
In the search directories i have links to the MinGW/bin, and the MinGW/lib directories, along with other links to different libraries.
My Compiler is MinGW, a GNU GCC compiler for windows 32 bit. and the IDE is Codeblocks. Also note that in Debug and Release settings on the project, there is nothing.
Most of these setings are also pieces that i got from the Ogre3D Application setup tutorial if that is of any help.
If you are using MingW to compile C++ code on Windows, you may like to add the options -static-libgcc and -static-libstdc++ to link the C and C++ standard libraries statically and thus remove the need to carry around any separate copies of those. Version management of libraries is a pain in Windows, so I've found this approach the quickest and cleanest solution to creating Windows binaries.
As far as I know, this is the C++ Runtime Library. So it depends on the compiler you use to create your program (A new version will include some C++0x stuff, an older version will probably not for instance. It depends of the compiler and of its version).
If you use MinGW then you should use the libstdc++-6.dll found into the folder of this compiler. MinGW/bin folder should be the place to search for it on your computer.
If you copy this file in the same directory as your executable, it should be OK.
Simply removing libstdc++-6.dll.a \ libstdc++.dll.a from the mingw directory fixes this.
I tried using the flag -static-libstdc++ but this did not work for me.
I found the solution in: http://ghc.haskell.org/trac/ghc/ticket/4468#
This error also occurred when I compiled with MinGW using gcc with the following options:
-lstdc++ -lm, rather than g++
I did not notice these options, and added: -static-libgcc -static-libstdc++
I still got the error, and finally realized I was using gcc, and changed the compiler to g++ and removed -stdc++ and -lm, and everything linked fine.
(I was using LINK.c rather than LINK.cpp... use make -pn | less to see what everything does!)
I don't know why the previous author was using gcc with -stdc++. I don't see any reason not to use g++ which will link with stdc++ automatically... and as far as I know, provide other benefits (it is the c++ compiler after all).
useful to windows users who use eclipse for c/c++ but run *.exe file and get an error: "missing libstdc++6.dll"
4 ways to solve it
Eclipse ->"Project" -> "Properties" -> "C/C++ Build" -> "Settings" -> "Tool Settings" -> "MinGW C++ Linker" -> "Misscellaneous" -> "Linker flags" (add '-static' to it)
Add '{{the path where your MinGW was installed}}/bin' to current user environment variable - "Path" in Windows, then reboot eclipse, and finally recompile.
Add '{{the path where your MinGW was installed}}/bin' to Windows environment variable - "Path", then reboot eclipse, and finally recompile.
Copy the file "libstdc++-6.dll" to the path where the *.exe file is running, then rerun. (this is not a good way)
Note: the file "libstdc++-6.dll" is in the folder '{{the path where your MinGW was installed}}/bin'
I use Eclipse under Fedora 20 with MinGW for cross compile.
Use these settings and the program won't ask for libstdc++-6.dll any more.
Project type - Cross GCC
Cross Settings
Prefix: x86_64-w64-mingw32-
Path: /usr/bin
Cross GCC Compiler
Command: gcc
All Options:
-I/usr/x86_64-w64-mingw32/sys-root/mingw/include -O3
-Wall -c -fmessage-length=0
Includes: /usr/x86_64-w64-mingw32/sys-root/mingw/include
Cross G++ Compiler
Command: g++
All Options: -I/usr/x86_64-w64-mingw32/sys-root/mingw/include -O3
-Wall -c -fmessage-length=0
Includes: /usr/x86_64-w64-mingw32/sys-root/mingw/include
Cross G++ Linker
Command: g++ -static-libstdc++ -static-libgcc
All Options: -L/usr/x86_64-w64-mingw32/sys-root/mingw/lib -L/usr/x86_64-w64-mingw32/sys-root/mingw/bin
Library search path (-L):
/usr/x86_64-w64-mingw32/sys-root/mingw/lib
/usr/x86_64-w64-mingw32/sys-root/mingw/bin
I just had this issue.. I just added the MinGW\bin directory to the path environment variable, and it solved the issue.
I placed the libstdc++-6.dll file in the same folder where exe file is generated.
You only need to add your "mingw-install-directory"/bin/ to your Path in your System environment variables ... that's it !!
I had same problem. i fixed it. i was using Codeblocks and i save my .cpp file on desktop instead of saving it in Codeblocks file where MinGW is located. So i copied all dll files from MinGW>>bin folder to where my .cpp file was saved.
You can also copy the dll files in the directory of your exe file
I had this problem too. I was compiling in command prompt and used the flag -static.
My command before:
"g++ test.cpp -o test.exe"
and afterwards:
"g++ test.cpp -o test.exe -static"
I had the same problem and I solved it by running the compiled exe as an administrator.

Library link error when starting Windows application compiled with MinGW on another computer

I wrote a simple HelloWorld console application and compiled it on Windows 7 with MinGW compiler using one of these commands:
gcc -Wall -pedantic Hello.c -o Hello.exe
g++ -Wall -pedantic Hello.cpp -o Hello.exe
However the compiler links some own dynamic libraries into the app and when i copy the executable into another computer with Windows 7, which does not have MinGW installed, i'm getting missing library error. On Linux this problem is solved by package system, which automatically installs all needed libs, but in Windows you surely don't want to tell your users to install MinGW in order to run your program.
So my question is: How do i link all libraries properly and what else do i have to do to make my application run independently?
Although i believe, this must be a fundamental problem to all Windows programmers, i have been unable to find any answers on the internet (maybe i just don't know how and what to search).
It was in the FAQ at some stage, but now I seem to find it only on this page:
Why I get an error about missing libstdc++-6.dll file when running my program?
GCC4 dynamically link to libgcc and libstdc++ libraries by default
which means that you need a copy of libgcc_s_dw2-1.dll and
libstdc++-6.dll files to run your programs build with the GCC4 version
(These files can be found in MinGW\bin directory). To remove these DLL
dependencies, statically link the libraries to your application by
adding "-static-libgcc -static-libstdc++" to your "Extra linking
options" in the project settings.
Try this,
g++ -static-libgcc -static-libstdc++ -Wall -pedantic Hello.cpp -o Hello.exe
I'm afraid to say that with all of the applications installed on my machine, it's easy to identify which ones were built with MinGW. The telltale sign is a folder filled with libraries.
Check to see if the libraries that you need are distributable, and then simply include them in your .exe directory.
Although you may have other applications installed on user's machine, and some of them may contain the libraries that you need, there's a good chance that your application wont be compatible with them. This is why asking your users to install MinGW would be unlikely to work anyways.

How to install protobuf on windows? (Win7x64/MinGW)

C++-Protobuf does not compile in VS2012. Now I want to use MinGW to compile it on windows. Can someone please give me some brief headwords on how to compile protobuf on Win7 x64. I already installed MinGW with the GUI installer. Google writes as MinGW setup notice that I should refer to the Unix installation notes. But I cant figure out how to use the auto tools on windows.
Edit
Okay this is what I've done until now:
$ mount C:/ WinDir
$ cd ./[...]/protobuf.2.4.1
$ ./configure
$ minGW32-make.exe
$ minGW32-make.exe check
minGW32-make.exe runs without errors, but no tests are running and I cant find libprotobuf.lib. There are some libprotobuf.dll but I need the lib, dont I?.
You should have an MSys console together with your MinGW instalation. This console provides an linux-like environment in which you should be able to use autotools normally.
If MSys is not installed, you can grab it from the MinGW site too.
cd to your directory with sources and try the usual:
$ ./configure
$ make
Some libraries cause problems on Windows but most compile well with MinGW and MSys. Come back and add more info to your question if you run into specific problems.
Edit:
minGW32-make.exe runs without errors, but no tests are running and I cant find libprotobuf.lib. There are some libprotobuf.dll but I need the lib, dont I?.
Usually for a dynamic library you'd get protobuf.dll (the dynamic library) and libprotobuf.a (the static wrapper library).
When linking, just pass -lprotobuf to the linker - it will look for both libprotobuf.a and protobuf.lib.
(.lib is another static library format, which is partially handled by MinGW but not native here.)
You will not work with a .lib file when using the MinGW toolchain. Instead, you are able to link against the dll directly. The MinGW Wiki explains this.
I could get dll and lib both. This is when you do not want static lib file and want to use dll and lib file.
You need to make following changes in Protobuf code:
Open the project in VS. Or any other editor. I use VS2015.
In libProtoBuf project settings, in C/C++ Preprocessor add following flags.
PROTOBUF_USE_DLLS; LIBPROTOBUF_EXPORTS;
Those flags will export information from profobuf using dllexport
in ur client code where you are using Protobuf, define: PROTOBUF_USE_DLLS. Which will make protobuf includes to use dllimport.
Once you do step 2, you will see both dll and lib in your output folder. Otherwise, you will always see just dll and not lib file.
Hope this helps. If not, please write a message here and I can help you getting this sorted out.

Starting off with OpenGL under Cygwin

Is it possible to compile and run OpenGL programs from under Cygwin? If yes, how?
It is possible to compile and run OpenGL programs under Cygwin. I illustrate the basic steps here:
I assume you know OpenGL programming. If not, get the Red Book (The OpenGL Programming Guide). It is mandatory reading for OpenGL anyway.
I assume you have Cygwin installed. If not, visit cygwin.com and install it.
To compile and run OpenGL programs, you need the Cygwin package named opengl. In the Cygwin installer, it can be found under the Graphics section. Please install this package.
Write a simple OpenGL program, say ogl.c.
Compile the program using the flags -lglut32 -lglu32 -lopengl32. (This links your program with the GLUT, GLU and OpenGL libraries. An OpenGL program might typically use functions from all the 3 of them.) For example:
$ gcc ogl.c -lglut32 -lglu32 -lopengl32
Run the program. It's as simple as that!
If the above doesn't work (and it didn't for me), try the following (which did!)
gcc ogl.c -lglut -lglu -lgl
I do not normally post answers this long, but this one is worth it.
I will present a Windows 10 64-bit setup for Cygwin that uses the same libraries as Visual Studio. You will be able to use both development environments with the same code (same includes and libraries), so you can switch between the two as you see fit.
You need three libraries: OpenGL, GLEW, and GLFW.
OpenGL
Visual Studio: The following default locations are valid for current versions of Windows 10 and Visual Studio 2019.
OpenGL static library:
C:\Program Files(x86)\Microsoft Visual Studio\2019\Community\SDK\ScopeCPPSDK\vc15\lib\SDK\lib\opengl32.lib
OpenGL DLL:
C:\Windows\SysWOW64\opengl32.dll
The opengl32.lib library will need to be specified under the VS project Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies. The same applies for all other dynamic libraries under Visual Studio. I will not mention it again.
Cygwin:
OpenGL static library default location:
/lib/w32api/libopengl32.a
OpenGL dynamic library (uses the Windows DLL):
C:\Windows\SysWOW64\opengl32.dll
GLEW
Visual Studio: Download 32-bit/64-bit binaries from http://glew.sourceforge.net/ and install in a custom folder, say C:\OpenGL\glew-2.1.0. The same download works for both Visual Studio and Cygwin.
GLEW headers (to #include GL/glew.h):
C:\OpenGL\glew-2.1.0\include
GLEW static library:
C:\OpenGL\glew-2.1.0\lib\Release\x64\glew32.lib
GLEW DLL:
C:\OpenGL\glew-2.1.0\bin\Release\x64\glew32.dll
These can be specified in your VS project's Properties menu.
Cygwin: You can link against this library from Cygwin as-is, meaning you can specify its download directory for the INCS, LIBS, and LDLIBS variables in your Makefile as follows (consistent with the download directory specified above):
GLEW headers directory:
/cygdrive/c/OpenGL/glew-2.1.0/include
GLEW static library directory:
/cygdrive/c/OpenGL/glew-2.1.0/lib/Release/x64
GLEW dynamic library directory:
/cygdrive/c/OpenGL/glew-2.1.0/bin/Release/x64
With these values for INCS, LIBS, and LDLIBS respectively, you can then link using the UNIX naming conventions as shown in the complete Makefile, at the bottom of the post.
GLFW
This can be downloaded at https://www.glfw.org/download. For our 64-bit setup, you need the Windows 64-bit precompiled binaries. You can place it also in a custom folder, say C:\OpenGL\glfw-3.3.4.bin.WIN64. The same download works for both VS and Cygwin.
Visual Studio:
You can specify directly the download locations into your project Properties for headers (to #include GLFW/glfw3.h in your source code) and DLLs (to have VS link against these libraries), respectively.
Cygwin:
For Cygwin, GLFW is trickier, because you can no longer link against it directly from the download location. You need to:
(a) copy the headers, static, and dynamic libraries from the download locations:
C:\OpenGL\glfw-3.3.4.bin.WIN64\include\GLFW\*.h
C:\OpenGL\glfw-3.3.4.bin.WIN64\lib-mingw-w64\*.a
C:\OpenGL\glfw-3.3.4.bin.WIN64\lib-mingw-w64\*.dll
...into your toolchain's (MinGW's) respective locations:
GLFW headers (create the include directory):
/usr/x86_64-w64-mingw32/include/GLFW/*.h
GLFW static libraries:
/usr/x86_64-w64-mingw32/lib/*.a
GLFW dynamic libraries:
/usr/x86_64-w64-mingw32/bin/*.dll
(b) place the dynamic library location into your PATH environment variable, editable in your .bash_profile file in your home directory.
The Makefile for Cygwin is:
CC=/usr/bin/x86_64-w64-mingw32-c++.exe
OPTS=-std=c++11
DEBUG=-g
CFLAGS=-Wall -c ${DEBUG}
INCS= -I.\
-I/cygdrive/c/OpenGL/glew-2.1.0/include\
-I/cygdrive/c/cygwin64/usr/x86_64-w64-mingw32
LIBS= -L/usr/lib\
-L/cygdrive/c/OpenGL/glew-2.1.0/lib/Release/x64\
-L/cygdrive/c/cygwin64/usr/x86_64-w64-mingw32/lib
LDLIBS= -L/bin\
-L/cygdrive/c/OpenGL/glew-2.1.0/bin/Release/x64\
-L/cygdrive/c/cygwin64/usr/x86_64-w64-mingw32\bin
Program.o: Program.cpp
${CC} ${OPTS} ${INCS} -c $<
Program: Program.o
${CC} ${OPTS} ${LIBS} ${LDLIBS} Program.o -lopengl32 -lglew32 -lglew32.dll -lglfw3 -lgdi32 -luser32 -o Program
With this setup, you can use the same exact source code files in both VS and Cygwin. You can compile, link, and run Program.exe from its directory in Cygwin with:
$ make Program
$ ./Program.exe
You can run from VS a Cygwin-compiled program by opening the existing *.exe as an SLN project and running it using the IDE interface. Conversely, you can run the VS executable (created by VS in Project/Debug or Project/Release) directly from the Cygwin command line with the command above.
The includes are:
#include <GL/glew.h>
#include <GLFW/glfw3.h>
No changes whatsoever will have to be made in the source code to switch back and forth b/w VS and Cygwin. Happy coding :-)
I remember doing this once with some success, a few years ago, basically trying to cross compile a small Linux OpenGL C++ program. I do recall problems with Windows OpenGL drivers being behind the times (due to MS's focus on DirectX). I had NVidia OpenGL and DirectX drivers installed on my Windows system, but cygwin/g++ seemed to want to only use the Microsoft OpenGL DLLs, many years old, which do not have the latest support for all the ARB extensions, like shader programs, etc. YMMV.