Comments (16)
Take a look at the discussion
#175
In particular the suggestion
'From the description above it does not seem like you are including cppad_lib in the linking.'
from cppad.
But how exactly to include that particular library? Please see below my CMakeLists.txt. There is an entry called cppad_lib, but the problem remains.
cmake_minimum_required(VERSION 3.5.1
FATAL_ERROR)
# It's actually not a true cmake way of making such things, but here its more comfortable :)
set(CMAKE_CXX_FLAGS_DEBUG "")
set(CMAKE_CXX_FLAGS_RELEASE "")
add_compile_options(
-Wall
-std=c++20
-pthread
-DHAVE_CSTDDEF
)
include_directories(
"/usr/local/include/coin-or",
"/usr/include/coin",
)
link_directories(
)
set(SEA_LIBRARIES
"-lOsiCbc -lCbc -lCgl -lOsiClp -lOsi -lClp -lCoinUtils -lm -lz"
"-lbz2 -llapack -lblas -ldl -lgflags -lipopt -pthread -lunwind -lwsmp64"
"-luuid -llog4cpp -ljsoncpp -lstdc++fs -lcppad_lib"
)
file(GLOB_RECURSE SOURCES "src/*.cpp")
add_executable(sea ${SOURCES})
target_compile_options(sea PUBLIC -O3 -march=native -fopenmp)
target_link_libraries(sea
${SEA_LIBRARIES}
"cppad_lib"
"cppad_ipopt"
)
from cppad.
And this is how compiler error log sounds:
[ 2%] Linking CXX executable sea
/usr/bin/ld: CMakeFiles/sea.dir/src/backend/ipopt/recalculate.cpp.o: in function `void CppAD::put_check_for_nan<double>(CppAD::vector<double> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std:
:allocator<char> >&) [clone .isra.0]':
recalculate.cpp:(.text+0x8d8e): undefined reference to `CppAD::local::temp_file[abi:cxx11]()'
/usr/bin/ld: CMakeFiles/sea.dir/src/backend/lagrangian_relaxation/gm_sea/gm_src/ufgm_optimizer.cpp.o: in function `void CppAD::put_check_for_nan<double>(CppAD::vector<double> const&, std::__cxx11::basic_string<c
har, std::char_traits<char>, std::allocator<char> >&) [clone .isra.0]':
ufgm_optimizer.cpp:(.text+0x6fde): undefined reference to `CppAD::local::temp_file[abi:cxx11]()'
/usr/bin/ld: CMakeFiles/sea.dir/src/backend/lagrangian_relaxation/gm_sea/sea_gm_apply.cpp.o: in function `void CppAD::put_check_for_nan<double>(CppAD::vector<double> const&, std::__cxx11::basic_string<char, std:
:char_traits<char>, std::allocator<char> >&) [clone .isra.0]':
sea_gm_apply.cpp:(.text+0x5b2e): undefined reference to `CppAD::local::temp_file[abi:cxx11]()'
/usr/bin/ld: CMakeFiles/sea.dir/src/backend/lagrangian_relaxation/gm_sea/sea_gm_apply.cpp.o: in function `void CppAD::put_check_for_nan<CppAD::AD<double> >(CppAD::vector<CppAD::AD<double> > const&, std::__cxx11:
:basic_string<char, std::char_traits<char>, std::allocator<char> >&) [clone .isra.0]':
sea_gm_apply.cpp:(.text+0x5f0e): undefined reference to `CppAD::local::temp_file[abi:cxx11]()'
/usr/bin/ld: CMakeFiles/sea.dir/src/backend/lagrangian_relaxation/lr_cppad.cpp.o: in function `void CppAD::put_check_for_nan<double>(CppAD::vector<double> const&, std::__cxx11::basic_string<char, std::char_trait
s<char>, std::allocator<char> >&) [clone .isra.0]':
lr_cppad.cpp:(.text+0x257e): undefined reference to `CppAD::local::temp_file[abi:cxx11]()'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/sea.dir/build.make:849: sea] Error 1
make[1]: *** [CMakeFiles/Makefile2:84: CMakeFiles/sea.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
from cppad.
The only workaround I have found so far is to include the following header (copied from inside CppAD):
#pragma once
# include <vector>
# include <stdio.h>
# include <stdlib.h>
# include <unistd.h>
# include <cppad/configure.hpp>
# include <cppad/local/temp_file.hpp>
# include <filesystem>
# define DIR_SEP '/'
namespace CppAD {
namespace local { // BEGIN_CPPAD_LOCAL_NAMESPACE
std::string temp_file(void)
{ // path
using std::filesystem::path;
//
// tmp_dir_path
path tmp_dir_path = std::filesystem::temp_directory_path();
//
// tmp_dir_str
std::string tmp_dir_str = tmp_dir_path.string();
if( tmp_dir_str.back() != DIR_SEP )
tmp_dir_str += DIR_SEP;
//
// pattern_str
std::string pattern_str = tmp_dir_str;
pattern_str += "fileXXXXXX";
//
// pattern_vec
std::vector<char> pattern_vec( pattern_str.size() + 1 );
for(size_t i = 0; i < pattern_str.size(); ++i)
pattern_vec[i] = pattern_str[i];
pattern_vec[ pattern_str.size() ] = '\0';
//
// fd, pattrern_vec
int fd = mkstemp( pattern_vec.data() );
if( fd < 0 )
return "";
close(fd);
//
// file_name
std::string file_name = pattern_vec.data();
return file_name;
}
}
}
from cppad.
Please take a look at the following
#175
Many other people are having this problem and I think I should put something in the documentation for this:
https://cppad.readthedocs.io/en/latest/
Do you have a suggesiton ? Where did you look in the documentation ? Did you do a search for link error
or temp_file
?
from cppad.
Did the message above solve the problem for you ? If so, would you please close this issue.
from cppad.
No, the message above did not help. Sounds like the library does not have temp_file method inside for some reason. The problem was solved the other way: by directly compiling with adding the temp_file method to the header included in the entry point main.cpp.
from cppad.
temp_file should be in cppad_lib. What system / compiler are you using and what does your link command look like ?
from cppad.
Related Issues (20)
- Tried to set Option: xx. It is not a valid option. Please check the list of available options HOT 2
- Computing the Jacobian of an ODE HOT 2
- CPPAD_DISCRETE_FUNCTION does not work through base2ad HOT 2
- Eigen::NumTraits does not define infinity() or quiet_NaN() HOT 3
- How to add self defined functions to AD<Base>? HOT 8
- Using C++ conditional operators HOT 5
- AD<double> not working in Eigen with some complex function HOT 4
- Computing Derivatives of solutions of optimization Problems HOT 9
- Working with CppAD::ipopt::solve and CppADCodeGen HOT 4
- Leppov case missing in local/optimize/get_op_usage.hpp HOT 3
- Discrete coefficient sets for polynomial vary as a function of dependent variable HOT 16
- How to write the `.lp` file of a Ipopt model? HOT 6
- Linking error "undefined reference to `CppAD::local::temp_file()'" HOT 4
- solution vector is empty HOT 10
- Undefined reference to temp_file HOT 2
- ipopt and cppad tests HOT 11
- CppAD::cg::CGException: what(): GreaterThanZero cannot be called for non-parameters HOT 5
- Compiler warnings from use of bitwise '|' and '&' for bool arguments HOT 5
- Potential build mistake in third party tool in use of NDEBUG flag - CppAD compiled in Release HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cppad.