admb-project / admb

AD Model Builder
http://admb-project.org
Other
64 stars 19 forks source link

linker error on OS X when compiling examples/contrib/catage example from ADMB 12.3 #198

Closed wStockhausen closed 3 years ago

wStockhausen commented 3 years ago

Got the following linker error when trying to compile and link examples/contrib/catage/catage.tpl on a Mac using ADMB 12.3:

williamstockhausen@MacBook-Pro catage % /Users/WilliamStockhausen/Work/Programming/admb/bin/admb catage
*** Parse: catage.tpl tpl2cpp catage || tpl2rem catage

*** Compile: catage.cpp c++ -c -std=c++14 -O3 -D_USE_MATH_DEFINES -DUSE_ADMB_CONTRIBS -I. -I"/Users/WilliamStockhausen/Work/Programming/admb/include" -I"/Users/WilliamStockhausen/Work/Programming/admb/include/contrib" -ocatage.obj catage.cpp

*** Linking: catage.obj c++ -std=c++14 -O3 -ocatage catage.obj "/Users/WilliamStockhausen/Work/Programming/admb/lib/libadmb-contrib-x86_64-macos-clang.a"

Undefined symbols for architecture x86_64: "cubic_spline(dvar_vector const&, dvar_vector const&)", referenced from: model_parameters::get_mortality_and_survivial_rates() in catage.obj ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Error: Could not build catage

The example in examples/admb/catage compiles and runs correctly, but (of course) doesn't have a call to cubic_spline(...).

The signature for "cubic_spline(dvar_vector const&, dvar_vector const&)" is defined in stats lib.h but the body of the function is not defined anywhere (at least, I couldn't find it using the ADMB Documentation File Reference). Note that the body of the function "cubic_spline(dvar_vector const&, dvector const&)" IS defined in vcubicspline.cpp (but the signature does not seem to appear in a header file).

johnoel commented 3 years ago

Yes, that looks like a typo. Thanks for catching that. It has been corrected in dc99713 commit.

For now, just declare the function correctly in the GLOBALS_SECTION.

GLOBALS_SECTION
   #include <statsLib.h>
   dvar_vector cubic_spline(const dvar_vector& spline_nodes, const dvector& ip);