Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

...\boost\preprocessor\control\iif.hpp|25|error: 'BOOST_PP_IIF_0' was not declared in this scope| #256

Open
nimahamidian opened this issue May 1, 2023 · 11 comments

Comments

@nimahamidian
Copy link

nimahamidian commented May 1, 2023

Hi
When I compile the amgcl example "cpr.cpp" in code:blocks IDE, it gives the following error:

...\boost\preprocessor\control\iif.hpp|25|error: 'BOOST_PP_IIF_0' was not declared in this scope|

I tried to compile this example in several IDEs and operating systems, but it didn't resolve. Any help would be really appreciated.

@ddemidov
Copy link
Owner

ddemidov commented May 2, 2023

This looks like a boost.preprocessor issue (which I can not reproduce by the way). Here they recommend to define BOOST_PP_VARIADICS to 1. Can you try that?

@nimahamidian
Copy link
Author

nimahamidian commented May 2, 2023

Thank you for the response.
I should mention that I am not professional in C++, especially with header file syntax; my speciality is MATLAB.
I saw and tried the solution you have mentioned, by adding:

#if defined(BOOST_PP_VARIADICS)
#if !BOOST_PP_VARIADICS
#error BOOST_PP_VARIADICS cannot be defined as 0 when using Expected
#endif
#else
#define BOOST_PP_VARIADICS 1
#endif

to a setup.hpp file (located in ...\boost\boost\log\utility\setup.hpp), but it didn't work. I downloaded and extracted boost_1_82_0.7z for windows from boost.org, and amgcl from github.com/ddemidov/amgcl, so I am surprised why this problem doesn't reproduce for you. Any other hint would be highly appreciated

@ddemidov
Copy link
Owner

ddemidov commented May 2, 2023

How did you create the project? Did you use cmake CMakeLists.txt provided with the project? If not, I recommend to use it and see if that solves your problem. Or at least look at the command line options that are set there for msvc compiler:

amgcl/CMakeLists.txt

Lines 83 to 92 in 276a649

$<$<CXX_COMPILER_ID:MSVC>:/bigobj>
$<$<CXX_COMPILER_ID:MSVC>:/wd4715>
)
target_compile_definitions(amgcl INTERFACE
# Compiler is MSVC:
$<$<CXX_COMPILER_ID:MSVC>:NOMINMAX>
$<$<CXX_COMPILER_ID:MSVC>:_USE_MATH_DEFINES>
$<$<CXX_COMPILER_ID:MSVC>:_VARIADIC_MAX=10>
$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>

@nimahamidian
Copy link
Author

nimahamidian commented May 6, 2023

Thank you for your important remark
In fact I didn't use cmake for building the project, but I just used code:blocks for building the amgcl example (cpr.cpp) using the GCC compiler. I guess this should be the problem. Now I am trying to build the amgcl example (cpr.cpp) by cmake (in which I am a beginner). It seems to me that amgcl doesn't need to be build (since it consists of header files), and only the cpr.cpp should be built.
When I got a result I will comment here. Thanks

@nimahamidian
Copy link
Author

nimahamidian commented May 7, 2023

Hi,
thanks for your helpful comments.
Based on guidance from this link I could run an independent project by opening CMakeLists.txt file in Visual Studio 2017. However when I wanted to build the projects in 'examples' and 'tutorials' folders (such as cpr.cpp) in the amgcl library, it gives error, such as not finding the nonexistent library 'amgcl.lib', or the need to compile by '/bigobj' which I couldn't resolve. Any hint would be appreciated.

@ddemidov
Copy link
Owner

ddemidov commented May 7, 2023

It looks like you ran cmake directly in the examples folder, and not at the top level of amgcl, as you should. If you did that, then cmake would create a project for building amgcl.lib, and it would also setup the /bigobj compile flag.

@nimahamidian
Copy link
Author

nimahamidian commented May 7, 2023

I am trying to exactly describe the issue:

  • based on this link, I go to the folder amgcl-master/build and enter the following:
    cmake -DAMGCL_BUILD_TESTS=ON -DAMGCL_BUILD_EXAMPLES=ON ..
    it gives some negative messages such as:
could not find Boost (missing BOOST_INCLUDE_DIR program_options serialization unit_test_framework)
could not find CUDA
could not find MPI_C
could not find MPI_CXX
could not find MPI

maybe this is the source of error but currently I don't know how to make it recognize the boost, cuda and mpi. At the end it says that the build files have been written in ../amgcl-master/build.

  • After this, when I make a cmake project according to this link, and build and run it in VS 2017, it recognizes amgcl and there is no problem.
  • However, when I open the CMakeLists.txt at the root amgcl-master folder by VS 2017, and when I build it, it gives 0 files built, and then when I want to build cmake projects in 'examples' or 'tutorials' folders, it gives errors related to nonexistent amgcl.lib or compiling with /bigobj.

Maybe I should download CUDA, and OpenMPI and devise the cmake to recognize boost, cuda, and mpi.

@ddemidov
Copy link
Owner

ddemidov commented May 8, 2023

The only thing that is required and was not found is Boost: it is used in many examples (which are not built in case boost is not found), so you should try to tell cmake where it is located:

cmake \
    -G "Visual Studio 15 2017" \
    -DAMGCL_BUILD_TESTS=ON \
    -DAMGCL_BUILD_EXAMPLES=ON \
    -DBOOST_ROOT=</path/to/your/boost/installation>

@nimahamidian
Copy link
Author

nimahamidian commented May 8, 2023

Thanks a lot. By executing the command you wrote, (after building the Boost by two commands for building boost libraries i.e.: "bootstrap" and ".\b2" commands; which I didn't do previously), now it finds Boost in cmd, but when I open the amgcl project, in the stage of "target info extraction" it says that "Could NOT find Boost". As you said this would be a main problem. The VS call-stack shows that the problem root is at line 31 of CMakeLists.txt in amgcl root folder (i.e. find-package(boost)...), then at line 1618 of FindBoost.cmake (Boost_MISSING_DEPENDENCIES...), and finally at line 959 of FindBoost.cmake (Boost_COMPONENT_DEPENDENCIES...).

@ddemidov
Copy link
Owner

ddemidov commented May 8, 2023

Do you use x64 architecture in VS? In that case I think you need to specify --address-model=64, and correct toolset when building boost (I don't have a windows machine, so I am not sure if this still applies): https://stackoverflow.com/questions/43946538/how-to-build-boost-1-64-in-64-bits.

@nimahamidian
Copy link
Author

Yes I use x64-debug configuration in VS. I am trying what you just said.
thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants