coin-or / SHOT

A solver for mixed-integer nonlinear optimization problems
https://shotsolver.dev
Eclipse Public License 2.0
119 stars 25 forks source link

Compile ld.lld: error: undefined symbol: __android_log_write #175

Closed defencedog closed 8 months ago

defencedog commented 8 months ago

My configure step is OK

build$ LDFLAGS="-llog" cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX -DHAS_CBC=on -DHAS_IPOPT=on                            -- The CXX compiler identification is Clang 17.0.6         -- The C compiler identification is Clang 17.0.6           -- Detecting CXX compiler ABI info                         -- Detecting CXX compiler ABI info - done                  -- Check for working CXX compiler: /data/data/com.termux/files/usr/bin/c++ - skipped                                  -- Detecting CXX compile features                          -- Detecting CXX compile features - done                   -- Detecting C compiler ABI info                           -- Detecting C compiler ABI info - done                    -- Check for working C compiler: /data/data/com.termux/files/usr/bin/cc - skipped                                     -- Detecting C compile features                            -- Detecting C compile features - done                     -- Looking for C++ include filesystem                      -- Looking for C++ include filesystem - found              -- Performing Test CAN_COMPILE_FS_WITHOUT_LINK             -- Performing Test CAN_COMPILE_FS_WITHOUT_LINK - Success   -- Git hash: 08b87f56                                      -- Found PkgConfig: /data/data/com.termux/files/usr/bin/pkg-config (found version "0.29.2")                           CMake Warning (dev) at /data/data/com.termux/files/usr/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:438 (message):                                                 The package name passed to `find_package_handle_standard_args` (PkgConfig)                                            does not match the name of the calling package (CBC).  This can lead to                                               problems in calling code that expects `find_package` result variables                                                 (e.g., `_FOUND`) to follow a certain pattern.            Call Stack (most recent call first):                         /data/data/com.termux/files/usr/share/cmake-3.28/Modules/FindPkgConfig.cmake:99 (find_package_handle_standard_args)   misc/FindCBC.cmake:6 (include)                             CMakeLists.txt:189 (find_package)                        This warning is for project developers.  Use -Wno-dev to suppress it.                                                                                                            -- Checking for one of the modules 'cbc'                   -- Cbc found using Pkg-config:                                Include directories found: /data/data/com.termux/files/usr/include/coin;/data/data/com.termux/files/usr/include/coin-or/asl;/data/data/com.termux/files/usr/include/coin         Library directories found: /data/data/com.termux/files/usr/lib                                                     -- Found CBC: CbcSolver;Cbc;coinasl;Cgl;OsiClp;ClpSolver;Clp;Osi;CoinUtils;m                                          -- Checking for one of the modules 'ipopt'                 -- Cbc include files will be used from: /data/data/com.termux/files/usr/include/coin;/data/data/com.termux/files/usr/include/coin-or/asl;/data/data/com.termux/files/usr/include/coin                                                       -- The following Cbc libraries will be used from: /data/data/com.termux/files/usr/lib                                    CbcSolver;Cbc;coinasl;Cgl;OsiClp;ClpSolver;Clp;Osi;CoinUtils;m                                                     -- Ipopt include files will be used from: /opt/ipopt/include/coin                                                     -- The following Ipopt libraries will be used from: /data/data/com.termux/files/usr/lib                                  ipopt                                                   -- Configuring done (11.7s)                                -- Generating done (0.1s)                                  -- Build files have been written to: /data/data/com.termux/files/home/ipopt_dev/SHOT/build

Error step

[ 14%] Completed 'cppad'                                   [ 14%] Built target cppad                                  [100%] Linking CXX executable example                      ld.lld: error: undefined symbol: __android_log_write       >>> referenced by android_sink.h:56 (/data/data/com.termux/files/home/ipopt_dev/SHOT/ThirdParty/spdlog/include/spdlog/sinks/android_sink.h:56)                                   >>>               CMakeFiles/example.dir/example.cpp.o:(spdlog::sinks::android_sink<std::__ndk1::mutex>::sink_it_(spdlog::details::log_msg const&))                              >>> referenced by android_sink.h:61 (/data/data/com.termux/files/home/ipopt_dev/SHOT/ThirdParty/spdlog/include/spdlog/sinks/android_sink.h:61)                                   >>>               CMakeFiles/example.dir/example.cpp.o:(spdlog::sinks::android_sink<std::__ndk1::mutex>::sink_it_(spdlog::details::log_msg const&))                              >>> referenced by android_sink.h:61 (/data/data/com.termux/files/home/ipopt_dev/SHOT/ThirdParty/spdlog/include/spdlog/sinks/android_sink.h:61)                                   >>>               CMakeFiles/example.dir/example.cpp.o:(spdlog::sinks::android_sink<std::__ndk1::mutex>::sink_it_(spdlog::details::log_msg const&))                              c++: error: linker command failed with exit code 1 (use -v to see invocation)                                         make[5]: *** [example/CMakeFiles/example.dir/build.make:98: example/example] Error 1                                  make[4]: *** [CMakeFiles/Makefile2:126: example/CMakeFiles/example.dir/all] Error 2                                   make[3]: *** [Makefile:156: all] Error 2                   make[2]: *** [CMakeFiles/spdlog.dir/build.make:86: spdlog/src/spdlog-stamp/spdlog-build] Error 2                      make[1]: *** [CMakeFiles/Makefile2:133: CMakeFiles/spdlog.dir/all] Error 2                                            make: *** [Makefile:156: all] Error 2

I appended LDFLAGS="-llog" in a bid to resolve the issue as explained here https://stackoverflow.com/questions/4455941/undefined-reference-to-android-log-print

The error originated previously here https://github.com/catchorg/Catch2/issues/2576#issuecomment-1323915624 But i resolved it by passing this argument -DCATCH_CONFIG_ANDROID_LOGWRITE=OFF

Any equivalent argument?

defencedog commented 8 months ago

Ok solved it by prefixing export LDFLAGS="-llog" && cmake .. instead LDFLAGS="-llog" && cmake ..