Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compile errors on Linux #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jhannemann
Copy link

The changes below fix compile errors experienced on Ubuntu 16.04 LTS
with GCC 5.4.0.

  • On Linux, <sys/time.h> must be included to make struct timeval known.
  • <math.h> does not include std:sqrt. <cmath> does.
  • must be included to use fopen().
  • string.h must be included to use memset().
  • A jump to a label (done_close_file) must not cross local
    declarations. The corresponding code has been encapsulated in a block.
  • The use of the STRINGIZE macro leads to an error where the compiler
    sees the #version 430 sequence as an invalid preprocessor directive.
    Removing the # from #version fixes this.

The changes below fix compile errors experienced on Ubuntu 16.04 LTS
with GCC 5.4.0.

- On Linux, <sys/time.h> must be included to make struct timeval known.
- <math.h> does not include `std:sqrt`. `<cmath>` does.
- <cstdio> must be included to use fopen().
- string.h must be included to use memset().
- A jump to a label (done_close_file) must not cross local
  declarations. The corresponding code has been encapsulated in a block.
- The use of the STRINGIZE macro leads to an error where the compiler
  sees the #version 430 sequence as an invalid preprocessor directive.
  Removing the # from #version fixes this.
@bsmr
Copy link

bsmr commented Nov 19, 2017

I almost created a pull request with the same changes. But I checked the pull-requests before submitting it. Well, I should have checked the pull-requests, before working on the patches.

Question

A question about 12-particlesimulator.cpp and the #version problem: removing the # makes it compile, but is this still a valid shader?

I could make it compile with adding a \ to #, e.g. \#version 430 core, but I am not sure, if this compiles to a proper shader. Maybe I will add some error handling code to vglAttachShaderSource(). Besides, I also removed the trailing \n.

But I couldn't test the output, because my current gfx card only supports 410, and this example is one of the few, which I couldn't get working properly. Only 01-triangles gives me some trouble as well, all the other examples do work.

System Information

$ glxinfo | grep -i version
server glx version string: 1.4
client glx version string: 1.4
GLX version: 1.4
    Version: 17.2.2
    Max core profile version: 4.1
    Max compat profile version: 3.0
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.0
OpenGL core profile version string: 4.1 (Core Profile) Mesa 17.2.2
OpenGL core profile shading language version string: 4.10
OpenGL version string: 3.0 Mesa 17.2.2
OpenGL shading language version string: 1.30
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 17.2.2
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00

$ g++ --version
g++ (Ubuntu 7.2.0-8ubuntu3) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ uname --all
Linux abyss 4.13.0-16-generic #19-Ubuntu SMP Wed Oct 11 18:35:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

$ lsb_release --all
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 17.10
Release:	17.10
Codename:	artful

@jhannemann
Copy link
Author

Well, looking back, I don't know why I removed the # rather than escaping it. Not sure whether it actually compiles correctly, but IIRC it did. I'll revisit this when teaching my class next semester. Thanks for noticing this.

@johnkslang
Copy link
Contributor

Do you want to resubmit without the change to #, or a change to # that preserves it?

robotchaoX added a commit to robotchaoX/examples that referenced this pull request Mar 29, 2022
On Linux, <sys/time.h> must be included to make struct timeval known.
string.h must be included to use memset().
A jump to a label (done_close_file) must not cross local declarations. The corresponding code has been encapsulated in a block.
The use of the STRINGIZE macro leads to an error where the compiler sees the #version 430 sequence as an invalid preprocessor directive.
Move add_subdirectory(lib/glfw) before examples compile in CmakeList.txt to avoid build dependence error.
Reference:
	jhannemann openglredbook#3
	elmindreda openglredbook#5
robotchaoX added a commit to robotchaoX/examples that referenced this pull request Mar 29, 2022
On Linux, <sys/time.h> must be included to make struct timeval known.
string.h must be included to use memset().
A jump to a label (done_close_file) must not cross local declarations. The corresponding code has been encapsulated in a block.
The use of the STRINGIZE macro leads to an error where the compiler sees the #version 430 sequence as an invalid preprocessor directive.
Move add_subdirectory(lib/glfw) before examples compile in CmakeList.txt to avoid build dependence error.
Reference:
	jhannemann openglredbook#3
	elmindreda openglredbook#5
robotchaoX added a commit to robotchaoX/examples that referenced this pull request Mar 29, 2022
On Linux, <sys/time.h> must be included to make struct timeval known.
string.h must be included to use memset().
A jump to a label (done_close_file) must not cross local declarations. The corresponding code has been encapsulated in a block.
The use of the STRINGIZE macro leads to an error where the compiler sees the #version 430 sequence as an invalid preprocessor directive.
Move add_subdirectory(lib/glfw) before examples compile in CmakeList.txt to avoid build dependence error.
Reference:
	jhannemann openglredbook#3
	elmindreda openglredbook#5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants