Using -mfloat-abi=hard in eclipse - c++

I am trying to cross compile in eclipse using the arm gcc compiler. I go to projrct , properties and set the c/c++ compile option and set the flag to -mfloat-abi=hard.
It throws the following exception while building:
**** Build of configuration Debug for project HelloWorld ****
make all
Building file: ../src/HelloWorld.c
Invoking: GCC C Compiler
arm-linux-gnueabi-gcc -I/usr/arm-linux-gnueabi/include -O0 -g3 -Wall -mfloat-abi=hard -c -fmessage-length=0 -MMD -MP -MF"src/HelloWorld.d" -MT"src/HelloWorld.d" -o "src/HelloWorld.o" "../src/HelloWorld.c"
Finished building: ../src/HelloWorld.c
Building target: HelloWorld
Invoking: GCC C Linker
arm-linux-gnueabi-gcc -L/usr/arm-linux-gnueabi/lib -mfloat-abi=hard -o "HelloWorld" ./src/HelloWorld.o
/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../arm-linux-gnueabi/bin/ld: error: ./src/HelloWorld.o uses VFP register arguments, HelloWorld does not
/usr/lib/gcc/arm-linux-gnueabi/4.6/../../../../arm-linux-gnueabi/bin/ld: failed to merge target specific data of file ./src/HelloWorld.o
collect2: ld returned 1 exit status
make: *** [HelloWorld] Error 1
**** Build Finished ****
It builds fine without that flag. But I need to set it for it to run on the beaglebone.Any ideas what I am doing wrong?
Output after using -print-multi-lib
**** Build of configuration Debug for project HelloWorld ****
make all
Building file: ../src/HelloWorld.c
Invoking: GCC C Compiler
arm-linux-gnueabi-gcc -I/usr/arm-linux-gnueabi/include -O0 -g3 -Wall -mfloat-abi=hard -c -fmessage-length=0 -print-multi-lib -MMD -MP -MF"src/HelloWorld.d" -MT"src/HelloWorld.d" -o "src/HelloWorld.o" "../src/HelloWorld.c"
arm-linux-gnueabi-gcc: error: ./src/HelloWorld.o: No such file or directory
.;
arm-linux-gnueabi-gcc: fatal error: no input files
compilation terminated.
make: *** [HelloWorld] Error 4
.;#mfloat-abi=softfp
hf;#mfloat-abi=hard
Finished building: ../src/HelloWorld.c
Building target: HelloWorld
Invoking: GCC C Linker
arm-linux-gnueabi-gcc -L/usr/arm-linux-gnueabi/lib -mfloat-abi=hard -o "HelloWorld" ./src/HelloWorld.o
**** Build Finished ****

Related

How to include a library header after adding the linker in Eclipse

I am trying to include a library from Github (https://github.com/dcjones/hat-trie).
The installation worked fine and I was able to add the library
to the linker in Eclipse
but the problem is that I don't know how to use it.
I have added it as a header
#include <hat-trie.h>
but it's giving this error:
18:49:31 **** Incremental Build of configuration Debug for project test2 ****
make all
Building file: ../src/test2.cpp
Invoking: GCC C++ Compiler
g++ -std=c++1y -std=c++11 -I/home/use1/boost_1_58_0 -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/test2.d" -MT"src/test2.d" -o "src/test2.o" "../src/test2.cpp"
**../src/test2.cpp:28:22: fatal error: hat-trie.h: No such file or directory
#include <hat-trie.h>**
^
compilation terminated.
make: *** [src/test2.o] Error 1
18:49:33 Build Finished (took 2s.831ms)
Any idea how can I fix this?

How to compile an independent executable file by g++?

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.

Error while building an eclipse project with boost

I am trying to include boost in building C++ projects on Ubuntu. The g++ version is 4.8.1 and the boost version is 1.57.0. I followed these instructions to use boost (header only libraries). I put the boost library into ~/opt/lib, and when I try to compile the project I get the following error output:
15:19:47 **** Incremental Build of configuration Debug for project TEST ****
make all
Building file: ../src/test.cpp
Invoking: GCC C++ Compiler
g++ -include/home/alexander/opt/lib/boost_1_57_0 -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/test.d" -MT"src/test.d" -o "src/test.o" "../src/test.cpp"
In file included from <command-line>:0:0:
/usr/include/stdc-predef.h:39:1: fatal error: /home/alexander/opt/lib/boost_1_57_0: No such file or directory
#endif
^
compilation terminated.
make: *** [src/test.o] Error 1
15:19:48 Build Finished (took 1s.31ms)
What have I made wrong?

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.

problem building cpp project in eclipse

I have installed minGW and msys. In eclipse CDT I created c++ project that uses cross gcc toolchain.
Eclipse created make file which I can use through command line, so if I run make all project is correctly compiled, but if I use eclipse to build, it fails with following message
**** Build of configuration Debug for project cpp ****
make all
Building file: ../src/main.cpp
Invoking: Cross G++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"src/main.d" -MT"src/main.d" -o "src/main.o" "../src/main.cpp"
make: *** [src/main.o] Error 1
**** Build Finished ****
I have chosen wrong toolchain in project, changed to mingw gcc and now it works