I'm trying to compile my project, it contains many files and it need 3 libraries gsl,libxml,boost
when i give the terminal the g++ command on ubuntu 14.04LTS
g++ -Wall -I/usr/include/libxml2 -I/usr/include/gsl main.cpp YUNucNet.cpp src/*.cpp -lxml2 -lgsl -lm -lgslcblas -lboost_system -lboost_filesystem
it gives me these error
In file included from /usr/include/boost/lexical_cast.hpp:34:0,
/usr/include/c++/4.8/typeinfo:39:37: error: expected ‘}’ before end of line
#pragma GCC visibility push(default)
^
/usr/include/c++/4.8/typeinfo:39:37: error: expected unqualified-id before end of line
/usr/include/c++/4.8/typeinfo:39:37: error: expected declaration before end of line
what would be the problem ???? I can't get it .
thanx
default is a c++11 token.
You need to compile with -std=c++0x or something similar. Make sure your gcc is new enough to support such things.
Related
I tried to compile the example: echo_server_with_as_single_default.cpp from boost examples on an:
ubuntu 18.04
boost 1.75.0
g++ 10.1.0
Using the following commands to compile&link (I know it's not optimal, I reused the makefile from another project I am working on):
g++ -MT bin/.o/src/main.o -MD -MP -MF bin/.d/src/main.d -std=c++20 -Isrc -Ilib/ -g -Wfatal-errors -c -o bin/.o/src/main.o src/main.cpp
g++ -o bin/server bin/.o/src/main.o -lpthread -lrt -lboost_system -lboost_thread -lboost_chrono -lboost_context -lboost_coroutine -DBOOST_COROUTINES_NO_DEPRECATION_WARNING
And I get the following error:
I tried diferrent combinations but there is something I am missing. Any help?
error: 'awaitable' has not been declared in 'boost::asio'
22 | using boost::asio::awaitable;
Currently, coroutines are not enabled by default in gcc. You need to pass the -fcoroutines compiler switch in order to enable them. This will probably change soon as it already works with the current gcc trunk version.
See here (I had to comment out the code in main due to the execution time cap in godbolt.org).
This may be a bit of a weird request but I'm trying to compile some software with g++ with the -nostdlib flag.
I'm pretty new to c++ and I'm still learning how linking and compiling works but I'm trying to compile this code:
#include "../lib/gamesys/types.h"
int main() {
types::setUid(1001);
}
Using these commands:
g++ -Wall -g -c bin/scripttwo.cpp -o bin/scripttwo.o -std=c++14
and
g++ -o bin/scripttwo bin/scripttwo.o software/*.o hardware/*.o *.o -nostdlib -Llib/lib/ -ltypes -ljsoncpp -lreadline -ltypes
and I'm getting the error:
/usr/bin/ld: software/FS.o: undefined reference to symbol '_Unwind_Resume##GCC_3.0'
/usr/bin/ld: /lib64/libgcc_s.so.1: error adding symbols: DSO missing from command line
I'm assuming it has something to do with the stdlib because once I remove -nostdlib, it compiles and links fine.
How can I solve this (it is pretty important that I don't include stdlibs)
Note: If you want to know why I'm trying to avoid stdlibs, let me know, its a long a convoluted story lol
arm-linux-gnueabi-g++ can't compile code that uses the xerces-c parser. Specifically, it can't seem to locate the xerces-c library even when I specify the full path with the I- flag or link it with -lxerces-c. However, when I compile with the generic g++ parser, everything works fine. Moreover, g++ works fine when I move around the xerces-c directories.
The code for g++ compilation:
g++ -pthread -g -c -std=c++0x src/MyFile.cpp -o $(TARGET_DIR)/MyFile.o -lxerces-c
The code for arm-linux-gnueabi-g++:
arm-linux-gnueabi-g++ -pthread -g -c -std=c++0x src/MyFile.cpp -o $(TARGET_DIR)/MyFile.o -lxerces-c
This is the error I receive:
src/myFile.cpp fatal error: xerces/util/PlatformUtils.hpp: No such file or directory
#include <xerces/util/Platform/utils.hpp
compilation terminated
I also tried removing the angle brackets enclosing the xerces library and replacing them with quotations so the path wouldn't get messed up.
So, I was following a simple C++ with SDL tutorial for linux but i encounter some errors on my way.
First of all I'm using Geany and i downloaded the corresponding SDL2 libs, here is the thing:
in my project folder there is a main.cxx file, which i open with geany as i mentioned before:
I included this libraries:
#include <iostream>
#include <SDL2/SDL.h>
#include <SDL2/SDL_image.h>
#include <SDL2/SDL_mixer.h>
First i encountered a pelculiar error, compilation performs sucessfully but when it comes to build i got this error:
main.cxx: undefined reference to `SDL_Init'
After searching a bit i found out that i had to add the tag -lSDL to my geany build options so they would end up being somethinf like this:
Compile:
g++ -Wall -c -lSDL "%f"
Build:
g++ -Wall -o -lSDL "%e" "%f"
But there is a problem, now when I execute the build command i get a:
G ++: error: main: There is no such file or directory
Why am i getting this error, am I including a wrong library or g++ has problems with .cxx files?
I already tried converting between .cxx and .cpp.
Thanks in advance.
g++ -Wall -c -lSDL2 "%f"
There is absolutely no need to specify libraries during compilation phase. Remove -lSDL.
g++ -Wall -o -lSDL2 "%e" "%f"
It invokes compiler, implies linking (no -c or other operation-specific flags), and sets output file name to -lSDL2. That is, linker will output resulting binary in a file named -lSDL2 in current working directory. Then, when it comes what files to link, it goes main, which supposed to be -o main, but since you've broken flags order it is now just ordinary file name that linker will try to link into resulting binary. It so happens that this file doesn't exist.
Long story short, make correct linking line - g++ -o "%e" %f -lSDL2 (libraries comes last, library order is also important).
I've taken the great advice from this answer, checked the file list for libbotan1.10-dev and found /usr/lib/libbotan-1.10.a, so I used the linker flag -lbotan-1.10.
I've successfully been able to code and compile websocket++, json-spirit, connector/c++, and boost::lockfree::spsc_queue.
I'm now trying to use botan's passhash9 to hash passwords.
When I try to compile with
g++ -Ofast -march=native -o btServer broadcast_server_tls.cpp
-I ~/websocketpp-master/ -std=c++0x -D_WEBSOCKETPP_CPP11_STL_
-D_WEBSOCKETPP_NO_CPP11_REGEX_ -lboost_regex -lboost_system
-pthread -L/usr/lib -lssl -lcrypto -ljson_spirit -lmysqlcppconn -lbotan-1.10
g++ gives an error on the #include <botan/botan.h> line, saying "broadcast_server_tls.cpp:12:25: fatal error: botan/botan.h: No such file or directory".
To install on Ubuntu 12.10, I did apt-get install libbotan1.10-dev.
How can I correct this?
You should compile as:
g++ "whatever_source_file" "whatever flags you are already using" -I/usr/include/botan-1.10/