gcc compile errors - linux

I am getting these errors when I compile sim_routing.cc program by this command
../../bin/cxx sim_routing.cc
g++ -Wall -o sim_routing sim_routing.cxx
following errors are produced:
../../common/priority_q.h : In member function 'bool guardedQueue<ITEM>::Validate(Const char*);
error : there are no argument to 'strcat' that depend on template parameter so a declaration of 'strcat' must be avaible.
error : <if you use -fpermissive g++ will accept your code but allowing use of undeclared name is deprecated>
When I tried to change commom/priority_q.h, it shows it is read only; file changes cannot be accepted.
How these errors can be removed?

#include <cstring> before the header triggering your error.

Related

Compiling binary using dynamic libraries

I have 20 shared objects files, and I want to use one function from the let`s say "a.so"
but my problem is that a.so is linked to other libraries.
When i compile my main i get the following error:
/usr/bin/ld: warning: b.so, needed by /home/test/lib/a.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: c.so, needed by /home/test/lib/a.so, not found (try using -rpath or -rpath-link)
How can i compile my main that i would be able to use the function in a.so ?
I have tried to use this method: gcc -L. -WL, -rpath,. main.c -l{libraryName} -o main
but i get the following error:
gcc: error: unrecognized command line option ‘-WL,’; did you mean ‘-Wa,’?
gcc: error: unrecognized command line option ‘-rpath,.’
When i compile my main i get the following error:
There are two mistakes in above statement:
you get a warning, not an error, and
you get it when you link your program, not when you compile it.
How can i compile my main that i would be able to use the function in a.so ?
Like so:
gcc -L. -Wl,-rpath=. main.c -l{libraryName} -o main
P.S. In general, it's a bad practice to have -rpath as a relative path, because the program will not work if you invoke it from a different directory. A better solution is to use absolute -rpath instead:
gcc -L/home/test/lib -Wl,-rpath=/home/test/lib main.c -l{libraryName} -o main

error: "was not declared in this scope", using cygwin

I'm trying to build a simple c++ code, that uses threads.
I tried to build it with Eclipse, Code Blocks, and Cygwin shell. All have resulted in the error:
"was not declared in this scope".
I added the -std=c++14 to the compiler options.
$ g++ --version
g++.exe (GCC) 7.4.0
and here's what I get:
$>g++ -std=c++14 main.cpp
main.cpp: In function 'int main()':
main.cpp:10:5: error: 'thread' was not declared in this scope
thread t1(callback, 1, 2);
^~~~~~
any idea how to solve it?

unqlite.h:651:15: error: changes meaning of ‘pgno’ from ‘typedef sxu64 pgno’ [-fpermissive]

Just downloaded the unqlite.c and unqlite.h, created a new project in Eclipse, copied one of the examples from unqlite.org website and I'm getting the following error:
21:37:51 **** Build of configuration Debug for project nosql ****
make all
Building file: ../main.cpp
Invoking: Cross G++ Compiler
g++ -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF"main.d" -MT"main.d" -o "main.o" "../main.cpp"
In file included from ../main.cpp:49:0:
../unqlite.h:661:8: error: declaration of ‘pgno unqlite_page::pgno’ [-fpermissive]
pgno pgno; /* Page number for this page */
^
../unqlite.h:651:15: error: changes meaning of ‘pgno’ from ‘typedef sxu64 pgno’ [-fpermissive]
typedef sxu64 pgno;
^
subdir.mk:25: recipe for target 'main.o' failed
make: *** [main.o] Error 1
21:37:51 Build Finished (took 171ms)
It was meant to be as simple, but I have no clue of what is going on... Has anyone tried this unqLite KV store?
I'm using
gcc version 4.9.2 (Debian 4.9.2-10)
Cheers
ttkdroid
This issue appears when including unqlite.h in a C++ file, and compiling it with a g++. You have two solutions to fix it:
You can get the patch produced by the author of the lib as indicated here: https://github.com/symisc/unqlite/issues/24
Or you can edit the unqlite.h file on line 661 replacing:
pgno pgno; /* Page number for this page */
by
::pgno pgno; /* Page number for this page */
Which will work with a g++ compiler as well as other C++ compilers. Of course, you cannot compile unqlite.c with this edited header, with a C compiler.
If you want to learn more about this error, this might be a good link: typedef changes meaning
Have a good day!

Compiling Mongo on Alpine

I'm attempting to compile Mongo on Alpine Linux.
Anybody know how to get past this error?
In file included from src/mongo/util/net/socket_poll.h:20:0,
from src/mongo/util/net/sock.cpp:42:
/usr/include/sys/poll.h:1:2: error: #warning redirecting incorrect #include <sys/poll.h> to <poll.h> [-Werror=cpp]
#warning redirecting incorrect #include <sys/poll.h> to <poll.h>
^
cc1plus: all warnings being treated as errors
scons: *** [build/linux2/normal/mongo/util/net/sock.o] Error 1
scons: building terminated because of errors.
This comes from the build system adding a -Werror flag and therefore the compiler is treating warnings as errors and fails the build.
You'll probably be able to go past this step by using the ad hoc --disable-warnings-as-errors flag.

error: 'uint8_t' has not been declared

I'm trying to use an xbox360 controller as a joystick in openSUSE 11.2. When attempting to compile xboxdrv (http://pingus.seul.org/~grumbel/xboxdrv/) I get the following errors:
g++ -o src/xbox_controller.o -c -g -O2 -Wall -ansi -pedantic src/xbox_controller.cpp
In file included from src/xbox_controller.hpp:23,
from src/xbox_controller.cpp:24:
src/xbox_generic_controller.hpp:30: error: 'uint8_t' has not been declared
src/xbox_generic_controller.hpp:30: error: 'uint8_t' has not been declared
src/xbox_generic_controller.hpp:31: error: 'uint8_t' has not been declared
In file included from src/xbox_controller.cpp:24:
src/xbox_controller.hpp:38: error: 'uint8_t' has not been declared
src/xbox_controller.hpp:38: error: 'uint8_t' has not been declared
src/xbox_controller.hpp:39: error: 'uint8_t' has not been declared
src/xbox_controller.cpp:54: error: variable or field 'set_rumble' declared void
src/xbox_controller.cpp:54: error: 'uint8_t' was not declared in this scope
src/xbox_controller.cpp:54: error: 'uint8_t' was not declared in this scope
scons: *** [src/xbox_controller.o] Error 1
scons: building terminated because of errors.
Any ideas how to fix this?
Edit src/xbox_controller.hpp, add missing #include <stdint.h> to it (somewhere near the beginning).

Resources