The development system is:
MacBook Pro Intel i9
MacOS Big Sur 11.4
gcc version 11.1.0 (Homebrew GCC 11.1.0_1)
clang version 12.0.0
I'm having trouble compiling some examples from the book 'Boost C ++ Application Development Cookbook’.
The problem occurs only with g ++, with clang there is no error.
Mistakes only occur when linking to -lboost_program_options, -lboost_system and -lboost_filesystem, with any other library (eg -lboost_chrono) everything is fine.
Furthermore, it should be noted that by linking with -lboost_system and -lboost_filesystem no compilation / linking errors are obtained but we get a SEGMENTATION FAULT (ONLY when compiling with g++, compiling with Clang the program run fine), instead linking with -lboost_program_options results in linking errors.
This is the example:
#include
On 23/07/2021 07:57, Stefano Gragnani via Boost-users wrote:
The development system is: MacBook Pro Intel i9 MacOS Big Sur 11.4 gcc version 11.1.0 (Homebrew GCC 11.1.0_1) clang version 12.0.0
I'm having trouble compiling some examples from the book 'Boost C ++ Application Development Cookbook’. The problem occurs *only* *with g ++,* *with clang there is no error.* Mistakes only occur when linking to -lboost_program_options, -lboost_system and -lboost_filesystem, with any other library (eg -lboost_chrono) everything is fine.
Did you compile the libraries with g++ or are they clang compiled? I would expect that mixing the 2 would cause issues. -- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
I compile with g++-11 without mixing, if I compile with clang 12 all compile fine.
Il giorno 24 lug 2021, alle ore 12:33, John Maddock via Boost-users
ha scritto: On 23/07/2021 07:57, Stefano Gragnani via Boost-users wrote:
The development system is: MacBook Pro Intel i9 MacOS Big Sur 11.4 gcc version 11.1.0 (Homebrew GCC 11.1.0_1) clang version 12.0.0
I'm having trouble compiling some examples from the book 'Boost C ++ Application Development Cookbook’. The problem occurs *only* *with g ++,* *with clang there is no error.* Mistakes only occur when linking to -lboost_program_options, -lboost_system and -lboost_filesystem, with any other library (eg -lboost_chrono) everything is fine.
Did you compile the libraries with g++ or are they clang compiled? I would expect that mixing the 2 would cause issues.
-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
Hi, you are right probably some gcc / clang mix was there, now i recompiled boost with gcc-11 and the linking errors are gone but now i get errors at runtime. ./bootstrap.sh --prefix=/usr/local/boost-1.76.0_gcc-11_libs In project-config.jam: #if ! clang in [ feature.values <toolset> ] #{ # using clang ; #} #project : default-build <toolset>clang ; using gcc : 11.1.0 : /usr/local/Cellar/gcc/11.1.0_1/bin/g++-11 ; and then: sudo ./b2 cxxflags=-std=gnu++20 install export DYLD_LIBRARY_PATH=/usr/local/boost-1.76.0_gcc-11_libs/lib:$DYLD_LIBRARY_PATH and at runtime I get: dyld: Symbol not found: __ZN5boost15program_options3argB5cxx11E Referenced from: /Users/stegra/Projects/VSCode/BoostCookbook/./Chapter01/01_A_program_options_base/main Expected in: /usr/local/lib/libboost_program_options.dylib in /Users/stegra/Projects/VSCode/BoostCookbook/./Chapter01/01_A_program_options_base/main Thanks Stefano
Il giorno 24 lug 2021, alle ore 12:33, John Maddock via Boost-users
ha scritto: On 23/07/2021 07:57, Stefano Gragnani via Boost-users wrote:
The development system is: MacBook Pro Intel i9 MacOS Big Sur 11.4 gcc version 11.1.0 (Homebrew GCC 11.1.0_1) clang version 12.0.0
I'm having trouble compiling some examples from the book 'Boost C ++ Application Development Cookbook’. The problem occurs *only* *with g ++,* *with clang there is no error.* Mistakes only occur when linking to -lboost_program_options, -lboost_system and -lboost_filesystem, with any other library (eg -lboost_chrono) everything is fine.
Did you compile the libraries with g++ or are they clang compiled? I would expect that mixing the 2 would cause issues.
-- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users
Hello,
export DYLD_LIBRARY_PATH=/usr/local/boost-1.76.0_gcc-11_libs/lib:$DYLD_LIBRARY_PATH
and at runtime I get:
dyld: Symbol not found: __ZN5boost15program_options3argB5cxx11E
Referenced from: /Users/stegra/Projects/VSCode/BoostCookbook/./Chapter01/01_A_program_options_base/main
Expected in: /usr/local/lib/libboost_program_options.dylib
in /Users/stegra/Projects/VSCode/BoostCookbook/./Chapter01/01_A_program_options_base/main
It seems, that libboost_program_options.dylib is piced from /usr/local/lib instead of =/usr/local/boost-1.76.0_gcc-11_libs/lib. Macos is different from linux in finding dynamic libraries. The most important difference is, that in macos, shared libraries usually are referred by absolute path. You can see this, when doing otool -l on an execuatable. You can use install_name_tool to change the path of the shared objects referenced within an executable or shared object. Klebsch Mario Funktion | R&D Tel: +49 (0) 531 38 701 718 Raum: Braunschweig, E20 Diese E-Mail und die an sie angehängten Dateien sind ausschließlich für Personen oder Institutionen bestimmt, deren Namen oben aufgeführt sind. Sie können Informationen enthalten, die durch das Berufsgeheimnis geschützt sind und deren Weitergabe strengstens untersagt ist. Jede elektronische Nachricht kann geändert werden. ACTIA lehnt jede Verantwortung für diese Nachricht ab. Der Inhalt dieser Nachricht stellt keine Verpflichtung seitens unseres Unternehmens dar. Wenn Sie kein Empfänger sind, weisen wir Sie darauf hin, dass das Lesen, Vervielfältigen oder Verteilen strengstens untersagt ist. Wir bitten Sie daher, uns umgehend über diesen Brief zu informieren und diese Nachricht sowie eventuell beigefügte Unterlagen aus Ihrem Postfach zu löschen. Danke. This e-mail and the files attached to it are intended exclusively for persons or institutions whose names are listed above. They may contain information that is protected by professional secrecy and the disclosure of which is strictly prohibited. Any electronic message can be modified. ACTIA declines all responsibility for this message. The content of this message does not represent a commitment on the part of our company. If you are not a recipient, we would like to point out that reading, copying or distribution is strictly prohibited. We therefore ask you to inform us immediately about this letter and to delete this message and any accompanying documents from your mailbox. Thank you.
Yes, that's it, if I launch the program from the terminal it works correctly but if I launch it from Visual Studio Code I get the error described. In task.json I use: { "label": "Run Project", "type": "shell", "command": "./Chapter01/01_A_program_options_base/main --apples=60 --oranges=20", "group": { "kind": "build", "isDefault": true }, "problemMatcher": [] } visual studio code ignores the environment variable DYLD_LIBRARY_PATH or DYLD_FALLBACK_LIBRARY_PATH. If i run the program from the terminal integrated in visual studio code i get the correct result. Does anyone know how to set the path for libraries in non-standard path in visual studio code? Thanks Stefano
Il giorno 27 lug 2021, alle ore 10:00, Klebsch, Mario via Boost-users
ha scritto: Hello,
export DYLD_LIBRARY_PATH=/usr/local/boost-1.76.0_gcc-11_libs/lib:$DYLD_LIBRARY_PATH and at runtime I get: dyld: Symbol not found: __ZN5boost15program_options3argB5cxx11E Referenced from: /Users/stegra/Projects/VSCode/BoostCookbook/./Chapter01/01_A_program_options_base/main Expected in: /usr/local/lib/libboost_program_options.dylib in /Users/stegra/Projects/VSCode/BoostCookbook/./Chapter01/01_A_program_options_base/main
It seems, that libboost_program_options.dylib is piced from /usr/local/lib instead of =/usr/local/boost-1.76.0_gcc-11_libs/lib.
Macos is different from linux in finding dynamic libraries. The most important difference is, that in macos, shared libraries usually are referred by absolute path. You can see this, when doing otool -l on an execuatable.
You can use install_name_tool to change the path of the shared objects referenced within an executable or shared object.
Klebsch Mario Funktion | R&D
Tel: +49 (0) 531 38 701 718 Raum: Braunschweig, E20
Diese E-Mail und die an sie angehängten Dateien sind ausschließlich für Personen oder Institutionen bestimmt, deren Namen oben aufgeführt sind. Sie können Informationen enthalten, die durch das Berufsgeheimnis geschützt sind und deren Weitergabe strengstens untersagt ist. Jede elektronische Nachricht kann geändert werden. ACTIA lehnt jede Verantwortung für diese Nachricht ab. Der Inhalt dieser Nachricht stellt keine Verpflichtung seitens unseres Unternehmens dar. Wenn Sie kein Empfänger sind, weisen wir Sie darauf hin, dass das Lesen, Vervielfältigen oder Verteilen strengstens untersagt ist. Wir bitten Sie daher, uns umgehend über diesen Brief zu informieren und diese Nachricht sowie eventuell beigefügte Unterlagen aus Ihrem Postfach zu löschen. Danke. This e-mail and the files attached to it are intended exclusively for persons or institutions whose names are listed above. They may contain information that is protected by professional secrecy and the disclosure of which is strictly prohibited. Any electronic message can be modified. ACTIA declines all responsibility for this message. The content of this message does not represent a commitment on the part of our company. If you are not a recipient, we would like to point out that reading, copying or distribution is strictly prohibited. We therefore ask you to inform us immediately about this letter and to delete this message and any accompanying documents from your mailbox. Thank you.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org mailto:Boost-users@lists.boost.org https://lists.boost.org/mailman/listinfo.cgi/boost-users https://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (3)
-
John Maddock
-
Klebsch, Mario
-
Stefano Gragnani