Re: Problem linking the Class++ example with Conan and CMake

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>

> Le 30 juin 2019 à 18:45, Wouter Beek <[email protected]> a écrit :
> 
> Hi,

Hi Wouter,

> I'm trying to build the example calc++ program with Conan and CMake:
> https://github.com/wouterbeek/conan-cmake-bison-flex

That sounds interesting!

> The promise of Conan and CMake is that one could ultimately build a
> Flex/Bison program on multiple platforms, which is more difficult with
> traditional build systems.
> 
> Unfortunately, I'm currently stuck at the linking phase (see the
> output below).  Does anybody know what I'm doing wrong / how to
> proceed?

Well, your instruction to clone and compile are obsolete, the project,
I guess, has changed name.  And indeed, it does not work, but sooner
than in your case.

> -- Conan: Automatic detection of conan settings from cmake
> In file included from <stdin>:1:
> In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string:500:
> In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:176:
> In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/__string:56:
> In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/algorithm:642:
> In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/cstring:61:
> /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string.h:61:15: fatal error: 'string.h' file not found
> #include_next <string.h>
>               ^~~~~~~~~~
> 1 error generated.
> -- Conan: Settings= -s;build_type=Debug;-s;compiler=apple-clang;-s;compiler.version=10.0;-s;compiler.libcxx=libc++
> -- Conan executing: conan install /tmp/conan-cmake-bison-flex/conanfile.txt -s build_type=Debug -s compiler=apple-clang -s compiler.version=10.0 -s compiler.libcxx=libc++ -g=cmake --build=missing
> CMake Error at Debug/conan.cmake:399 (message):
>   Conan install failed='No such file or directory'
> Call Stack (most recent call first):
>   Debug/conan.cmake:485 (conan_cmake_install)
>   CMakeLists.txt:9 (conan_cmake_run)
> 
> 
> -- Configuring incomplete, errors occurred!
> See also "/tmp/conan-cmake-bison-flex/Debug/CMakeFiles/CMakeOutput.log".


> PS: The Calc++ example seems to be partially missing from Git master.
> Is this intentional?

Yes, it is extracted from the documentation.  You should start from a
tarball to get the full example.


> /home/wbeek/.conan/data/bison/3.3.2/bincrafters/stable/package/7e924ee4fb46c796a19516dcf956dd2bc0171a91/bin/bison
> --defines=/home/wbeek/tmp/calc++/Debug/Parser.hpp -o
> /home/wbeek/tmp/calc++/Debug/Parser.cpp
> /home/wbeek/tmp/calc++/Parser.yy
> cd /home/wbeek/tmp/calc++/Debug && /usr/bin/cmake -E cmake_depends
> "Unix Makefiles" /home/wbeek/tmp/calc++ /home/wbeek/tmp/calc++
> /home/wbeek/tmp/calc++/Debug /home/wbeek/tmp/calc++/Debug
> /home/wbeek/tmp/calc++/Debug/CMakeFiles/calc++.dir/DependInfo.cmake
> --color=
> Dependee "/home/wbeek/tmp/calc++/Debug/CMakeFiles/calc++.dir/DependInfo.cmake"
> is newer than depender
> "/home/wbeek/tmp/calc++/Debug/CMakeFiles/calc++.dir/depend.internal".
> Dependee "/home/wbeek/tmp/calc++/Debug/CMakeFiles/CMakeDirectoryInformation.cmake"
> is newer than depender
> "/home/wbeek/tmp/calc++/Debug/CMakeFiles/calc++.dir/depend.internal".
> Scanning dependencies of target calc++
> gmake[2]: Leaving directory '/home/wbeek/tmp/calc++/Debug'
> /usr/bin/gmake -f CMakeFiles/calc++.dir/build.make CMakeFiles/calc++.dir/build
> gmake[2]: Entering directory '/home/wbeek/tmp/calc++/Debug'

Reading build logs from cmake is really painful.

> [ 50%] Building CXX object CMakeFiles/calc++.dir/Driver.cpp.o
> /usr/bin/c++   -I/home/wbeek/tmp/calc++/Debug -I/home/wbeek/tmp/calc++
> -g   -o CMakeFiles/calc++.dir/Driver.cpp.o -c
> /home/wbeek/tmp/calc++/Driver.cpp
> [ 66%] Building CXX object CMakeFiles/calc++.dir/Parser.cpp.o
> /usr/bin/c++   -I/home/wbeek/tmp/calc++/Debug -I/home/wbeek/tmp/calc++
> -g   -o CMakeFiles/calc++.dir/Parser.cpp.o -c
> /home/wbeek/tmp/calc++/Debug/Parser.cpp
> [ 83%] Building CXX object CMakeFiles/calc++.dir/Lexer.cpp.o
> /usr/bin/c++   -I/home/wbeek/tmp/calc++/Debug -I/home/wbeek/tmp/calc++
> -g   -o CMakeFiles/calc++.dir/Lexer.cpp.o -c
> /home/wbeek/tmp/calc++/Debug/Lexer.cpp
> [100%] Linking CXX executable bin/calc++
> /usr/bin/cmake -E cmake_link_script CMakeFiles/calc++.dir/link.txt --verbose=1
> /usr/bin/c++    -g   CMakeFiles/calc++.dir/Driver.cpp.o
> CMakeFiles/calc++.dir/Parser.cpp.o CMakeFiles/calc++.dir/Lexer.cpp.o
> -o bin/calc++ /home/wbeek/.conan/data/flex/2.6.4/bincrafters/stable/package/7e924ee4fb46c796a19516dcf956dd2bc0171a91/lib/libfl.a
> /usr/bin/ld: /home/wbeek/.conan/data/flex/2.6.4/bincrafters/stable/package/7e924ee4fb46c796a19516dcf956dd2bc0171a91/lib/libfl.a(libmain.o):
> in function `main':
> /home/wbeek/.conan/data/flex/2.6.4/bincrafters/stable/build/7e924ee4fb46c796a19516dcf956dd2bc0171a91/source_subfolder/src/libmain.c:33:
> undefined reference to `yylex'

Have you checked the content of the scanner file?  Have you used `nm` to look for the names of the symbols in the object files and see where yylex is defined?


_______________________________________________
[email protected] https://lists.gnu.org/mailman/listinfo/help-bison
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.