This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
Chris, What is the value of the MATH_LIBRARY variable in the file "CMakeCache.txt", which should be in the top-level build-directory? > My point is: The latest udunits doesn't build on ubuntu: > > $ rm -Rf build && mkdir build && cd build > $ cmake .. > $ make > Scanning dependencies of target udunits2_doc > [ 5%] Built target udunits2_doc > Scanning dependencies of target libudunits2 > [ 10%] Building C object lib/CMakeFiles/libudunits2.dir/converter.c.o > [ 15%] Building C object lib/CMakeFiles/libudunits2.dir/error.c.o > [ 21%] Building C object lib/CMakeFiles/libudunits2.dir/formatter.c.o > [ 26%] Building C object lib/CMakeFiles/libudunits2.dir/idToUnitMap.c.o > [ 31%] Building C object lib/CMakeFiles/libudunits2.dir/parser.c.o > [ 36%] Building C object lib/CMakeFiles/libudunits2.dir/prefix.c.o > [ 42%] Building C object lib/CMakeFiles/libudunits2.dir/status.c.o > [ 47%] Building C object lib/CMakeFiles/libudunits2.dir/systemMap.c.o > [ 52%] Building C object lib/CMakeFiles/libudunits2.dir/unitAndId.c.o > [ 57%] Building C object lib/CMakeFiles/libudunits2.dir/unitcore.c.o > [ 63%] Building C object lib/CMakeFiles/libudunits2.dir/unitToIdMap.c.o > [ 68%] Building C object lib/CMakeFiles/libudunits2.dir/ut_free_system.c.o > [ 73%] Building C object lib/CMakeFiles/libudunits2.dir/xml.c.o > Linking C shared library libudunits2.so > [ 84%] Built target libudunits2 > Scanning dependencies of target udunits2lib_doc > [ 89%] Built target udunits2lib_doc > Scanning dependencies of target udunits2 > [ 94%] Building C object prog/CMakeFiles/udunits2.dir/udunits2.c.o > Linking C executable udunits2 > ../lib/libudunits2.so: undefined reference to `fmod' > ../lib/libudunits2.so: undefined reference to `exp' > ../lib/libudunits2.so: undefined reference to `log' > ../lib/libudunits2.so: undefined reference to `pow' > ../lib/libudunits2.so: undefined reference to `log10' > ../lib/libudunits2.so: undefined reference to `floor' > collect2: error: ld returned 1 exit status > make[2]: *** [prog/udunits2] Error 1 > make[1]: *** [prog/CMakeFiles/udunits2.dir/all] Error 2 > make: *** [all] Error 2 > > The only way to fix it is to tell gcc that libudunits depends on libm > while generating the .so: > > Original command: > /usr/bin/cc -fPIC -shared -Wl,-soname,libudunits2.so -o > libudunits2.so [...] -lexpat > Fixed command: > /usr/bin/cc -fPIC -shared -Wl,-soname,libudunits2.so -o > libudunits2.so [...] -lexpat -lm > > After the fix: > $ make > [ 5%] Built target udunits2_doc > [ 84%] Built target libudunits2 > [ 89%] Built target udunits2lib_doc > Linking C executable udunits2 > [ 94%] Built target udunits2 > Scanning dependencies of target udunits2prog_doc > [100%] Built target udunits2prog_doc > > > The sense of the "res == 0" test in the above is inverted: the > > function returns false (i.e., 0) if and only if numeric values are not > > convertible between the two units. > > My bad! Actually the documentation is clear enough on that point. > > > You should use ut_free(ut_unit*) and ut_free_system(ut_unit_system*) > > in the above instead of free(). The documentation needs to be improved > > in the area. I'll get on that. > > My bad again, I think the documentation is clear enough. > > > The above warnings are expected for the reasons given. You can disable them. > > Good, I think i will eventually customise my unit definitions. Regards, Steve Emmerson Ticket Details =================== Ticket ID: KIA-819973 Department: Support UDUNITS Priority: Normal Status: Closed