ld warning: file A.o: attempted multiple inclusion of file - c++

I am trying to port some windows C++ code to Solaris (Unix). I am compiling the code using CC(the SUN C++ compiler). After some efforts, I only have one warning message left as shown below.
ld: warning: file A.o: attempted multiple inclusion of file
I try to search the warning message. But what I got are some info that this warning can be ignored... Although it is a warning, I would really like to understand it and solve it.
May I know if any one can give me some clue what this warning means?
Thanks,

Related

Intel compiler undefined reference to symbol 'for_inquire'

I'm running a Makefile given to me to compile some Fortran code along with some C++ code. This is being compiled on CentOS using the intel compiler.I didn't write any of the code or the Makefile, also I have no clue what I'm doing.
When I run the Makefile script I get the following error when trying to do something with Fortran code 'libStuff':
ld: /home/myProject/trunk/libStuff/lib/libStuff.a(stuff.o): undefined reference to symbol 'for_inquire'
/opt/intel2019/compilers_and_libraries_2019.0.117/linux/compiler/lib/intel64_lin/libifcore.so.5: error adding symbols: DSO missing from command line
make[1]: *** [myProject] Error 1
I've played around with the Makefile and I've figured out that I need to add a flag to a specific line
MYFORTRANCODE=-L$(MYFORTRANCODE_LIB) -lSTUFF -lmpi_usempif08 -lmpi_mpifh -l_I_NEED_TO_ADD_SOMETHING_HERE
The problem is I don't know which flag to add, and couldn't find any helpful documentation on the intel website. Also I couldn't figure out what the 'for_inquire' thing means.
Anybody got any ideas?
the flag I needed to add was -lifcore. I figured it out.

internal compiler error: in decode_addr_const, at varasm.c:2632

When I compile a project using cross compiler,I come across the following error:
internal compiler error: in decode_addr_const, at varasm.c:2632
Where can I find the varasm.c file?I searched the project directory and cross compiler directory,but I didn't find it.
Thanks for helpping,Light
The compiler maker has that file, and probably won't give it to you.
But as it seems to be an error in the compiler, you can either contact them / file a bug report, or try to avoid the error by changing your code a bit (which is a guessing game, as you don't know how you made it run into the error). Or use another compiler, if there are choices.

Compiler says it cannot find file and yet reports errors in "unfound" file?

I have two short files located in the same directory. The contents of each are shown below.
File test.cpp contains:
int main()
{
#include <test.h>
}
File test.h contains:
syntax_error
Upon compiling test.cpp with either g++ or clang++, I get an error which is expected.
test.cpp:3:11: error: 'test.h' file not found with <angled> include; use
"quotes" instead
#include <test.h>
^~~~~~~~
"test.h"
However, I also get a second error which seems to contradict the first error.
In file included from test.cpp:3:
./test.h:1:1: error: use of undeclared identifier 'syntax_error'
syntax_error
^
Essentially, the first error reports that the compiler cannot find the file test.h, and the second reports a syntax error in the file that the compiler reported it could not find.
These are the only two errors generated.
I understand why the compiler reports the first error and that I should use quotes with #include in this case. Why, though, does the compiler say it cannot find the file when it clearly has found it? And, why would it continue to report errors in the "unfound" file?
This is a feature, not a bug.
The idea is that if the error is trivial (like a missing semicolon), then the compiler will try to continue compiling as if you had already fixed the error. This enables you to fix multiple errors in one go. This is especially useful when compiling your code takes a long time.
Imagine fixing a missing semicolon, recompiling for five hours, just so that the compiler finds another missing semicolon. And then you have to recompile again. That would be very frustrating, no?
Basically, the compiler will try to recover from any errors as far as it is able to, to be able to report as much errors as possible. Most compilers have a flag for this.
Why, though, does the compiler say it cannot find the file when it clearly has found it?
The compiler found the file yes, that's why it gave you a hint to use "" instead of <>. If it hadn't, it might not have given you the hint. Still, the compiler is not allowed to compile your code correctly, because your code is ill-formed.
As an analogy, just because the compiler found a missing semicolon, that doesn't mean that it can just compile the code with that missing character (if it tries to be Standards compliant). It will however recover and try to find other errors, if any.

Get more information about compiler errors in Clion

I have a program with many files and right now I have a huge bunch of compiler errors which I have a hard time understanding. The only line references I get are references to C++ libraries, such as algorithm or utility.
My question is: how am I supposed to know where the compiler error is? Some line in my code obviously generated an error in a C++ library, but where was it generated? Is there any way to get more info about the compiler errors? It's not like I can debug it, since it's in compile time.
EDIT: I realize this could be difficult to understand. Here are some examples of errors which I have modified for simplicity reasons.
(1) Here the error is on a line which includes std::string and I have no idea where it tries to do something with ClassY.
In file included from [my path]/ClassX.cpp:1:
In file included from [my path]/ClassX.h:4:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:439:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:2123:24:
error: invalid operands to binary expression ('my project::ClassY *' and 'const my project::ClassY')
EDIT 2: problem solved. There were in total 31 error lines and note lines. I thought these had nothing to do with the above. However, they were all connected to one single line, which was referenced further down in the error messages:
myvec.erase(std::remove(myvec.begin(), myvec.end(), item), myvec.end());

C++: debug bus error

I am trying to compile a c++ program in Linux, using the command in the shell
$ g++ -Wall *.cpp -o prog
and for some reason it keeps on giving me a weird error:
g++: Internal error: Bus error (program cc1plus) Please submit a full
bug report. See for
instructions.
I searched the net for this bus error, and it says that it has to do with something about accessing illegal memory.
Can someone maybe clarify things a bit more for me?
This error message is telling you that there's a bug in the g++ compiler itself.
Try to narrow it down by removing bits and pieces of your source file until the problem goes away. You're not trying to fix your program, you're just trying to find the part that is breaking the compiler. Once you've found it, you can either give a better bug description or you can change your code to work around it.
Or just download the latest version of the g++ compiler and hope that it's already fixed.
Your problem is not in your code, is the compiler (g++) that is crashing and producing that Bus Error, it's possible you have an outdated version of such compiler and need to update, or you're lucky and found a real bug in g++.
I would try compiling each source file separately, to check what part of the source code triggers the error.