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.
Related
I have an Eclipse C++ project which initially has first.cpp. Then second.cpp is added and should be linked to the original file. Using Eclipse building tool, I got this output:
make all
Building file: ../src/first.cpp
Invoking: GCC C++ Compiler
g++ -I/home/workspace/first/src -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/first.d" -MT"src/first.o" -o "src/first.o" "../src/first.cpp"
Finished building: ../src/first.cpp
Building file: ../src/second.cpp
Invoking: GCC C++ Compiler
g++ -I/home/workspace/first/src -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/second.d" -MT"src/second.o" -o "src/second.o" "../src/second.cpp"
Finished building: ../src/second.cpp
Building target: first
Invoking: GCC C++ Linker
g++ -L/usr/local/lib -o "first" ./src/first.o ./src/second.o
Finished building target: first
How can I get Eclipse to compile this way?
g++ first.cpp second.cpp -o first
Thank you so much.
============================================================================
I am asking how to make a single binary from multiple source files, not building multiple binaries with multiple source files.
Try using CMake
As per my understanding of your question, you would need to add your source files into CMakeList.txt and then run it. You can make use of this tutorial in doing so.
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"
I devellop a piece of c++ software on my OpenSUSE, which I like to test on another OpenSUSE system.
I copied the executable file on the other system, but when I am starting it I receive an error:
"error while loading shared libraries: libboost_system.so.1.61.0:
cannot open shared object file: No such file or directory"
How can I compile an independent executable without dependencies?
Eclipse does this:
17:24:41 **** Incremental Build of configuration Debug for project boostServer ****
make all
Building file: ../src/boostCom.cpp
Invoking: Cross G++ Compiler
g++ -I/opt/boost -I/usr/local/lib -O0 -g3 -Wall -c -fmessage-length=0 -isystem /opt/boost -MMD -MP -MF"src/boostCom.d" -MT"src/boostCom.o" -o "src/boostCom.o" "../src/boostCom.cpp"
Finished building: ../src/boostCom.cpp
Building file: ../src/main.cpp
Invoking: Cross G++ Compiler
g++ -I/opt/boost -I/usr/local/lib -O0 -g3 -Wall -c -fmessage-length=0 -isystem /opt/boost -MMD -MP -MF"src/main.d" -MT"src/main.o" -o "src/main.o" "../src/main.cpp"
Finished building: ../src/main.cpp
Building target: boostServer
Invoking: Cross G++ Linker
g++ -L/usr/local/lib -o "boostServer" ./src/boostCom.o ./src/boostServer.o ./src/main.o -lboost_system -lboost_serialization -lboost_thread -lboost_date_time -lpthread
Finished building target: boostServer
Greets Ulf
You need to make sure you have the boost libraries installed on your system, and that the path to them is included in you LD_LIBRARY_PATH variable.
For example, if the libboost_system.so file (or symlink) is to be found at /usr/local/boost-1.56.0/lib64 on your system, then you would run the command.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/boost-1.56.0/lib64`
To find out exactly which libraries you need, you can run the command:
ldd my_binary
The output will tell you exactly which libraries are required, and which of those can't currently be resolved.
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.
I'm getting an undefined references linker error only when linking optimized objects files, not when linking unoptimized object files. I don't understand what the problem is or could be.
Here is my unoptimized build:
Building file: ../COMPASS.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -pg -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"COMPASS.d" -MT"COMPASS.d" -o"COMPASS.o" "../COMPASS.cpp"
Finished building: ../COMPASS.cpp
Building file: ../PSA.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -pg -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"PSA.d" -MT"PSA.d" -o"PSA.o" "../PSA.cpp"
Finished building: ../PSA.cpp
Building file: ../SAR.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -pg -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"SAR.d" -MT"SAR.d" -o"SAR.o" "../SAR.cpp"
Finished building: ../SAR.cpp
Building file: ../constraints.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -pg -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"constraints.d" -MT"constraints.d" -o"constraints.o" "../constraints.cpp"
Finished building: ../constraints.cpp
Building file: ../genetic.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -pg -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"genetic.d" -MT"genetic.d" -o"genetic.o" "../genetic.cpp"
Finished building: ../genetic.cpp
Building file: ../globals.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -pg -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"globals.d" -MT"globals.d" -o"globals.o" "../globals.cpp"
Finished building: ../globals.cpp
Building file: ../logging.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -pg -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"logging.d" -MT"logging.d" -o"logging.o" "../logging.cpp"
Finished building: ../logging.cpp
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -pg -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"main.d" -MT"main.d" -o"main.o" "../main.cpp"
Finished building: ../main.cpp
Building file: ../sampling.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -pg -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"sampling.d" -MT"sampling.d" -o"sampling.o" "../sampling.cpp"
Finished building: ../sampling.cpp
Building file: ../simulation1.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -pg -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"simulation1.d" -MT"simulation1.d" -o"simulation1.o" "../simulation1.cpp"
../globals.h: At global scope:
../globals.h:43: warning: inline function 'double showDecimals(const double&, const int&)' used but never defined
Finished building: ../simulation1.cpp
Building file: ../test_function.cpp
Invoking: GCC C++ Compiler
g++ -O0 -g3 -pg -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"test_function.d" -MT"test_function.d" -o"test_function.o" "../test_function.cpp"
Finished building: ../test_function.cpp
Building target: pc2
Invoking: GCC C++ Linker
g++ -pg -fopenmp -pg -o"pc2" ./COMPASS.o ./PSA.o ./SAR.o ./constraints.o ./genetic.o ./globals.o ./logging.o ./main.o ./sampling.o ./simulation1.o ./test_function.o
Finished building target: pc2
Here is my optimized build:
Building file: ../COMPASS.cpp
Invoking: GCC C++ Compiler
g++ -O3 -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"COMPASS.d" -MT"COMPASS.d" -o"COMPASS.o" "../COMPASS.cpp"
Finished building: ../COMPASS.cpp
Building file: ../PSA.cpp
Invoking: GCC C++ Compiler
g++ -O3 -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"PSA.d" -MT"PSA.d" -o"PSA.o" "../PSA.cpp"
Finished building: ../PSA.cpp
Building file: ../SAR.cpp
Invoking: GCC C++ Compiler
g++ -O3 -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"SAR.d" -MT"SAR.d" -o"SAR.o" "../SAR.cpp"
Finished building: ../SAR.cpp
Building file: ../constraints.cpp
Invoking: GCC C++ Compiler
g++ -O3 -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"constraints.d" -MT"constraints.d" -o"constraints.o" "../constraints.cpp"
Finished building: ../constraints.cpp
Building file: ../genetic.cpp
Invoking: GCC C++ Compiler
g++ -O3 -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"genetic.d" -MT"genetic.d" -o"genetic.o" "../genetic.cpp"
Finished building: ../genetic.cpp
Building file: ../globals.cpp
Invoking: GCC C++ Compiler
g++ -O3 -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"globals.d" -MT"globals.d" -o"globals.o" "../globals.cpp"
Finished building: ../globals.cpp
Building file: ../logging.cpp
Invoking: GCC C++ Compiler
g++ -O3 -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"logging.d" -MT"logging.d" -o"logging.o" "../logging.cpp"
Finished building: ../logging.cpp
Building file: ../main.cpp
Invoking: GCC C++ Compiler
g++ -O3 -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"main.d" -MT"main.d" -o"main.o" "../main.cpp"
Finished building: ../main.cpp
Building file: ../sampling.cpp
Invoking: GCC C++ Compiler
g++ -O3 -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"sampling.d" -MT"sampling.d" -o"sampling.o" "../sampling.cpp"
Finished building: ../sampling.cpp
Building file: ../simulation1.cpp
Invoking: GCC C++ Compiler
g++ -O3 -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"simulation1.d" -MT"simulation1.d" -o"simulation1.o" "../simulation1.cpp"
../globals.h: At global scope:
../globals.h:43: warning: inline function 'double showDecimals(const double&, const int&)' used but never defined
Finished building: ../simulation1.cpp
Building file: ../test_function.cpp
Invoking: GCC C++ Compiler
g++ -O3 -Wall -c -fmessage-length=0 -Wno-sign-compare -fopenmp -MMD -MP -MF"test_function.d" -MT"test_function.d" -o"test_function.o" "../test_function.cpp"
Finished building: ../test_function.cpp
Building target: pc2
Invoking: GCC C++ Linker
g++ -fopenmp -o"pc2" ./COMPASS.o ./PSA.o ./SAR.o ./constraints.o ./genetic.o ./globals.o ./logging.o ./main.o ./sampling.o ./simulation1.o ./test_function.o
./logging.o: In function `LOG_COMPASS_display_points_MATLAB(int const&, VisitedSet&)':
logging.cpp:(.text+0x686): undefined reference to `VisitedSet::getSize()'
collect2: ld returned 1 exit status
make: *** [pc2] Error 1
make: Leaving directory `/home/djunderw/ncsu/workspace/pc2/release'
Any ideas?
[FIXED ISSUE WITH showDecimals() FUNCTION]
The file COMPASS.h includes this class template:
template<class T> class VisitedSet {
public:
VisitedSet(const T& soln);
int getSize();
void addSolution(const T& soln);
void evaluate();
void sample(const int& numNewSolutions, Constraints& space);
void CSBiased_generateDistribution();
void constructMPA(Constraints& space);
vector<T> vec;
double bestValue;
int bestIndex;
/* used to implement biased coordinate sampling */
double CSBiased_coefficient;
vector< vector<double> > lastSampledPoints;
vector<int> lastSampledPointsIndex;
vector< vector<double> > newSampledPoints;
vector<int> newSampledPointsIndex;
vector<double> CSBiased_distribution;
private:
int iteration;
int dimension;
int SAR(); // simulation allocation rule
};
And COMPASS.cpp include the following code:
template<class T>
int VisitedSet<T>::getSize() {
return vec.size();
}
The logging.cpp files includes the following code:
#include "COMPASS.h"
void LOG_COMPASS_display_points_MATLAB(const int& iteration, VisitedSet<Policy>& visited) {
cout << "points{"<<iteration+1<<"} = [\n"
<< visited.vec[visited.bestIndex].x[0] << "\t" << visited.vec[visited.bestIndex].x[1] << "\t" << visited.vec[visited.bestIndex].meanQALY() << ";" << endl;
for(int i=0; i<visited.getSize(); i++) {
if(i != visited.bestIndex)
cout << visited.vec[i].x[0] << "\t" << visited.vec[i].x[1] << "\t" << visited.vec[i].meanQALY() << ";" << endl;
}
cout << "];\n";
}
int VisitedSet<T>::getSize() is a templated function, so its definition should be in a header file like COMPASS.h, not in COMPASS.cpp.
Here's why: http://www.parashift.com/c++-faq/templates-defn-vs-decl.html