Is it possible to compile c++ using Clang only on windows? - c++

I really tried a lot. Clang does not come with standard C++ includes, and obviously can not find them :
clang++ file.cpp -o file.out
C:\Folder\file.cpp:1:11: fatal error: 'iostream' file not found
#include <iostream>
^
1 error generated.
Passing the mingw includes by arguments, it returns another error:
clang++ -target x86_64-w64-mingw32 C:\Folder\file.cpp -IC:\MinGW\mingw64\lib\gcc\x86_64-w64-mingw32\6.3.0\include\c++ -IC:\MinGW\mingw64\lib\gcc\x86_64-w64-mingw32\6.3.0\include\c++\x86_64-w64-mingw32 -IC:\MinGW\mingw64\x86_64-w64-mingw32\include -o C:\Folder\file.out -std=c++11
clang++.exe: error: unable to execute command: program not executable
clang++.exe: error: linker command failed with exit code 1 (use -v to see invocation)
When I use -c it does not use the linker and also not generate an executable file.
Edit : I'm running on windows

Run your commands from "x64 Native Tools Command Prompt for VS 2017", or something similar. It will setup some required env vars for you.

Related

linking error with NDK (r19c): cannot find -lpthread

I have a C++ project with CMake build system. When I compile using GCC it compiles fine. But when I tried to use NDK toolchain, it shows the following error.
Linking CXX executable ../bin/my_app
/opt/r19c/linux-x86_64/toolchains/llvm/prebuilt/linux-x86_64/lib/gcc/aarch64-linux-android/4.9.x/../../../../aarch64-linux-android/bin/ld:
cannot find -lpthread
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
How can I fix this issue?

Why won't this C++ program compile and run? [duplicate]

This question already has answers here:
How can I compile and run C/C++ code in a Unix console or Mac terminal?
(19 answers)
Closed 6 years ago.
I tried to run a basic C++ file in the terminal:
#include <iostream>
using namespace std;
int main() {
cont << "This is my first C++ program!";
return 0
}
And then tried to run it in the terminal:
make learningCPP.cpp
make: *** No rule to make target `learningCPP.cpp'. Stop.
And tried:
make learningCPP
make: *** No rule to make target `learningCPP'. Stop.
And tried:
gcc learningCPP.cpp -o learningCPP.out
clang: error: no such file or directory: 'learningCPP.cpp'
clang: error: no input files
Here is the entire Bash/Clang file:
Last login: Mon May 25 07:49:21 on console
make learningCPP.cpp
make: *** No rule to make target `learningCPP.cpp'. Stop.
make learningCPP
make: *** No rule to make target `learningCPP'. Stop.
gcc learningCPP.cpp -o learningCPP.out
clang: error: no such file or directory: 'learningCPP.cpp'
clang: error: no input files
$ g++ -o lab21 learningCPP.cpp
-bash: $: command not found
$ ./lab21
-bash: $: command not found
./learningCPP.cpp
-bash: ./learningCPP.cpp: No such file or directory
./main
-bash: ./main: No such file or directory
$ g++ -o main learningCPP.cpp
-bash: $: command not found
cpp
make learningCPP.cpp
run
How can I fix it?
Judging by the errors, your file either isn't called learningCPP.cpp, or isn't in the directory you're trying to compile it from.
Rename it so it has that name, or change directory to its location, then the build command is
g++ learningCPP.cpp -o learningCPP
not gcc, and with no spurious $ before it. Alternatively, as long as the source file is present in the working directory, you could use make learningCPP.
Once that succeeds, run the program with
./learningCPP
although you'll have to read the new error messages, and use that to figure out how to fix the syntax errors, before it will compile.

Can't compile CUDA driver api sample under OS X

I'm trying to compile code that uses nvidia cuda driver api, but compilation return following error:
g++ -fPIC -o exec helloWorldDriverAPI.cpp.o -lcuda
ld: library not found for -lcuda
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [exec] Error 1
Here is sample code that i have problem with:
https://github.com/mciancia/CUDA-Driver-api
I tried pointing libraries folder manually but it didn't work for me.
Also, i don't have any problems with compiling this code under Linux.
I'm using macbook with nvidia 750m under os x 10.10 and latest driver (6.5)
This was answered elsewhere, copying the answer here to get it off the unanswered list:
You need to add the location of the library.
The LIB_CUDA variable in your Makefile should be:
LIB_CUDA := -L/usr/local/cuda/lib -lcuda

makefile error for c++

What is this error
:!make
g++ -g -I../direc1 -I./ -c final.cpp
make: g++: Command not found
make: *** [final.o] Error 127
?
You don't have g++ installed (or it's not in your $PATH variable).
The error message says it all.
You don't have g++ installed or
You have it installed but it is not in your PATH environment variable.
g++ not found indicates that your system can not find the executable file g++.
Ensure that your system knows where to search for g++.
On windows, this is done via the environment variable "path".
Add the g++ path in $PATH export PATH=$PATH:g++Path

Newbie question f2c compilation problem: cc1plus error: /include: not a directory What does this mean?

I am having problems with compiling code on my Mac (OS X, 10.6.5).
The code uses f2c.
I don't understand the error, and would really appreciate any help. I wondered if it might be a problem with my compiler, and just in case I reinstalled Xcode, which installs a new g++ compiler. But I still get the same error.
Here's the error:
cc1plus: error: /include: not a directory
cc1plus: error: /lib: not a directory
make: *** [Task1.o] Error 1
Thanks!
This may be an error in the installation of your gcc compiler. It seems it may be looking for includes in /usr/include, but it is missing the first part of the directory. Try executing:
$ gcc -v
to see what directories the gcc you're using has by default. In my case, I see
--prefix=/usr
as one of the options.