Error including the library
Opened this issue · 12 comments
My program cannot include the library due to the following error.
OS: Ubuntu 18.04
Compiler: g++-9 (Ubuntu 9.2.1-17ubuntu1~18.04.1) 9.2.1 20191102
CMake compilation configuration:
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
In file included from /usr/local/include/dmitigr/pgfe.hpp:26,
from /home/hou/repo/library/pgfe_example/main.cpp:1:
/usr/local/include/dmitigr/pgfe/array_conversions.hpp: In member function ‘void dmitigr::pgfe::detail::Filler_of_deepest_container<T, Optional, Container, Allocator>::operator()(std::string&&, bool, int, Types&& ...)’:
/usr/local/include/dmitigr/pgfe/array_conversions.hpp:353:82: error: too many initializers for ‘dmitigr::pgfe::detail::iClient_exception’
353 | throw detail::iClient_exception{Client_errc::excessive_array_dimensionality};
| ^
In file included from /usr/local/include/dmitigr/pgfe.hpp:26,
from /home/hou/repo/library/pgfe_example/main.cpp:1:
/usr/local/include/dmitigr/pgfe/array_conversions.hpp: In lambda function:
/usr/local/include/dmitigr/pgfe/array_conversions.hpp:771:78: error: too many initializers for ‘dmitigr::pgfe::detail::iClient_exception’
771 | throw iClient_exception{Client_errc::improper_value_type_of_container};
|
Hello,
The Pgfe library is a shared library by default. But it seems you're attempting to use Pgfe as a header-only library. In this case you have 2 options:
1 If you're using CMake:
1.1 configure in header-only mode and install (this step is not required if you don't want to install the library):
cd /path/to/build
cmake /path/to/pgfe -DDMITIGR_CEFEIKA_HEADER_ONLY=ON
1.2 install the library (this step is not required if you don't want to install the library):
cmake --install /path/to/build
1.3 use the following snippets in your CMakeLists.txt:
1.3.1 If you have not installed the library as described above (and Pgfe resides in your repo, typically in third-party/pgfe
):
set(DMITIGR_CEFEIKA_HEADER_ONLY ON CACHE BOOL "Header-only?")
add_subdirectory(third-party/pgfe)
1.3.2 If you have installed the library as described above:
cmake_minimum_required(VERSION 3.13)
project(foo)
find_package(dmitigr_cefeika REQUIRED COMPONENTS pgfe)
set(CMAKE_CXX_STANDARD 17)
set(CXX_STANDARD_REQUIRED ON)
add_executable(foo foo.cpp)
target_link_libraries(foo dmitigr::pgfe)
2 If you're not using CMake for your project, try to define DMITIGR_PGFE_HEADER_ONLY
macro before including the dmitigr/pgfe.hpp
header:
#define DMITIGR_PGFE_HEADER_ONLY
#include <dmitigr/pgfe.hpp>
I've added the reference about the usage to the documentation - https://github.com/dmitigr/pgfe#usage
Please, follow this link for more information.
If this doesn't help you or you have any other issues, please let me know. Thank you for the report!
Thanks for the detailed reply. Let's assume I want to use pgfe as a shared library (as is the way it is installed on my machine), please see my CMakeLists file:
cmake_minimum_required(VERSION 3.13)
project(pgfe_example)
find_package(dmitigr_cefeika REQUIRED COMPONENTS pgfe)
set(CMAKE_CXX_STANDARD 17)
set(CXX_STANDARD_REQUIRED ON)
add_executable(main main.cpp)
target_link_libraries(main dmitigr::pgfe)
But the following error appears:
CMake Error at CMakeLists.txt:3 (find_package):
Found package configuration file:
/usr/local/share/dmitigr_cefeika/cmake/dmitigr_cefeika-config.cmake
but it set dmitigr_cefeika_FOUND to FALSE so package "dmitigr_cefeika" is
considered to be NOT FOUND. Reason given by package:
The following imported targets are referenced, but are missing:
dmitigr::util
P.S. : Your documentation is very modern and easy to read. It does not assume a lot of things, which is very helpful to beginners like me.
Indeed, there was a problem I've just fixed. Please, pull the changes and try again. Please let me know about your success.
Thanks for the report and your feedback! If you have any problems feel free to open new issues!
Pulled the latest and re-built and re-installed. The initial error came back:
In file included from /usr/local/include/dmitigr/pgfe.hpp:26,
from /home/hou/repo/library/pgfe_example/main.cpp:1:
/usr/local/include/dmitigr/pgfe/array_conversions.hpp: In member function ‘void dmitigr::pgfe::detail::Filler_of_deepest_container<T, Optional, Container, Allocator>::operator()(std::string&&, bool, int, Types&& ...)’:
/usr/local/include/dmitigr/pgfe/array_conversions.hpp:353:82: error: too many initializers for ‘dmitigr::pgfe::detail::iClient_exception’
353 | throw detail::iClient_exception{Client_errc::excessive_array_dimensionality};
| ^
In file included from /usr/local/include/dmitigr/pgfe.hpp:26,
from /home/hou/repo/library/pgfe_example/main.cpp:1:
/usr/local/include/dmitigr/pgfe/array_conversions.hpp: In lambda function:
/usr/local/include/dmitigr/pgfe/array_conversions.hpp:771:78: error: too many initializers for ‘dmitigr::pgfe::detail::iClient_exception’
771 | throw iClient_exception{Client_errc::improper_value_type_of_container};
It seems that you trying to consume Pgfe directly. Did you use the following snippet for your project:
cmake_minimum_required(VERSION 3.13)
project(pgfe_example)
find_package(dmitigr_cefeika REQUIRED COMPONENTS pgfe)
set(CMAKE_CXX_STANDARD 17)
set(CXX_STANDARD_REQUIRED ON)
add_executable(main main.cpp)
target_link_libraries(main dmitigr::pgfe)
I've test it and it works as expected. Please, provide the CMake's output.
Yes, this is exactly my CMakelists file. Please see the CMake's output:
/usr/local/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=/usr/bin/g++-9 -G "CodeBlocks - Unix Makefiles" /home/hou/repo/library/pgfe_example
-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 9.2.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/g++-9
-- Check for working CXX compiler: /usr/bin/g++-9 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/hou/repo/library/pgfe_example/cmake-build-debug
[Finished]
====================[ Build | main | Debug ]====================================
/usr/local/bin/cmake --build /home/hou/repo/library/pgfe_example/cmake-build-debug --target main -- -j 2
[ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o
In file included from /usr/local/include/dmitigr/pgfe.hpp:26,
from /home/hou/repo/library/pgfe_example/main.cpp:1:
/usr/local/include/dmitigr/pgfe/array_conversions.hpp: In member function ‘void dmitigr::pgfe::detail::Filler_of_deepest_container<T, Optional, Container, Allocator>::operator()(std::string&&, bool, int, Types&& ...)’:
/usr/local/include/dmitigr/pgfe/array_conversions.hpp:353:82: error: too many initializers for ‘dmitigr::pgfe::detail::iClient_exception’
353 | throw detail::iClient_exception{Client_errc::excessive_array_dimensionality};
| ^
In file included from /usr/local/include/dmitigr/pgfe.hpp:26,
from /home/hou/repo/library/pgfe_example/main.cpp:1:
/usr/local/include/dmitigr/pgfe/array_conversions.hpp: In lambda function:
/usr/local/include/dmitigr/pgfe/array_conversions.hpp:771:78: error: too many initializers for ‘dmitigr::pgfe::detail::iClient_exception’
771 | throw iClient_exception{Client_errc::improper_value_type_of_container};
| ^
CMakeFiles/main.dir/build.make:62: recipe for target 'CMakeFiles/main.dir/main.cpp.o' failed
make[3]: *** [CMakeFiles/main.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/main.dir/all' failed
make[2]: *** [CMakeFiles/main.dir/all] Error 2
CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/main.dir/rule' failed
make[1]: *** [CMakeFiles/main.dir/rule] Error 2
Makefile:118: recipe for target 'main' failed
make: *** [main] Error 2
Please, pull the changes, rebuild, reinstall and try again.
Pulled the latest and re-built and re-installed. There is a different error:
====================[ Build | main | Debug ]====================================
/usr/local/bin/cmake --build /home/hou/repo/library/pgfe_example/cmake-build-debug --target main -- -j 2
Scanning dependencies of target main
[ 50%] Building CXX object CMakeFiles/main.dir/main.cpp.o
In file included from /usr/local/include/dmitigr/pgfe/array_conversions.hpp:11,
from /usr/local/include/dmitigr/pgfe.hpp:26,
from /home/hou/repo/library/pgfe_example/main.cpp:1:
/usr/local/include/dmitigr/pgfe/exceptions.hpp:59:10: fatal error: dmitigr/pgfe/exceptions.cpp: No such file or directory
59 | #include "dmitigr/pgfe/exceptions.cpp"
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
CMakeFiles/main.dir/build.make:62: recipe for target 'CMakeFiles/main.dir/main.cpp.o' failed
make[3]: *** [CMakeFiles/main.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/main.dir/all' failed
make[2]: *** [CMakeFiles/main.dir/all] Error 2
CMakeFiles/Makefile2:84: recipe for target 'CMakeFiles/main.dir/rule' failed
make[1]: *** [CMakeFiles/main.dir/rule] Error 2
Makefile:118: recipe for target 'main' failed
make: *** [main] Error 2
CMake configuration is ok.
/usr/local/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=/usr/bin/g++-9 -G "CodeBlocks - Unix Makefiles" /home/hou/repo/library/pgfe_example
-- The C compiler identification is GNU 7.4.0
-- The CXX compiler identification is GNU 9.2.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/g++-9
-- Check for working CXX compiler: /usr/bin/g++-9 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/hou/repo/library/pgfe_example/cmake-build-debug
[Finished]
Okay, it should works now. Please try again. I looking forward for your feedback. Thank you!
No problem. Have the following error at build stage:
The mode of building shared Dmitigr Cefeika libraries is set.
Dmitigr Cefeika build type it set to Debug
-- Configuring done
CMake Error at CMakeLists.txt:184 (add_library):
Cannot find source file:
lib/dmitigr/pgfe/exceptions.cpp
Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
.hpp .hxx .in .txx
CMake Error at CMakeLists.txt:184 (add_library):
No SOURCES given to target: pgfe
-- Build files have been written to: /home/hou/lib/pgfe
Ugh. And this is one of the reasons I dislike CMake. Fixed, please try again and report! Thanks for your patience.
Ugh. And this is one of the reasons I dislike CMake. Fixed, please try again and report! Thanks for your patience.
No problem. Just tried again and it is working!