Portable C/C++ code is hard

Timothy Wright  —  6 months, 2 weeks ago

I've yet to get the build working for anyone but me. If you have any experience with this or some resources I would love some opinions.

https://github.com/ZenToad/kiss_engine
#11915 ratchetfreak  —  6 months, 2 weeks ago
First step is to replicate the problem:

start with a blank directory and clone your repo into that and then try and compile from just that. Note down everything you had to do, then simplify. Rinse and repeat.

Then when satisfied with that go to a new machine with just a compiler and repeat the process (restoring the machine's env when restarting)
#11916 royh  —  6 months, 2 weeks ago
I tried building ufo_2d. First I got a lot of output that looked like this:

1
2
3
4
5
6
7
8
w:\tmp\kiss\include\glad\glad.c(135) : error C2220: warning treated as error - no 'object' file generated
w:\tmp\kiss\include\glad\glad.c(135) : warning C4054: 'type cast' : from function pointer 'FARPROC' to data pointer 'void *'
w:\tmp\kiss\include\glad\glad.c(214) : warning C4127: conditional expression is constant
w:\tmp\kiss\include\glad\glad.c(263) : warning C4054: 'type cast' : from function pointer 'PFNGLCOPYTEXIMAGE1DPROC' to data pointer 'void *'
w:\tmp\kiss\include\glad\glad.c(265) : warning C4054: 'type cast' : from function pointer 'PFNGLCOPYTEXIMAGE1DPROC' to data pointer 'void *'
w:\tmp\kiss\include\glad\glad.c(271) : warning C4054: 'type cast' : from function pointer 'PFNGLVERTEXATTRIBI3UIPROC' to data pointer 'void *'
w:\tmp\kiss\include\glad\glad.c(273) : warning C4054: 'type cast' : from function pointer 'PFNGLVERTEXATTRIBI3UIPROC' to data pointer 'void *'
w:\tmp\kiss\include\glad\glad.c(279) : warning C4054: 'type cast' : from function pointer 'PFNGLVERTEXARRAYELEMENTBUFFERPROC' to data pointer 'void *'

so I added
1
/wd4054 /wd4055 /wd4127
to the FLAGS variable in build.bat. Then I tried again and got this:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
W:\tmp\kiss\examples\ufo_2d>build
imgui_demo.cpp
imgui_draw.cpp
imgui.cpp
Generating Code...
Compiling...
glad.c
Generating Code...
Compiling...
ufo_2d.cpp
Generating Code...
LINK : fatal error LNK1181: cannot open input file '../../../lib/glfw/build/src/Debug/glfw3.lib'
File not found - ufo_2d.exe
0 File(s) copied

so I changed the
1
../../../lib/glfw/build/src/Debug/glfw3.lib
in the LIBRARY_FILES variable to
1
../../../lib/glfw/lib/glfw3.lib


The file right afterward caused the next problem:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
W:\tmp\kiss\examples\ufo_2d>build
glad.c
Generating Code...
Compiling...
ufo_2d.cpp
Generating Code...
Skipping... (no relevant changes detected)
imgui_demo.cpp
imgui_draw.cpp
imgui.cpp
LINK : fatal error LNK1181: cannot open input file '../../../lib/Box2D/Build/vs2017/bin/Release/Box2D.lib'
File not found - ufo_2d.exe
0 File(s) copied

but I didn't get a Box2D.lib anywhere in that ZIP file from github.
#11919 Mārtiņš Možeiko  —  6 months, 2 weeks ago
Portable code is not very hard. Its just that you need to test it well enough and often enough if you are shipping it.
Run it on multiple systems, don't assume any prerequisites (like specific paths, or tool versions, and similar).
Log in to comment