nothings / stb

stb single-file public domain libraries for C/C++
https://twitter.com/nothings
Other
26.81k stars 7.72k forks source link

Failed to run make under tests #1421

Open laoshaw opened 1 year ago

laoshaw commented 1 year ago

Describe the bug can not make tests

To Reproduce Steps to reproduce the behavior:

  1. Go to tests
  2. run 'make' on ubuntu 20.04
  3. Scroll down to '....'
  4. See error
cc -I.. -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast -DSTB_DIVIDE_TEST ../stb_vorbis.c test_c_compilation.c test_c_lexer.c test_dxt.c test_easyfont.c test_image.c test_image_write.c test_perlin.c test_sprintf.c test_truetype.c test_voxel.c -lm
cc -I.. -Wno-write-strings -DSTB_DIVIDE_TEST -std=c++0x test_cpp_compilation.cpp -lm -lstdc++
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x24): undefined reference to `main'
collect2: error: ld returned 1 exit status
make: *** [Makefile:10: all] Error 1

Expected behavior should build tests without errors

Screenshots If applicable, add screenshots to help explain your problem.

hikari-no-yume commented 1 year ago

I get this too, but on macOS. It's not clear to me if there's meant to be a main function and it's broken for some reason, or if it's meant to be a library and some systems don't require a special flag to compile one.

rygorous commented 1 year ago

Neither, this file as originally written is meant to be compiled but not linked into anything and the Makefile in question was submitted by a contributor and isn't (to my knowledge) used by the maintainers at all, or at least I've never used it. (This is the first time I'm learning about it even existing in the repository.)

hikari-no-yume commented 1 year ago

I'd be happy to contribute a small patch that fixes the Makefile so it won't try to link against main, but I am not a maintainer so I don't know if the file is reasonable to begin with. Does it look okay?

rygorous commented 1 year ago

I think all that needs to happen here is to add a -c to the line that compiles this file since the only reason the test_x_compilation file exist is to check that the libs compile when fed to a C/C++ compiler, respectively. (I.e. to test that the libs conform to the common subset of C and C++.)

hikari-no-yume commented 1 year ago

Might be good to compile them a few times with different language standards.

nothings commented 1 year ago

I believe the Makefile is part of the Travis integration, so probably shouldn't be touched unless that's broken.