C++ compilation error (eclipse) - c++

I am working on simple program of grayscaling using Opencl. When i compile, it gives me the following error.
make all
Building file: ../Test1.cpp
Invoking: GCC C++ Compiler 4.9.3 [armeb-linux-gnueabihf]
armeb-linux-gnueabihf-g++ -I/opt/AMDAPPSDK-3.0-0-Beta/include/ -I/opt/AMDAPPSDK-3.0-0-Beta/include/CL -I/opt/AMDAPPSDK-3.0-0-Beta/include/GL -I/opt/AMDAPPSDK-3.0-0-Beta/include/SDKUtil -I/usr/local/include -O0 -g3 -Wall -c -fmessage-length=0 -o -MM -MMD -MP -MF"Test1.d" -MT"Test1.d" -o "Test1.o" "../Test1.cpp"
cc1plus: fatal error: Test1.d: No such file or directory
compilation terminated.
make: *** [Test1.o] Error 1
Compiler command with options:-
armeb-linux-gnueabihf-g++ -I/opt/AMDAPPSDK-3.0-0-Beta/include/ -I/opt/AMDAPPSDK-3.0-0-Beta/include/CL -I/opt/AMDAPPSDK-3.0-0-Beta/include/GL -I/opt/AMDAPPSDK-3.0-0-Beta/include/SDKUtil -I/usr/local/include -O0 -g3 -Wall -c -fmessage-length=0 -o -MM

The actual command that is executed seems to have the output option -o twice. This option is supposed to be followed by a filename.
Please remove the output option -o from your command because eclipse seems to automatically add it.

Related

Override -shared option in g++

I was building some Cython extensions, and have to link it against a static library (it has CUDA code in them, so have to be static):
running build_ext
building 'k3lib' extension
gcc -pthread -B /home/kelvin/anaconda3/envs/torch/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/kelvin/repos/tools/include -I/home/kelvin/anaconda3/envs/torch/include/python3.8 -c main.cpp -o build/temp.linux-x86_64-3.8/main.o -O3 -march=native
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
g++ -pthread -shared -B /home/kelvin/anaconda3/envs/torch/compiler_compat -L/home/kelvin/anaconda3/envs/torch/lib -Wl,-rpath=/home/kelvin/anaconda3/envs/torch/lib -Wl,--no-as-needed -Wl,--sysroot=/ build/temp.linux-x86_64-3.8/main.o /home/kelvin/repos/tools/include/libk2.a -L/home/kelvin/repos/tools/include -lk2 -o build/lib.linux-x86_64-3.8/k3lib.cpython-38-x86_64-linux-gnu.so -static -Wl,-Bstatic -flinker-output=exec
However, Cython's g++ compile command includes the options -shared -fPIC by default. I tried a number of options at the end of the command via this setup file (the static library is at $(LOCAL_INCLUDE)/libk2.a):
includes = [os.getenv("LOCAL_INCLUDE")]
ext_modules = [
Extension("k3lib", sources=["main.pyx"],
libraries=["k2"], include_dirs=includes, library_dirs=includes, language="c++",
extra_compile_args=["-O3", "-march=native"], extra_objects=[f"{includes[0]}/libk2.a"],
extra_link_args=['-static', '-Wl,-Bstatic', '-flinker-output=exec'])
]
#extra_objects=[f"{includes[0]}/libk2.a"]
#extra_link_args=['-static']
setup(name="k3lib", ext_modules=cythonize(ext_modules, language_level="3"))
Still, g++ thinks that I want to build a shared library, and thus the error message. Is there a way to override the -shared option? I'm planning to go into Cython's files and edit them myself, but was wondering is there a simpler way?
Context: I was following this question on SO but can't replicate their success.

How to add -std=c++0x into the eclipse ubuntu?

I am trying to add -std=c++0x into the eclipse Ubuntu but I do not know how to add it.
My original set up:
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/copy2.d" -MT"src/copy2.d" -o "src/copy2.o" "../src/copy2.cpp"
Does not include -std=c++0x that's why giving me the error when I run std::stoi:
error: stoi is not a member of std
My expectation:
g++ -std=c++0x -O0 -g3 -Wall -c -fmessage-length=0 MMD -MP -MF"src/copy2.d" -MT"src/copy2.d" -o "src/copy2.o" "../src/copy2.cpp"

make:*** [Lab1] Error 1

