augustus icon indicating copy to clipboard operation
augustus copied to clipboard

Linker: undefined reference when no Cmake build type is defined

Open gonX opened this issue 2 years ago • 2 comments
trafficstars

Running mkdir build && cd build && cmake .. && make on master (dfab1140c669b) results in:

/usr/bin/ld: CMakeFiles/augustus.dir/src/widget/city_without_overlay.c.o: in function `city_without_overlay_draw':
city_without_overlay.c:(.text+0x24f0): undefined reference to `debug_draw_city'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/augustus.dir/build.make:6365: augustus] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/augustus.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

The workaround is defining the build type, e.g.: cmake -DCMAKE_BUILD_TYPE="Debug" .. or cmake -DCMAKE_BUILD_TYPE="Release" ..

gonX avatar Dec 01 '22 21:12 gonX

Just to add, debug_draw_city is only called when NDEBUG is not set (which is set for a release build), and src/platform/debug.c is not included unless debug is set.

I suggest falling back to a consistent choice if its unset.

gonX avatar Dec 01 '22 21:12 gonX

@PrettyFlower You also can't build with -DDRAW_FPS=1 if the build type isn't debug. We definitely need to revamp the debug system.

crudelios avatar Dec 02 '22 08:12 crudelios