Installed Intel C++ Compiler, missing /bits/c++config - c++

I installed the intel c++ compiler, and sourced the compilervars.h file. (I think this is how you are supposed to set up the compiler).
When testing a simple HelloWorld! program compiling with the icpc command for bot the .cpp and .o files I am told that there is no /bits/c++config.h file. The file is not located under /usr/include/c++/4.8/bits or /usr/include/c++/4.8.1/bits. I have read up on this problem (there were a few threads about it) but could not figure out how to fix it.
I got the program to compile by using gcc for the .cpp file and icpc for the .o file. gcc won't compile the .o file and icpc won't compile the .cpp file.
I am a rookie to setting up programming environments because I mostly have just programmed via shh on school computers. Any help would be greatly appreciated.

This shall be fixed by adding corresponding -I option to your compiling command. If your machine is x32, try something like
-I/usr/include/i386-linux-gnu/c++/4.8/
or
-I/usr/include/x86_64-linux-gnu/c++/4.8/
for x64 machine.

Related

How to compile an application that uses libraries compiled from different compilers?

My question is as the topic.
I am currently using Mingw32 compiler in Qt creator to compile my application. The problem is that I include a .lib static library and header file which compiled from Visual Studio 2017 in my application.
When I further run or compiled my application in Qt. I would be facing the error code, unrecognized file format pointing to the .lib file.
I reasonably doubt that: For example, I can not use compiler 1 to compile other libraries compiled from compiler 2.
I follow the instruction here:libwdi Installation and Compilation to compile the "libwdi.lib" file.
FYI, the reason that I use Visual Studio to compile the .lib library(libWdi) is because it's easier to achieve on my Windows OS after I tried using wingw32-make from Qt5 Tool. It is such a pain since I can not even run ./autogen.sh to generate the makefile for Mingw32 on Windows.
Appreciate any step-by-step information on how to build a workable .lib file for Qt creator, including using VS, mingw, and cross-compilers.
If the target library uses c++ features in its public interface then it is likely this is not going to work regardless of what machinations you go through. Even different versions of the same compiler often have problems in that situation.
Pure C on the other hand will usually work (on Windows non-MS tool sets will be made to at least consume the MS intermediate object format, even if not used by the compiler/linker normally).

vim plugin youcompleteme for project using scons and g++ compiler

I just installed YCM on CentOS 7. I am now at the step of generating a ".ycm_extra_conf.py" equivalent of the file for my project, which is a nested directory of c++ files, uses Scons build system and g++ (with -std=c++98) to compile the c++ files.
I have few questions:
Are the contents of the "flags" variable in ".ycm_extra_conf.py"
file the flags that are passed to the project compiler, in my case
the g++ compiler by the scons build system?
If answer to question 1 is yes, are these same flags then passed to
clang when YCM compiles the files? If so, is YCM compiling or more
technically processing the c++ files in the project to use for
semantic completion?
If answer to question 2 is yes, then I am guessing the flags I state in
the "flags" variable will not work for clang, as they are applicable to
g++. Should I do a conversion/mapping of the flags to clang?
Does YCM use clang to only front-end compile the files to produce the
AST to use for semantic completion?
Sorry about the naive questions, I am very new to YCM. Any help/guidance would be very appreciated.
Regards and thank you,
Ahmed.
The easiest way to get autocompletion working in vim with ycm is bear:
https://github.com/rizsotto/Bear
Install it and then just run:
bear scons
and you'll get your compilation database that makes ycm happy.

Location of mpi.h

