Polytonic / Glitter

Dead Simple OpenGL
http://polytonic.github.io/Glitter/
2.46k stars 416 forks source link

Issues with cmake not building GLAD #39

Closed MohGhareeb closed 6 years ago

MohGhareeb commented 6 years ago

Sometimes when I build Glitter, the build process runs successfully but for some reason glad doesn't get built. I see not error messages in cmake, but the glad folder inside vendor doesn't include the folders named "include" and "src" as it should when it is built correctly; it still retains the same file structure in its git repo. I am using Win10 x64 with VS 2017 and cmake 3.9.5

Polytonic commented 6 years ago

Could you clarify what you mean by "sometimes"? Are these incremental builds? Clean builds? Are you running any git submodule related commands?

MohGhareeb commented 6 years ago

ok to be completely honest, I am not really knowledgeable with cmake, but I will try to clarify my situation. I am trying to do a clean build, the scenario that I am doing is as follow: 1- I clone the repo with git clone https://github.com/Polytonic/Glitter/, I do not use recursive because I have the other submodules cloned already, 2- I copy the required submodules to Glitter/Vendor folder 3- I go to the Build folder and run cmake -G "Visual Studio 15 2017 Win64" ,, 4- I get the situation I already described.

What I mean by sometimes is that I successfully built 2 times out like 20 trial, and I have no idea why, I am trying to replicate it,

Here is my output log:

$ cmake -G "Visual Studio 15" .. -- The C compiler identification is MSVC 19.10.25017.0 -- The CXX compiler identification is MSVC 19.10.25017.0 -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/ 2017/Enterprise/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.10.25017/bin/HostX86/x86/cl.exe -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done -- Looking for pthread.h -- Looking for pthread.h - not found -- Found Threads: TRUE -- Could NOT find Vulkan (missing: VULKAN_LIBRARY VULKAN_INCLUDE_DIR) -- Using Win32 for window creation -- Shared libraries disabled -- Looking for DirectX... -- DirectX_PREFIX_PATH changed. -- Could not locate DirectX -- Looking for ZLIB... -- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) -- Could not locate ZLIB -- compiling zlib from souces -- Looking for sys/types.h -- Looking for sys/types.h - found -- Looking for stdint.h -- Looking for stdint.h - found -- Looking for stddef.h -- Looking for stddef.h - found -- Check size of off64_t -- Check size of off64_t - failed -- Looking for fseeko -- Looking for fseeko - not found -- Looking for unistd.h -- Looking for unistd.h - not found -- Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) -- Could NOT find rt (missing: RT_LIBRARY) -- Enabled formats: AMF 3DS AC ASE ASSBIN ASSXML B3D BVH COLLADA DXF CSM HMP IRRMESH IRR LWO LWS MD2 MD3 MD5 MDC MDL NFF NDO OFF OBJ OGRE OPENGEX PLY MS3D COB BLEND IFC XGL FBX Q3D Q3BSP RAW SIB SMD STL TERRAGEN 3D X X3D GLTF 3MF MMD -- Disabled formats: CMAKE_EXE_LINKER_FLAGS_DEBUG=/INCREMENTAL:NO /debug /INCREMENTAL -- Found OpenGL: opengl32 OPENGL FOUND glu32opengl32 -- Configuring done -- Generating done -- Build files have been written to: D:/OpenGL/Libs/Glitter/Build

Polytonic commented 6 years ago

Apologies for the delay -- I've been out on travel for a few days.

1- I clone the repo with git clone https://github.com/Polytonic/Glitter/, I do not use recursive because I have the other submodules cloned already, 2- I copy the required submodules to Glitter/Vendor folder 3- I go to the Build folder and run cmake -G "Visual Studio 15 2017 Win64" ,, 4- I get the situation I already described.

What is your intent with regards to the second step? When you're copying to Glitter/Vendor are you copying into $REPO_ROOT/Build/Glitter/Vendor or $REPO_ROOT/Glitter/Vendor? You shouldn't have to perform manual copying of submodule (folders) when building, as CMake automatically handles this step from the source folder to the Build folder. I'd suggest cloning or fetching recursively (i.e. follow the steps outlined in the readme exactly) to rule out any git voodoo.

Can you paste the build output as well? (i.e. the console output after Ctrl+B or building in VS2017)

Polytonic commented 6 years ago

@MohGhareeb are you still experiencing problems? Just wanted to follow up here.

Minimuino commented 6 years ago

I'm also having an issue with glad, not sure if it's related to this one. I've followed the README instructions for linux, but got this linker error:

$ make [ 2%] Built target LinearMath [ 6%] Built target glfw [ 52%] Built target assimp [ 74%] Built target BulletCollision [ 83%] Built target BulletDynamics [ 83%] Linking CXX executable Glitter/Glitter /usr/bin/ld: CMakeFiles/Glitter.dir/Glitter/Vendor/glad/src/glad.c.o: relocation R_X86_64_32S against `.data' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Nonrepresentable section on output collect2: error: ld returned 1 exit status CMakeFiles/Glitter.dir/build.make:129: recipe for target 'Glitter/Glitter' failed make[2]: [Glitter/Glitter] Error 1 CMakeFiles/Makefile2:71: recipe for target 'CMakeFiles/Glitter.dir/all' failed make[1]: [CMakeFiles/Glitter.dir/all] Error 2 Makefile:129: recipe for target 'all' failed make: *** [all] Error 2

System: x86_64 Debian GNU/Linux cmake version 3.9.5 GNU Make 4.1 g++ (Debian 6.3.0-18) 6.3.0 20170516

I'd really appreciate if you can put some light on this. Thanks in advance. Pretty useful repo, btw ;)

Polytonic commented 6 years ago

@Minimuino huh, fascinating. I've never seen that one before. You could try adding -no-pie or -fPIC on Line 24 in CMakeLists.txt according to StackOverflow (https://stackoverflow.com/a/47201755) and run cmake again. This looks like something system specific anyway.

Minimuino commented 6 years ago

@Polytonic Wow, thanks mate! I've already tried with -fPIC, but the actual solution was to add -no-pie. When I searched StackOverflow for some clues, I found some people suggested to use -fPIC (the error output itself recommends it), but I didn't find that particular thread. Thank you again for your extremely quick answer! :+1:

Polytonic commented 6 years ago

I'm going to go ahead and close this one, as @MohGhareeb hasn't responded in two months. Feel free to open a new issue if you continue to have issues.