Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Please can someone explain how to compile and build C++ Blink Project (Linux/Raspberry PI Project in VS2017 15.5.5) code with -std=c++1z or -std=c++17 (g++),I have raspberry 3 model B set up and latest raspbian OS, I successfully connected and build my code and run with C++11/C++14 standard (default configured),

but I want to implement C++17 features with my code such as std::variants/optional so on.

I think current gcc environment set up with VS2017 not supported std::c++17,I added these parameters as project C/C++ -> Command line argument,but required headers and compiler support wasn’t there.

How can I compile and build my C++17 standard code into raspbian/Raspberry Pi system using VS2017 Crossplatform(Linux) build system with external GCC/G++ compiler which supports latest standard (std=c++latest) ?

Thank you.

If you get error messages, it's always useful to show them. In full and complete and without modifications. Some programmer dude Feb 8, 2018 at 6:30

The GCC version that comes with Raspbian is outdated and doesn't fully support C++17. You need to install a newer version of the compiler.

There's various guides on the net on how to do that. This one , for example.

I installed latest gcc on raspbian,should install gcc on windows and integrate with VS project? Buddhika Chaturanga Feb 8, 2018 at 6:46 @BuddhikaChaturanga I don't know. Does VS require GCC to be installed locally in Windows too? Nikos C. Feb 8, 2018 at 6:47 no they provided gcc, I think it does not support C++17,now I am trying to build with latest gcc compiler,I am kind of struggled with how to configure that with VS project. Buddhika Chaturanga Feb 8, 2018 at 6:50 @BuddhikaChaturanga If VS allows you to configure the path to the compiler on the remote (the Pi) then point it to the g++ binary in /usr/local. Basically, you need to find where you can configure the exact compiler executable that VS will use on the Pi. Also, specify "-std=c++17" manually in the command-line options of the compiler. Nikos C. Feb 8, 2018 at 6:53 @NikosC. I installed gcc7.20 on raspbian side already,problem is how to include those path in to VS side,currently VS using gcc/g++ path installed in windows side(installed with current VS2017). Buddhika Chaturanga Feb 8, 2018 at 7:11

If you set C++ Language Standard to Default in the C/C++ : Language properties page (2nd screenshot) and add -std=c++17 to Additional Options at the bottom of the C/C++ : Command Line page, VCLinux will add your option to the command line it sends to the Linux remote and not put in another -std= option of its own. I've tried this against GCC 6.3.0 on Debian 9 (Stretch) which I believe is also the current Raspbian version. GCC 6.3 has only partial support for C++17 and it reports __cplusplus as 201500 , without it __cplusplus is 201402 (which is C++14, the default in GCC 6.3). So the command line option is being actioned.

9-Feb I take it from your comments that you are now able to compile and build C++17 code on the Linux remote.

IntelliSense runs on the Windows host and relies on the Windows compiler. For this reason it will not recognise g++ extensions. At the time of writing, C++17 is not available as an option for VCLinux and therefore language features new to C++17 are not recognised. Presumably support will be added at some point. If you are only interested in new runtime library features then you could try bringing GCC headers onto the Windows host; this topic might be helpful in that regard Linux header file not recognized in Visual Studio 2017 Linux Project .

I installed gcc-7.2.0 version on raspbian then set it as default gcc and switch VS2017 compiler command line to -std=c++1z or -std=c++17 ,problem VS2017 intellisense won't work for std::17 only keywords ,but VS2017 linux build system managed to compiled code with remote g++-7.2.0 on raspbian and I could able attach running process on raspbian with VS2017 using gdb server (remote debug)too. Please refer these links : solarianprogrammer.com/2017/12/08/… & askubuntu.com/questions/26498/choose-gcc-and-g-version Buddhika Chaturanga Feb 9, 2018 at 6:14 For get inellisense support c++17 I tried to sync gcc-7.2.0 include with local(Win) directory using WinSCP tool ,and include it as VC++ includes on VS2017 but it wasn't successful.:( WinSCP -> winscp.net/eng/download.php Buddhika Chaturanga Feb 9, 2018 at 6:18

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question . Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers .