I stumbled upon free stuff in the form of Intel oneAPI toolkit and everything works great, the samples compile fine but I don't know how to specify the C++ standard in the compiler options. From what I understand DPC++ is built on top of Clang so I should be able to choose which C++ version it compiles for but I don't know how.
How do I get my C++17 code to work?
This is an ongoing issue, there are reports of other users with the same issue. As far as I know it hasn't been solved yet, what you can do meanwhile is to run the program from the command line:
Go to the folder where you installed OneApi, let's say C:\Program Files (x86)\inteloneapi\ and run setvars.bat to set environment variables.
Then compile the program using the C++17 flag, navigate to the folder where the source code is and run dpcpp filename(s).cpp -std=c++17.
Related
I'm trying to include curses.h and some functions from that lib (specifically detecting a keyboard hit without stopping), but whenever I try, it gives the error "symbols not found." I'm assuming that this is because the clang++ compiler sees curses.h as a C library. I've gathered I need to link curses.h, but I don't know how and I could not find any real guides.
I'm writing a program in C++ using VSCode and clang++ on a mac. Any help is appreciated.
For anyone else who has this problem- my clang version was outdated. It was installed, so after a brief check, I thought all was good. However, it was not able to compile (nor find some libs for some reason) the newer versions of C++. Installing the latest version of clang fixed all issues.
I'd really appreciate some help getting HElib to work on Windows 10 x64 using the MSVC 2017 compiler. I successfully managed to compile its dependency, NTL, using the same compiler by following this tutorial and also ran its tests, so it seems to work well.
However, in the case of HElib I tried generating Visual Studio projects using cmake and then compiled it successfully (see NOTE below), but running it fails. For example, I ran the Test_binaryCompare.cpp_exe test (has its own vcproj generated by cmake), but it fails because it reaches a part of code I doubt it's supposed to (it attempts to do an operation called bootstrapping and it is disabled for that test). However, on Linux it works.
LINUX: The reason I'd really like to run this on Windows is because I find it a lot easier to debug using Visual Studio. I'm also more used to Windows overall..
NOTE: Compiling HElib successfully required some modifications like fixing broken tr1 includes (e.g it was trying to include <tr1/memory> instead of just memory although the latter was actually available), suppressing the 4146 error (I also had to do this for NTL) and fixing two instances of variable-length arrays which Microsoft's compiler sadly does not support.
Without any error messages I can't really help you figure out your exact issues but I ported HElib to Windows some time ago: https://github.com/AlexanderViand/HElib/tree/Windows
It's a bit out of date but if the tests works in that version you can check the changes I made against your changes.
There's also the option that you're simply running into this issue: https://github.com/shaih/HElib/issues/228
If your linux version of NTL is slightly older, it might just be that your windows version of NTL is the buggy one.
Finally, I'd very much recommend against running HElib on Windows because without GMP it seems painfully slow.
Instead I ended up setting up a docker virtual machine and SSH'd into that from visual studio: https://hub.docker.com/r/alexanderviand/visual-studio-linux-build-box-with-helib/
Currently I'm using WSL and CLion (which supports WSL quite well) when I'm working with HElib on Windows.
I'm setting up a cross platform build environment. For that reason I've chosen to go for clang, for the, correct me if I'm wrong reasons:
Using the "same" compiler for different platform would potentially reduce the quirks that arise when getting gcc code to work with MSVC
Clang with its MSVC compatible ABI would let me work with the WINAPI as if I were using MSVC.
My question is: How do I get CMake to, based on the platform, find the correct clang to use, that is clang-cl in Windows and clang on *nix platforms ?
Please note that I'll be using Ninja generator for CMake, and the project is Qt based, if that matters.
You (the project author) don't get to choose the compiler, the user that invokes CMake chooses the compiler.
The only thing you can do from within the CMakeLists is abort with an error if you are not happy with the choice that the user made.
There are a couple of ways how the user can specify to CMake which compiler to use. Popular examples include setting the respective environment variables, passing it via -DCMAKE_CXX_COMPILER on the first CMake run (and only on the first run; you cannot change this later without re-configuring from scratch!), or by using a toolchain file.
On Visual Studio, you can also use the -T option to select a build toolchain. This allows you to build with clang from Visual Studio.
You should document in your project's Readme which compiler you expect your users to configure for CMake and maybe give them a small example how to do this via one of the methods above.
Lots of questions out there on trying to get NVCC to use the intel compiler. It doesn't work, I get that.
The most common answer that people give is to compile the device code into a library using NVCC/cl.exe and then compile the host code separately and link them. I'm attempting this, but am getting nowhere.
In VS2012 I have created a solution with 2 projects - one CUDA, the other a console application.
I have set the CUDA project to compile with VS2012 into a static library. It compiles no problem.
I have set the console application to intel 14.0 and to compile as an exe. I have also added the correct path to "Additional Library Dependencies" and have told the compiler about the CUDA library through "Additional Dependencies" (where I also told it about cudart_static.lib).
Build dependency is also set to compile the CUDA project first.
However, this setup is no good. Gives me an error which even google is at a loss for:
Error 5 error MSB4057: The target "ComputeLegacyManifestEmbedding" does not exist in the project. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Platforms\Win32\PlatformToolsets\Intel C++ Compiler XE 14.0\Toolset.targets 1162 7 rxnCalc_cpp
To verify that the linking is ok, if I set both projects to compile via VS2012 I get no problems.
OS - Windows 7 64bit (32bit application though)
Platform - VS2012
Cuda Toolkit - 6.0
Cuda Compute Version - 5.0 (and compiled as such)
So, am I just wasting my time or is there something I'm missing? It seems I have gone through a hundred posts, but I have yet to see a single success. Lots of people anxious to tell you that this is what you should do, but no one to tell you how to do it!
For everyone out there using windows and trying to get CUDA and the intel compiler to co-operate, see my initial question on how I set up the solution.
To get it to work, as per Roger Dahl's suggestion, I changed the CUDA project to a DLL.
This involved the following modifications:
Change CUDA project to dll
Add __declspec(dllexport) to CUDA wrapper function
Point console linker to the DLL lib file
This works and I am now able to utilize all intel compiler optimizations.
However, please note, I did need to set the intel compiler to only do single file IPO. Multi file IPO will cause errors, this was somewhat expected.
Hope this helps others in the same boat.
Simply put, I downloaded a port of V-USB for Arduino and can't seem to compile the example that came with it. I get the following message when trying to compile using Arduino IDE 1.0.1
avr-gcc: error: unrecognized command line option '-assembler-with-cpp'
I understand that this is most likely version incompatibility issue and could be avoided by downgrading my avr-gcc to an older version, but is it possible to do some trick to make it compile using the up to date version of avr-gcc?
Just a few notes about environment I'm trying this on
OS: Fedora release 17 (Beefy Miracle)
avr-gcc: (Fedora 4.7.2-1.fc17) 4.7.2
Arduino IDE: (arduino-1.0.1-1.fc17) 1.0.1
The -assembler-with-cpp option instructs the compiler to consider all following files to be assembler files requiring preprocessing. From a quick glance in v-usb, they provide .asm wrappers for .S files. You don't need to use those and the compiler will recognize the .S files automatically without any options.
If the problem isn't with the .asm wrappers detailed above, you can rename the files in question to .S.
Have you tried compiling without the flag? What happened?
With the hints from Jester I managed to solve this problem by updating the IDE to version 1.0.3 (1.0.2 might work as well) and it worked like a charm.
So I guess the problem wasn't the code or compiler, the problem was that the IDE 1.0.1 was expecting an older version of the avr-gcc and used a deprecated flag for compiling and simply failed since that flag is no longer available on the new compiler so you either have to downgrade the compiler or upgrade the IDE and from my perspective, upgrading is always the right choice to make.