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 <boost-users@lists.boost.org> 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
https://lists.boost.org/mailman/listinfo.cgi/boost-users