compile error

31 views
Skip to first unread message

俊黄

unread,
May 4, 2020, 12:14:18 PM5/4/20
to Lunaserv
Hi Nick,
Thank you very much for developing this interesting tool.

I am a planetary geologist, and I want to set up lunaserv on my local ubuntu 18.04 server.

I followed the install guide on lunaserv's page, and tried to install all the dependencies mentioned there. After cd into map_utils folder, and I typed make. It shows the error as follows:

gcc -Wall -Werror -std=gnu99 -O3 -pthread -I/opt/local/include -I/usr/include/libshp `gdal-config --cflags` map_raster_layer.c map_shared_code.c -L/opt/local/lib -lgd -lproj -ltiff -lImlib2 -lshp `gdal-config --libs` -o map_raster_layer
map_shared_code.c: In function ‘resolution_quality’:
map_shared_code.c:531:30: error: ‘latitude’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   double lat_rad = *latitude * DEG_TO_RAD;
                              ^
map_shared_code.c:785:24: note: ‘latitude’ was declared here
      double longitude, latitude;
                        ^~~~~~~~
map_shared_code.c:530:31: error: ‘longitude’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
   double lon_rad = *longitude * DEG_TO_RAD;
                               ^
map_shared_code.c:785:13: note: ‘longitude’ was declared here
      double longitude, latitude;
             ^~~~~~~~~
cc1: all warnings being treated as errors
Makefile:41: recipe for target 'map_raster_layer' failed
make: *** [map_raster_layer] Error 1

Could you give me some hints to fix it?

Thank you in advance,
Jun 

Nick Estes

unread,
May 4, 2020, 12:20:27 PM5/4/20
to 俊黄, Lunaserv
What version of gcc are you using? There have been a lot of compiler
updates since we last release code, and I know we've had to a make a
number of changes locally to keep the code up to date with newer
compilers. If I have the same gcc version you're running somewhere,
I'll try to reproduce the error and release a patch to fix it for you.

If you want to try fixing it yourself, just edit map_shared_code.c and
go to that declaration on line 785 and initialize both longitude and
latitude to 0 and I bet it will work. When passing around pointers to
variables, the compiler can't always recognize when that variable is
actually set, so initializing a value on declaration should solve it.

--Nick
> --
> You received this message because you are subscribed to the Google
> Groups "Lunaserv" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to lunaserv+u...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/lunaserv/7549cc7e-25a9-4102-ad3c-d19056d1b454%40googlegroups.com
> [1].
>
>
> Links:
> ------
> [1]
> https://groups.google.com/d/msgid/lunaserv/7549cc7e-25a9-4102-ad3c-d19056d1b454%40googlegroups.com?utm_medium=email&utm_source=footer

俊黄

unread,
May 4, 2020, 10:57:24 PM5/4/20
to Lunaserv
Thank you very much for your reply. It fixed the error. But it seems to have a new error:

gcc -Wall -Werror -std=gnu99 -O3 -pthread -I/opt/local/include -I/usr/include/libshp `gdal-config --cflags` map_raster_layer.c map_shared_code.c -L/opt/local/lib -lgd -lproj -ltiff -lImlib2 -lshp `gdal-config --libs` -o map_raster_layer
/usr/bin/ld: /tmp/cckWWgwi.o: undefined reference to symbol 'sin@@GLIBC_2.2.5'
//lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Makefile:41: recipe for target 'map_raster_layer' failed
make: *** [map_raster_layer] Error 1

______

When I typed gcc -v, the text comes up as follows:
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04) 

Jun
> an email to luna...@googlegroups.com.

Nick Estes

unread,
May 4, 2020, 11:10:39 PM5/4/20
to 俊黄, Lunaserv
That's another compiler change over time. GCC used to link in the math
library automatically, but that doesn't happen anymore. Open up the
Makefile and add "-lm" to the end of the LDFLAGS and that problem should
go away.

--Nick
>> [2]
>
> --
> You received this message because you are subscribed to the Google
> Groups "Lunaserv" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to lunaserv+u...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/lunaserv/3654622c-75f7-4c93-8e02-5cc7e8150fc8%40googlegroups.com
> [3].
> [2]
> https://groups.google.com/d/msgid/lunaserv/7549cc7e-25a9-4102-ad3c-d19056d1b454%40googlegroups.com?utm_medium=email&utm_source=footer
> [3]
> https://groups.google.com/d/msgid/lunaserv/3654622c-75f7-4c93-8e02-5cc7e8150fc8%40googlegroups.com?utm_medium=email&utm_source=footer

俊黄

unread,
May 5, 2020, 10:00:21 PM5/5/20
to Lunaserv
The problem went away after I fixed the Makefile as you suggested.

Thank you very much!

Jun
Reply all
Reply to author
Forward
0 new messages