I have a code on my computer uses Petsc which depends on mpi. On my computer it works well. I put it on cluster, exported paths of gcc, Petsc and openmpi (although I was using mpich on my computer I hope openmpi will also work) to LD_LIBRARY_PATH and PATH. I also changed paths in makefile. Petsc, gcc, openmpi were all available on cluster so I did not configure anything. When I did make, compiler gave error:
fatal error: mpi.h: No such file or directory
I know I did not give complete information but I can tell more if needed. How can I make the Petsc to know where is mpi.h?
Typically, you should use mpicc (or mpicxx for C++) to compile instead of gcc (or g++ for C++). These commands are simple wrappers around gcc and g++ that simply add in the appropriate -I/path/to/mpi/includes and -L/path/to/mpi/libs automatically and should be included with your openmpi install. In the absence of that, simply add -I/path/to/mpi/includes in your command to compile the appropriate files. This tells the compiler where to look for the appropriate header files.
To answer the question. To prevent a C/C++ editor from showing errors as you tyoe in the "special code" just use:
#include </usr/include/mpi/mpi.h>
which seems to be a link -- but doing that turns off the errors in Netbeans editor so I can code without distraction.
Note: Using Ubuntu 18.04 Desktop as editing machine -- and testing run machine -- but I compile manually using mpic as noted previously.
sudo mpicc c_pi.c -o c_pi
and then...
mpiexec ./c_pi
hth

Error trying to find exec "cc1d"

I'm trying to compile and run a c++ program from eclipse-c++. Unfortunately, I'm running into quite a few errors. I'm running Linux Mint 17.
My latest error occurs after building, but before the program runs. It seems g++ can't find the executable "cc1d." I've looked on the internet for a solution, but all questions seem to be asking about a missing executable called "cc1." I tried installing gcc-c++ from my package distributor, but it doesn't seem to work. I also tried making a symbolic link pointing to the program "cc." I named the link "cc1d," and it kind worked, but numerous options specified by g++ didn't work when I did that.
Actual error message:
g++: error trying to exec 'cc1d': execvp: No such file or directory
Any thoughts on how to fix this?
This is from the gcc manual:
C++ source files conventionally use one of the suffixes .C, .cc,
.cpp, .CPP, .c++, .cp, or .cxx; C++ header files often use .hh or .H;
and preprocessed C++ files use the suffix .ii. GCC recognizes files
with these names and
compiles them as C++ programs even if you call the compiler the same way as for compiling C programs (usually with the name gcc).
So to identify the code as C++, the source code files must have any of the above mentioned extensions, and not any other extensions such as .D

How to use C++ compiler by Matlab Mex compilation tool

I am trying to build a source code bundle containing m files and c++ (cpp) source files in Matlab.
The source folder has a simple Matlab Script to compile all cpp files in one folder:
function compileDir_simple(Cdir)
if nargin<1
Cdir=pwd;
end
files = dir(fullfile(Cdir,'*.cpp'));
oldDir=pwd;
cd(Cdir);
for j=1:length(files)
try
cm = sprintf('mex -largeArrayDims %s',files(j).name);
disp(cm);
eval(cm);
catch
disp(lasterr);
disp('IGNORE if the file is a C++ file which is not a mex file (ie without a mexFunction inside)');
end
end
cd(oldDir);
Inside, it uses "mex -largeArrayDims". However, my problem is, when I evaluate that statement Matlab tries to build the selected files by a C compiler which is contained in MATLAB itself. When I call mex -setup I see:
mex -setup
Please choose your compiler for building external interface (MEX) files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[1] Lcc-win32 C 2.4.1 in D:\MATLAB\R2010a\sys\lcc
[0] None
Compiler:
I installed Bloodshed C++ compiler and added its bin folder ( to the Windows Environment variables, but still I cannot see my C++ compiler in the list of installed compilers. Only Lcc-win32 appears. It will be appropriate to state that it is my first experience on compiling mex files.
A mex file on Windows is just a DLL that exports a function named mexFunction. In principle you can compile mex files with any compiler that can create Windows DLLs.
However, to do so using the mex function in MATLAB requires that MATLAB knows about your compiler. And by default MATLAB only has knowledge of a limited number of compilers. Your chosen compiler is not one of them.
Bloodshed is based on mingw. Which means that you should be able to use the Gnumex project to create a mexopts.bat file for use with your compiler.
However, I would be a little sceptical of using Bloodshed here. It is a C++ IDE and I'm not sure you particular need that. I suspect that all you are looking for is a compiler. In which case you would likely be best served by installing plain mingw.
Bloodshed C++ is not a supported compiler. Check http://www.mathworks.co.uk/support/compilers/R2014a/index.html for a list of supported compilers. Older releases are available from the same page.