meelgroup / approxmc

Approximate Model Counter
Other
70 stars 26 forks source link

Problem with Boost program_options #10

Closed allrtaken closed 4 years ago

allrtaken commented 4 years ago

Hello,

I am trying to install ApproxMC (and Cryptominisat) on a machine which comes with Boost preinstalled (and I do not have admin privileges) . However, due to some unknown linking problem, I get "undefined reference" errors for boost program_options functions. At this point I'm unsure about the reason for this -- the output of CMake confirmed that Boost along with program_options was found, but when linking the ApproxMC executable in the final step of running make, it throws the undefined reference errors. I faced the same problem while compiling cryptominisat as well, but I was able to circumvent it by fiddling with CMakeLists.txt. The same thing didn't work for ApproxMC

As the problem might be on my side, I was wondering if there is a cleaner way to disable Boost all together, like setting some flag. I have attached a file approxmc_output.txt showing some of the errors thrown during make. Thanks a lot!

allrtaken commented 4 years ago

As an aside, it seems that the root cause of the issue might be because of presence of multiple installations of Boost with different versions. Is there a way to manually specify the relevant paths (include, lib etc) to boost for Cmake?

msoos commented 4 years ago

Hi,

You can just try to use the Docker image -- it should work out of the box, and the speed is essentially the same. Please see the top of the README file. Otherwise, you can use our static releases here: https://github.com/meelgroup/ApproxMC/releases Just download and extract the file https://github.com/meelgroup/ApproxMC/releases/download/3.0/approxmc-linux-x64.gz and it should work fine.

I am surprised with boost-finding not working, it seems to be working in at least 4 different environments and you are the first to report it not working. I am using the same setup in CryptoMiniSat, STP and ApproxMC and nobody has reported it not working for a long while (a few years now) so there may be something weird with your system's setup?

I suggest you try using the Docker image or the static binaries. They should work out-of-the-box, without any issues. Please comment on this issue if not, I will then re-open. Otherwise, I am closing this, as one of the two alternative solutions should work :) If you find the issue with the CMakeLists.txt, please let us know, and we'll fix it as per your recommendation!

I hope the above helped,

Mate

allrtaken commented 4 years ago

Thanks for your suggestions -- I am now just using the static release.

Yes, the issue is on my side -- I suspect the problem is because there are multiple installations of boost with different versions but I am not sure. Is there is a variable I could set manually when doing cmake to point to the correct Boost directory? If not, then I'll just continue using the static build. Thanks!

msoos commented 4 years ago

Cool, glad it works now! Cheers and good luck,

Mate

allrtaken commented 3 years ago

Hello,

Reopening this issue since I potentially found the source of the problem.

Just some background: I have been using the static release of ApproxMC which was working fine, but it is now out of date. As I need to use the latest version of APMC, I am trying to compile from source. Compilation of the latest version of CryptoMiniSAT goes through fine, but the build of ApproxMC fails at the last step while linking the ApproxMC executable because an old version (1.10) of the Boost library is used when linking which has an outdated program_options component.

The problem, I believe, might be due to the CMakeLists.txt of ApproxMC, which does not have the following lines of code that the Cryptominisat CMakeLists.txt has:

#command-line parsing executable needs boost program-options  
if(NOT Boost_FOUND)
    set(ONLY_SIMPLE ON)
    message(STATUS "Only building executable with few command-line options because the boost program_options library were not available")
else()
    message(STATUS "Boost -- found at library: ${Boost_LIBRARIES}")
    message(STATUS "Boost -- adding '${Boost_LIBRARY_DIRS}' to link directories")
    link_directories(${Boost_LIBRARY_DIRS})
endif()

When running CMake for compiling ApproxMC, it detects the presence of new version of BOOST (1.61) which has program_options, but it doesn't store the library path for linking correctly as Cryptominisat does above with the line link_directories(${Boost_LIBRARY_DIRS}) Therefore, during linking it searches the default directories, which in my case contain older versions of Boost.

Would it be possible to update the CMakeLists.txt of ApMC with something similar to the code above that is used in Cryptominisat? I may be wrong, but I believe that should resolve the Boost program_options linking errors that I am facing.

Thanks in advance!

Aditya

allrtaken commented 3 years ago

Actually the problem got resolved with adding the following line at the beginning of approxmc's cmakelists.txt: enable_language( CXX )

It turned out that cmake was detecting and using an older version of GCC (4.8). The above line (which is present in cryptominisat's cmakelists.txt) enabled the correct version which resolved the problem with boost (which I believe was compiled with the newer version. I didn't have to add the lines dealing with boost from my previous comment.

Thanks, Aditya

msoos commented 3 years ago

Ah, nice! Thanks for this, I completely missed it. I now added it in: 8dab17d7ab73d3b95838d50805ddbb2eac7292e0

Thanks again,

Mate