I use armadillo library. somewhere I get this exception:
error: Mat::init(): size is fixed and hence cannot be changed
terminate called after throwing an instance of 'std::logic_error'
what(): Mat::init(): size is fixed and hence cannot be changed
Aborted (core dumped)
I know why. But I dont know where.
Is there any way to obtained the line causing this problem? is valgrind or any other tool able to do that?
Update:
compile code:
g++ -g -Wall -Wfatal-errors -Wextra -std=c++11
main.cpp -lboost_filesystem -lboost_system
Can you post a small snippet of the code where the error comes in?
I had similar error but dont remember what caused it but try storing the result of the command in some other variable and check it. And put "cout" to find the statement causing the error.
Related
So here's my problem. I have downloaded mingw g++ by using msys according to the official vs code website
Here are my files:
Now, when I try to build I get this error:
> Executing task: g++ -std=c++14 -g -o myfile.exe myfile.cpp <
cc1plus.exe: fatal error: myfile.cpp: No such file or directory
compilation terminated.
The terminal process "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command g++ -std=c++14 -g -o myfile.exe myfile.cpp" terminated with exit code: 1.
And if I do have a .exe file:
edit: I also started getting errors with
#include <iostream>
I would make this a comment if I could. What is the name of the file where you have written #include <iostream>?* I think if you change the name of that file to "myfile.cpp", you might stop getting that error. You will probably get a different error saying that "main() cannot be found" or something like that, but that's an improvement from your current spot.
*I see it's O3.cpp. Try changing that to myfile.cpp.
I've been trying to locate where a segmentation fault is in a program using LLDB. I've been going to the Ubuntu shell on repl.it and compiling my code using clang++-7 -pthread -std=c++17 -o main main.cpp -g and the program compiles succesfully. Next, I run lldb main and everything's fine but as soon as I type run I get error: process launch failed: 'A' packet returned an error: 8. I've checked the docs and looked up the error but I can't seem to find anything. Thanks for any sort of help!
The full log:
~/Project$ clang++-7 -pthread -std=c++17 -o main main.cpp -g
~/Project$ lldb main
(lldb) target create "main"
Current executable set to 'main' (x86_64).
(lldb) run
error: process launch failed: 'A' packet returned an error: 8
In case you need the code it's on this Github: https://github.com/KingsleyDockerill/Wirth
For those using Docker, as mentioned here, they need to add --cap-add=SYS_PTRACE --security-opt seccomp=unconfined to their docker run command in order to use lldb.
See also this older answer.
I am trying to compile a large group of codes for solving a physics problem. I usually use gfortran. There is no compile time error. My gfortran compiler statement is
gfortran -fdefault-real-8 -O -Waliasing -Wampersand -Wconversion -Wsurprising -Wintrinsics-std -Wintrinsic-shadow -Wline-truncation -Wreal-q-constant
When executed, I get a runtime error
Program received signal SIGBUS: Access to an undefined portion of a memory object.
But this runtime error does not occur, when I compile with the debugging flag -g or with Intel compiler ifort.
Even with gfortran without the -g flag, sometime this error does not occur! I know that this can be caused by some undefined array or unallocated array or something like this. My problem is that I can not seem to find out where is problem as apparently, I have no compile-time error.
So, is there a compiler flag for gfortran or for ifort which can help me detect this error?
Thanks
Madhurjya
I have written a websocket++ server on Ubuntu 13.10 and am trying to execute it on Linux Mint 16.
I have installed all dependencies, and the first line under main is a cout which never fires.
This is the compile command:
g++ -o Dgn Dgn.cpp ed25519-donna-master/ed25519.o
-Og -std=c++0x -I ~/Dgn -D_WEBSOCKETPP_CPP11_STL_ -D_WEBSOCKETPP_NO_CPP11_REGEX_
-lboost_regex -lboost_system -L/usr/lib -lssl -lcrypto -pthread -lpqxx
-lboost_thread -ljson_spirit -lgmp -lgmpxx
If I execute with sudo to use restricted ports, it fails immediately without error returning to the command line.
If I execute without sudo, is prints Segmentation Fault and fails immediately to the command line.
The directories in ~/Dgn are present on the new system.
I did a quick, simple test and checked to see if a basic websocket++ example could compile and execute normally, and it was successful.
Both systems are 64-bit. The only difference are the distros, but Linux Mint 16 is based upon Ubuntu 13.10, and all commands to setup were identical.
How can this be compiled so that it can execute on another system?
As a further test, I compiled it on the new system, and it works.
Is it not possible to compile on one system and run on another?
GDB
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff7de58da in ?? () from /lib64/ld-linux-x86-64.so.2
The fact that cout line never fires (I assume it has << std::endl) means that the crash happens in a static object constructor. The most straightforward way to debug is to allow core dump (see man limits) and inspect the dump with gdb. So far that's all I can think of. More details will help.
I'm trying to add a Swig interface on top of some already existing c++ code and I'm coming up with some errors with the -fPIC flag.
If I compile the already existing code without -fPIC and then create my Swig module using:
swig -python -c++ pyinterface.i
gcc -fPIC $(CFLAGS)-I $(PYTHON_INCLUDE_DIR) -c pyinterface_wrap.cxx
g++ -shared -o _pyinterface.so pyinterface_wrap.o -I $(PYTHON_INCLUDE_DIR) -L $(PYTHON_LIB_DIR) $(LPATH) $(LFLAGS) $(IPATH) $(LIBS)
Then I get a
warning: creating a DT_TEXTREL in object
However the module does seem to load and work in Python.
If I compile the already existing code with -fPIC and then do the same to create my module, when I try and import it into python:
import pyinterface
Then I get the error
ImportError: ./_pyinterface.so: undefined symbol: _Z7InitErfPA20_d
I can't tell why this would be. However, in the compliation of the base c++ files that I am trying to wrap, they do link to some standard libraries such as -llapack.
Could it be that I need to recompile these base libraries, like lapack, with -fPIC. That seems insane.
EDIT:
Actually sorry, I didn't realise, but with the -fPIC flag on I'm getting an error during compile:
g++: Internal error: Killed (program cc1plus)
Please submit a full bug report.
See http://bugs.gentoo.org/ for instructions.
I'll update this question if I figure out whats going on, but it seems like it might be unrelated to anything that the question actually raises.
I might be wrong regarding this reply.
Regarding the warning: creating a DT_TEXTREL in object
Even I was getting the same warning.
In my Makefile; I had done something like this
SRC= ../../some_folder/file.c 1.c 2.c
OBJS= $(SRC:.c=.o)
and while making the shared object, i was using this $(OBJS); whereas the "file.o" would be available at that location.
Make sure the object files that you are trying to access are available at that location.
My warning message vanished when i made the following changes
OBJS=file.o 1.o 2.o