Recent

Author Topic: Cross compiling ARM HF - Segmentation fault(core dumped)  (Read 6073 times)

wtechnologies.fr

  • Newbie
  • Posts: 4
Cross compiling ARM HF - Segmentation fault(core dumped)
« on: May 10, 2013, 02:05:02 am »
Hi guys,
    I use Lazarus until long times and it works perfectly on my Linux i386 desktop

My computer : a Linux NetRunner i386 (similar to Kubuntu Quantal)
My device : a Nexus 7 with (K)Ubuntu 12.10 for ARMHF
Lazarus / FPC : the last version of FPC 2.7.1 and Lazarus 1.1

I have followed this wiki http://wiki.lazarus.freepascal.org/Setup_Cross_Compile_For_ARM


After long try, failure linking, cross librairies missing, I succeed !!
On my Linux desktop i386, I can cross-compile application between i386 and ARM HF.
I succeed also to cross-compile the LCL (GTK2  ...with QT it does'nt works)

1 ) first program
I wrote the small application in the tuto
Code: [Select]
program test;
begin
  writeln('DATE ',{$i %DATE%});
  writeln('FPCTARGET ',{$i %FPCTARGET%});
  writeln('FPCTARGETCPU ',{$i %FPCTARGETCPU%});
  writeln('FPCTARGETOS ',{$i %FPCTARGETOS%});
  writeln('FPCVERSION ',{$i %FPCVERSION%});
end.
on a terminal on my i386 computer, I wrote :  fpc -Tlinux -Parm test.pas

the output :
Free Pascal Compiler version 2.7.1 [2013/05/08] for arm                                                                               
Copyright (c) 1993-2013 by Florian Klaempfl and others
Target OS: Linux for ARMHF
Compiling test.pas
Assembling test
Linking test
8 lines compiled, 0.2 sec

The binarie on my device (Nexus 7 Kubuntu) works perfectly !!

2 ) second program
On Lazarus, I create a new "console application" (without graphic), with a serial port communication, It works perfectly on both (computer and ARM tablet).

3 ) third program
On Lazarus, I create a new application with a single form and with a button (hello world).
LCL : gtk2
I can compile without errors with target CPU ARM!
But when I try to execute this binarie on the device, the terminal output is :

" Segmentation fault (core dumped) "

What does it mean exactly? What is wrong?

 









Leledumbo

  • Hero Member
  • *****
  • Posts: 8831
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Cross compiling ARM HF - Segmentation fault(core dumped)
« Reply #1 on: May 10, 2013, 08:08:50 am »
Quote
What does it mean exactly? What is wrong?
Segmentation fault happens in case of invalid memory access, e.g. dereferencing null pointer / address outside program's address space. You'll need to trace exactly where that happens. Does it work with soft float?

wtechnologies.fr

  • Newbie
  • Posts: 4
Re: Cross compiling ARM HF - Segmentation fault(core dumped)
« Reply #2 on: May 10, 2013, 11:40:14 am »
Hi Leledumbo,
     I will try to compile the program with soft float. And keep you in touch.
Thanks a lot.


wtechnologies.fr

  • Newbie
  • Posts: 4
Re: Cross compiling ARM HF - Segmentation fault(core dumped)
« Reply #3 on: May 10, 2013, 01:59:54 pm »
Hi,
On the original tutorial, to be able to crosscompile FPC, the command is

sudo make crossinstall CPU_TARGET=arm OS_TARGET=linux CROSSBINDIR=/home/user/lazarus/fpc/binutils/ OPT=-dFPC_ARMEL INSTALL_PREFIX=/usr

I have modified the OPT like that OPT=-dFPC_ARMHF

Do you think it can be the cause of the error?
Why a simple console program can be executed but when I had LCL it does'nt work ?

Regards

Leledumbo

  • Hero Member
  • *****
  • Posts: 8831
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Cross compiling ARM HF - Segmentation fault(core dumped)
« Reply #4 on: May 10, 2013, 03:35:55 pm »
Quote
Why a simple console program can be executed but when I had LCL it does'nt work ?
LCL depends on the backend toolkit, which is gtk2 in your case. I have no idea what really happens. As I said earlier, if you can debug and see the deepest stack that debugger can get. If it's a call to gtk2 functions, that means something different between LCL and gtk2. And you can still try FPC_ARMEL instead of FPC_ARMHF.

 

TinyPortal © 2005-2018