GithubHelp home page GithubHelp logo

Comments (16)

bradbell avatar bradbell commented on June 28, 2024

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.

smith-nekrald avatar smith-nekrald commented on June 28, 2024

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.

smith-nekrald avatar smith-nekrald commented on June 28, 2024

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.

smith-nekrald avatar smith-nekrald commented on June 28, 2024

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.

bradbell avatar bradbell commented on June 28, 2024

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.

bradbell avatar bradbell commented on June 28, 2024

Did the message above solve the problem for you ? If so, would you please close this issue.

from cppad.

smith-nekrald avatar smith-nekrald commented on June 28, 2024

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.

bradbell avatar bradbell commented on June 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.