I already read everything Make: *** [] Error 1 and I am returning a 0 in my main method.
I've tried switching up parsers, but that doesn't work either. I've tried the internal build, that doesn't work (and even if it did I want to work with makefile's).
Here's an example of the error being given. I believe this is what's preventing me from creating the binary files which is a must have in order to run my app.
Error image link -> http://upit.cc/i/c6b2db81.png
Here's the console bit. I did a refresh and then build.
23:52:19 **** Build of configuration Debug for project Lab1 ****
make all
Building file: ../src/Run.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/Run.d" -MT"src/Run.d" -o "src/Run.o" "../src/Run.cpp"
Finished building: ../src/Run.cpp
Building file: ../shared-src/EndToken.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"shared-src/EndToken.d" -MT"shared-src/EndToken.d" -o "shared-src/EndToken.o" "../shared-src/EndToken.cpp"
Finished building: ../shared-src/EndToken.cpp
Building file: ../shared-src/ErrorToken.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"shared-src/ErrorToken.d" -MT"shared-src/ErrorToken.d" -o "shared-src/ErrorToken.o" "../shared-src/ErrorToken.cpp"
Finished building: ../shared-src/ErrorToken.cpp
Building file: ../shared-src/Token.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"shared-src/Token.d" -MT"shared-src/Token.d" -o "shared-src/Token.o" "../shared-src/Token.cpp"
Finished building: ../shared-src/Token.cpp
Building file: ../server-src/server-token/SToken.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"server-src/server-token/SToken.d" -MT"server-src/server-token/SToken.d" -o "server-src/server-token/SToken.o" "../server-src/server-token/SToken.cpp"
Finished building: ../server-src/server-token/SToken.cpp
Building file: ../server-src/server-token/StartSToken.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"server-src/server-token/StartSToken.d" -MT"server-src/server-token/StartSToken.d" -o "server-src/server-token/StartSToken.o" "../server-src/server-token/StartSToken.cpp"
Finished building: ../server-src/server-token/StartSToken.cpp
Building file: ../server-src/Message.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"server-src/Message.d" -MT"server-src/Message.d" -o "server-src/Message.o" "../server-src/Message.cpp"
Finished building: ../server-src/Message.cpp
Building file: ../server-src/Server.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"server-src/Server.d" -MT"server-src/Server.d" -o "server-src/Server.o" "../server-src/Server.cpp"
Finished building: ../server-src/Server.cpp
Building file: ../server-src/User.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"server-src/User.d" -MT"server-src/User.d" -o "server-src/User.o" "../server-src/User.cpp"
Finished building: ../server-src/User.cpp
Building target: Lab1
Invoking: GCC C++ Linker
g++ -o "Lab1" ./src/Run.o ./shared-src/EndToken.o ./shared-src/ErrorToken.o ./shared-src/Token.o ./server-src/server-token/SToken.o ./server-src/server-token/StartSToken.o ./server-src/Message.o ./server-src/Server.o ./server-src/User.o
./shared-src/Token.o:(.rodata._ZTV5Token[_ZTV5Token]+0x20): undefined reference to `Token::getNextToken(char*)'
./shared-src/Token.o:(.rodata._ZTV5Token[_ZTV5Token]+0x28): undefined reference to `Token::processToken(char*)'
collect2: error: ld returned 1 exit status
make: *** [Lab1] Error 1
23:52:20 Build Finished (took 904ms)
As you can see from the image, Lab1 has no Binaries and it's showing the make error.
Solution found thanks to guys commenting
I'm including this code as reference to the comments to this question.
/*
* Token.h
*
* Created on: Sep 12, 2013
* Author: cam
*/
#pragma once
class Token {
public:
Token();
virtual ~Token();
enum TOKEN_TYPE {START, MIDDLE, END, ERROR};
/**
* #pre processToken must be ran first!
*/
virtual Token getNextToken(char*);
virtual bool processToken(char*);
};
/*
* Token.cpp
*
* Created on: Sep 12, 2013
* Author: cam
*/
#include "Token.h"
Token::Token() {
}
Token::~Token() {
}
Token Token::getNextToken(char* buff) {
}
bool Token::processToken(char * buff) {
}
Ultimately I wasn't including two virtual method definitions in my base class. While this got it to compile, I'm curious to know why this is necessary as they are defined as virtual.

Error 1 while buiding by G++

I'm using eclipse Junior and build my C++ program.
the command line in the console is as following:
make all
Building file: ../src/misc/bt_misc.cpp
Invoking: GCC C++ Compiler
g++ -DNDEBUG=1 -DEPOLL=1 -D__GXX_EXPERIMENTAL_CXX0X__
-I"/home/adtech/workspace/mtracker/src/misc" -I"/home/adtech/workspace/mtracker/src/Tracker" -I"/home/adtech/workspace/mtracker/src/misc/xbt" -I/usr/include -I/usr/lib64/mysql -O0 -g3 -Wall -c -fmessage-length=0 -std=c++0x -MMD -MP -MF"src/misc/bt_misc.d" -MT"src/misc/bt_misc.d" -o "src/misc/bt_misc.o" "../src/misc/bt_misc.cpp"
I got no error during the compilation phase, unfortunately, encouter an error at the end as following:
make: *** [src/Tracker/server.o] Error 1
Could you guys help me explain this error. Thanks so much
That error means that a command it executed (presumably g++ when building server.o) en­count­er­ed an error. Scroll up and make sure there aren't any errors. The error might not be at the very end if you're running multiple jobs in parallel.

Eclipse problem in windows

Hello I am getting the following error when trying to compile a c++ project under Eclipse Indigo in windows:
mingw32-make all
'Building file: ../src/testing.cpp'
'Invoking: GCC C++ Compiler'
g++ -I"c:\MinGW\lib\gcc\mingw32\4.5.0\include\c++\tr1\" -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/ testing.d" -MT"src/testing.d" -o "src/testing.o" "../src/testing.cpp"
g++: no input files
mingw32-make: *** [src/testing.o] Error 1
What could be the problem?
There must be some extra spaces somewhere before the name of the file, because you have a very strange file name in the arguments:
-MF"src/ testing.d"
Should be
-MF"src/testing.d"
The wrong path somehow must break the compile line and g++ doesn't understand what the input file is.