0

First, the background information - the question itself follows in bold.

I am trying to learn how to write OpenGL programs on 64-Bit Windows 10 Home (Version 21H2 OS Build 19044.1706). I program using Notepad++ as a text editor, and build via batch scripts and command prompt. I do not want to use an IDE or advanced build tools as I have found minimalistic tools to be easier for me to learn.

My development environment is as follows:

I have downloaded the .zip files for GLEW and freeglut from graphics.ucdenver.edu, and extracted the files to Desktop\Graphics\Dependencies\Glew and Desktop\Graphics\Dependencies\FreeGlut, respectively.

In Desktop\Graphics, I have included the code from https://github.com/TransmissionZero/Hello-GLUT as a test, and I am trying to build it using the following batch script:

@echo off

gcc -c %1.c -o %1.exe -I"C:\Users\myusername\Desktop\Graphics\Dependencies\FreeGlut\include" -L"C:\Users\myusername\Desktop\Graphics\Dependencies\FreeGlut\lib" -I"C:\Users\myusername\Desktop\Graphics\Dependencies\Glew\include" -L"C:\Users\myusername\Desktop\Graphics\Dependencies\Glew\lib" -lopengl32 -lbz2 -Wl,--subsystem,windows -Wall

where I am passing the location of the C program (TransmissionZero\HelloGLUT\HelloGLUT) as the command line argument.

The command succeeds without errors or warnings, but when I run the exe, I get "Unsupported 16-Bit Application" and the example program does not run. How do I resolve this issue?

BDL
  • 21,052
  • 22
  • 49
  • 55
Math Rules
  • 21
  • 7
  • 1
    `gcc -c` creates an object file that needs to be linked to create an actual program. You're missing that step. You need to run `gcc -o program.exe ` Learning to create a simple Makefile would help this process. – Retired Ninja Jun 19 '22 at 20:06
  • Or simply drop `-c` command line argument to compile *and* link for a first try – though with make files I'd rather retain separate steps. – Aconcagua Jun 19 '22 at 20:13
  • 2
    https://github.com/TransmissionZero/Hello-GLUT contains some particular instructions for a Win32 build, e.g. "-lglut32". – Franck Jun 19 '22 at 20:14
  • @Retired Ninja - gcc does generate a .exe file without any errors or warnings (even with the -Wall flag), but the file won't run due to the "Unsupported 16-Bit Application" error. Is this something wrong with the FreeGlut and GLEW implementations I'm using, or do I need to add more to my gcc command? If I need to use a different implementation of FreeGlut or GLEW, where can I download these securely? – Math Rules Jun 19 '22 at 20:15
  • For reference: [What does -c option do in GCC](https://stackoverflow.com/questions/14724315/what-does-c-option-do-in-gcc) – Retired Ninja Jun 19 '22 at 20:15
  • 2
    `gcc` will create any file you specify with the `-o` option, it doesn't mean that file will contain what you think it does (if you use `-c`) or have anything to do with the extension you gave it. – Retired Ninja Jun 19 '22 at 20:16
  • @Franck - I must have missed that option for Hello-GLUT. I added it to the gcc command, but I still am getting the same error message with the executable. – Math Rules Jun 19 '22 at 20:16
  • @RetiredNinja - You are correct, the -c flag is what was causing the issue. I'm now getting an error cannot find lglut32. How would I resolve that error? Should I close this question and make a new one for that? – Math Rules Jun 19 '22 at 20:20
  • Try to start with https://www.transmissionzero.co.uk/computing/using-glut-with-mingw/ – Franck Jun 19 '22 at 20:32
  • `-lfreeglut -lglu32` instead of `-lglut32` – Franck Jun 19 '22 at 20:43

0 Answers0