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
Related
I am using GNU g++ to compile an older c++ project with many source files. I am trying to get the project to compile without warnings using -Wall for version c++ versions 11 up to 17.
If I delete the entire build directory and remake everything from scratch, a large list of warnings appears. After fixing warnings generated by a specific file and recompiling, only warnings from that specific file are displayed, since the makefile detects that all other objects are up to date and the .cpp/.h files aren't modified.
Since doing the build from scratch is time consuming. My solution is digging into directories and deleting the objects, so I can recompile and see the warnings. This is okay, but somewhat tedious.
Is there any other solution. Is there a way to force the compiler to exit on a warning as if it was an error? I'm using GNU g++.
I am using -Werror and editing the makefile to add options for compiling only a few source files at a time. I think this is the best way. Thanks everyone.
The existing code is calling some sort of wx header file and my DEV C++ compiler just says there's no such file.
Code:
#include<wx/wx.h>
Compiler error:
[Error] wx/wx.h: No such file or directory
So my question is -
What is wx.h
How do I install it in my compiler so that I can use it?
Do I need to change my compiler or DEV C++ would do fine?
What is wx.h
It is the header file of a library. The GitHub project should have some instructions on how to fetch the dependencies and how to install them.
How do I install it in my compiler so that I can use it?
Normally you have to download the dependency, build it (following some instructions), and then you need to use the header in your project and link the library. The exact steps depend on each library and each compiler.
Do I need to change my compiler or DEV C++ would do fine?
In principle, no. Some libraries only work with some compilers, though.
Note that Dev-C++ is not a compiler, it is an IDE that comes with a port of GCC (as far as I know).
It seems that you are using WxWidgets framework but your compiler doesn't know where to find its headers, and apparently also libs which you would face with on a next step.
You, need to add to your compiler flags the output of wx-config --cxxflags. And also to your linker flags the output of wx-config --libs.
Assumption is of course that WxWidgets is installed on your PC
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
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.
I used CMake and Visual C++ to build the HyDE library. Then, still in VC++, I was able to successfully create code and build an executable that links into HyDE.lib and the HyDE header files.
I then discovered that in order to work with others at my company, it would be preferable to develop in Eclipse CDT. Knowing very little about Eclipse CDT, I created a default hello world project, deleted the code and then dumped in all of my code into the src folder. Then I attempted to change the includes and lib path and libs to mirror what had worked in VC++. At this point everything seems to compile, but I get an error in linking:
/cygdrive/c/EclipseWorkspace/425HyDE/Debug/../src/FS5HyDE.cpp:16: undefined reference to `HyDEAPI::HyDE::HyDE(HyDESystemModel::SystemModel*, bool)'
(There are many more errors like this, all referring to HyDE methods.) Here is what is being run at the command line:
g++ -L"C:\Progra~1\boost\boost_1_42\lib" -L"C:\EclipseWorkspace\HyDE" -o"425HyDE.exe" ./src/Adapter_FS5HyDE.o ./src/EPSCommands.o ./src/EPSCurrentSensor.o ./src/EPSFault.o ./src/FS5HyDE.o ./src/HyDEObservation.o ./src/MCDH.o ./src/MCDH_Module.o ./src/PDBComponent.o ./src/PowerSystem.o ./src/Program.o ./src/SSPCComponent.o ./src/Telemetry.o ./src/TelemetryReport.o -l:libboost_thread-vc90-mt-gd-1_42.lib -lHyDE
This is definitely not a library ordering problem because I've the other ordering as well (there are only two). Is it possible that there is a problem with compiling HyDE.lib in VC++ (which uses a Windows compiler) and compiling my program with g++? Could there be a problem in the way that Eclipse CDT is autogen'ing the makefiles? Any other ideas?
(Note: there appear to be plenty of others questions on SO with similar problems, but after reading through them I have yet to find one that addresses my problem.)
Classic missing symbol error. Which source file defines:
HyDEAPI::HyDE::HyDE(HyDESystemModel::SystemModel*, bool)' ?
Was this file added to the compilation? Can you spot it on the command line you pasted?
If this symbol belongs to an external library, after adding the directory path with -L , you could add the name of the specific library you want to link with your program using -l.
I'm going to suggest that you try to add to the compilation command the directory path to HyDE.lib, followed immediately by the library name, like this:
-L"C:\path_to_hyde_library" -l:HyDE.lib
and then tell us what happened.
Solution: Since the HyDE library was compiled with the Visual Studios compiler and I'm attempting to build the code that links to it with the Cygwin toolchain the two compilers use different name mangling schemes so that the latter linker can not find the expected symbols in the HyDE library. The only solution that I've found is to recompile the HyDE library with the Cygwin toolchain or compile the new code with whatever compiler Visual Studios is using. (grumble grumble)
./src/FS5HyDE.o and ./src/HyDEObservation.o should be the latest parameter if other object files (*.o files) need them, it means that the most needed object files should be appeared as last as possible in the parameters list.