joaoleal / CppADCodeGen

Source Code Generation for Automatic Differentiation using Operator Overloading
Other
167 stars 37 forks source link

Running the test program Jacobian module listwith cppAD library gives a lot of errors #85

Open qmpotential opened 1 year ago

qmpotential commented 1 year ago

Hey guys, I need your help! I am new to the library. Installing the library like cmake .. make install seems working file but when I run the test file I am getting the following.

qmpotential commented 1 year ago

icpc -o test3.run test3.cpp /tmp/icpcvNHPT6.o: In function CppAD::vector<double> CppAD::ADFun<double, double>::Forward<CppAD::vector<double> >(unsigned long, CppAD::vector<double> const&, std::ostream&)': test3.cpp:(.text._ZN5CppAD5ADFunIddE7ForwardINS_6vectorIdEEEET_mRKS5_RSo[_ZN5CppAD5ADFunIddE7ForwardINS_6vectorIdEEEET_mRKS5_RSo]+0x1114): undefined reference toCppAD::local::temp_file[abi:cxx11]()'

qmpotential commented 1 year ago

My code is

include

include <cppad/cppad.hpp>

int main(){

size_t n = 1; size_t m = 1;

CppAD::vector<CppAD::AD> X(n); CppAD::vector<CppAD::AD> Y(m);

Y[0] = CppAD::sin(X[0]);

CppAD::ADFun f(X,Y);

CppAD::vector x(n); CppAD::vector jac(m * n);

x[0] = 0.5;

jac = f.Jacobian(x);

return 0;

}

bradbell commented 1 year ago

Perhaps the following discussions will help ? https://github.com/coin-or/CppAD/discussions/173 https://github.com/coin-or/CppAD/discussions/175

qmpotential commented 1 year ago

Good morning, Bradbell!

Thank you so much for your links, they are somewhat helpful, but I still have a question about the proper installation. I still have trouble to compile my test program with the reference to the CppAD::local::temp_file[abi:cxx11]()' file.

Do I miss something?

I can see the cppad.hpp file in ../include/cppad/ directory and ../include/cppad/local/temp_file.hpp

Do you have a quick check to find if all the libraries have properly linked ?

Thank you so much in advance.

bradbell commented 1 year ago

I suggest that you find where CppADCodeGen has stored its pkg-config file. For example find dir -name 'cppadcg.pc' where dir is the prefix for your install of CppADCodeGen.

Let subdir be the sub-directory where the cppadcg.pc file is stored and set export PKG_CONFIG_PATH=full_path_to_subdir

Then execute the command pkg-config --libs --cflags cppadcg and you should get all the flags you need to link CppADCodeGen.

qmpotential commented 1 year ago

Thank you so much it worked, by the way, there is no cppadcg.pc file, but cppad.pc file.