Welcome, Guest
Username: Password: Remember me
CodeTyphon Cross-Build Development, discussions and problems
  • Page:
  • 1

TOPIC:

Cross compile console application? 10 years 9 months ago #5176

  • Javor
  • Javor's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • M.Sc in Computer Science, (ex-)freelancer
  • Posts: 72
  • Thank you received: 8
Hello guys
I need a suggestion as I still try hard to compile a Linux-ARM (for Raspberry Pi) console application with rpi_hal.pas from Windows (CT 4.6). It seems so far mission impossible as I get the well known
"
testrpi.pas(15,86) Warning: "crti.o" not found, this will probably cause a linking failure
testrpi.pas(15,86) Warning: "crtbegin.o" not found, this will probably cause a linking failure
testrpi.pas(15,86) Warning: "crtend.o" not found, this will probably cause a linking failure
testrpi.pas(15,86) Warning: "crtn.o" not found, this will probably cause a linking failure
c:\codetyphon\fpc\bin\i386-win32\arm-linux-ld.exe: warning: link.res contains output sections; did you forget -T?
C:\codetyphon\fpc\units\arm-linux\rtl\cprt0.o: In function `_haltproc_eabi':
(.text+0x88): undefined reference to `_fini'
C:\codetyphon\fpc\units\arm-linux\rtl\cprt0.o: In function `_haltproc_eabi':
(.text+0x90): undefined reference to `_init'
testrpi.pas(15,86) Error: Error while linking
testrpi.pas(15,86) Fatal: There were 1 errors compiling module, stopping
"
If I make a an application which uses Interfaces unit (which uses Forms and so on), then everything compiles and runs fine. However seems it's a GUI application as I get
Gtk-WARNING **: cannot open display:
while I try to run it.
Tried to compile the same application, which uses rpi_hal.pas from RPi itself, using Lazarus 0.9.2 and it compiles and runs, which leads me to conclusion that cross libs or something is the reason for that fail.

Please Log in or Create an account to join the conversation.

Cross compile console application? 10 years 9 months ago #5177

  • Javor
  • Javor's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • M.Sc in Computer Science, (ex-)freelancer
  • Posts: 72
  • Thank you received: 8
Update: removing cthreads and cmem units from uses clause solves the problem. What do they have in common with the libraries??? Now the next step is to use the synaser unit (TBlockSerial component). Trying to use it causes the errors, mentioned above... Why the heck is it that hard to compile a simple Linux console application from Windows.
Or if anyone knows how to make an app which doesn't require any X/graphics at all, please share

Please Log in or Create an account to join the conversation.

Cross compile console application? 10 years 9 months ago #5179

  • Rain
  • Rain's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 71
  • Thank you received: 8
I can confirm the issue with the missing libs for console apps.
First I tried to copy the libs from a real Raspi, but it still had issues with eabi 0 vs 5 etc.
Since I needed my compiled binary fast, I gave up and just compiled it on the RasPi itself.
Lazarus is available on Raspi:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install fpc
sudo apt-get install lazarus

All I needed to do was to copy the Synapse source Dir also to the Raspi and include it's search path into the project settings - Path - "other Units -Fu" path edit box.

Since the Raspbian image even runs in the QEMU 1.6 ARM-Emulator qemu-system-armw.exe :woohoo: , no Raspbian Hardware is required and it is not so hard to compile "on the target" itself.

Of course I would prefer to cross compile from Windows like you are trying, but at least I'm not blocked by the issues.

Please Log in or Create an account to join the conversation.

Cross compile console application? 10 years 9 months ago #5180

  • Rain
  • Rain's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 71
  • Thank you received: 8
There are a few different QEMU descriptions for Raspbian, but I found this to be the straightest one:

www.linux-mitterteich.de/fileadmin/dataf..._lug_18_sep_2013.pdf

Since the Howto is half a year old already, I can confirm it still works for the current image:
2014-01-07-wheezy-raspbian.img
and the current special compiled kernel:
xecdesign.com/downloads/linux-qemu/kernel-qemu

Please Log in or Create an account to join the conversation.

Last edit: by Rain.

Cross compile console application? 10 years 8 months ago #5255

  • Javor
  • Javor's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • M.Sc in Computer Science, (ex-)freelancer
  • Posts: 72
  • Thank you received: 8

rain wrote: I can confirm the issue with the missing libs for console apps.
First I tried to copy the libs from a real Raspi, but it still had issues with eabi 0 vs 5 etc.
Since I needed my compiled binary fast, I gave up and just compiled it on the RasPi itself.
Lazarus is available on Raspi:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install fpc
sudo apt-get install lazarus

All I needed to do was to copy the Synapse source Dir also to the Raspi and include it's search path into the project settings - Path - "other Units -Fu" path edit box.

Since the Raspbian image even runs in the QEMU 1.6 ARM-Emulator qemu-system-armw.exe :woohoo: , no Raspbian Hardware is required and it is not so hard to compile "on the target" itself.

Of course I would prefer to cross compile from Windows like you are trying, but at least I'm not blocked by the issues.

That's how I do it atm, but it's painfully slow to compile and test. While X is opened on RPi, it consumes about 1/3 up to 1/2 of the resources :D, 'cos of the no-GPU support :(. So it takes ages to code, compile and run

rain wrote: There are a few different QEMU descriptions for Raspbian, but I found this to be the straightest one:

www.linux-mitterteich.de/fileadmin/dataf..._lug_18_sep_2013.pdf

Since the Howto is half a year old already, I can confirm it still works for the current image:
2014-01-07-wheezy-raspbian.img
and the current special compiled kernel:
xecdesign.com/downloads/linux-qemu/kernel-qemu

Surprisingly for me, the QEMU with Raspbian works slower than the RPi itself even on my Core2Duo machine... so I'll stick up to RPi, at least until libs are available.
Tried to copy necessary libs from Raspbian to same Win folders but still I can't cross-compile. Hope Sternas will include those needed in the next update, because it's a must I think :unsure:

Please Log in or Create an account to join the conversation.

Cross compile console application? 10 years 8 months ago #5278

  • Alfred
  • Alfred's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 21
  • Thank you received: 5
I am crosscompiling from Windows 8.1 64bit to RPi without any problem.
Console as well as GUI (GTK).
With hardware access (USB).
With plain FPC/Lazarus as well as with CodeTyphon.

So keep trying, you will succeed !!!
Or ask me about the setup-details if needed ...

Please Log in or Create an account to join the conversation.

Cross compile console application? 10 years 8 months ago #5298

  • XANDR
  • XANDR's Avatar
  • Visitor
  • Visitor
DonAlfredo, I try build the console app with cthreads for Rpi. I use CT 4.7 on Win7 64bit. Without cthreads unit the app was builded ok. But with cthreads unit i got the same that Markov and rain. Can you write your expirience or maybe your setup-details, i need help.

Please Log in or Create an account to join the conversation.

Cross compile console application? 10 years 8 months ago #5299

  • Javor
  • Javor's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • M.Sc in Computer Science, (ex-)freelancer
  • Posts: 72
  • Thank you received: 8
In fact I found a workaround. I connect with PuTTY to RPi, then I compile my project from command line. Here's an example :)

/usr/bin/fpc -MObjFPC -Scghi -O1 -gl -vewnhi -l -Fi/var/www/Src/lib/arm-linux -Flc:/lib -Flc:/codetyphon/libraries/arm-linux-pi -Fupl_Synapse/source -Fupl_LNet/source -Fu. -FUlib/arm-linux/ -oMy_Console_Application /var/www/Src/My_Console_Application.lpr

In my current project I use Synapse, lNet, rpi_hal (modified by me) for I/O, SPI and I2C operations and everything compiles without a problem on the RPi itself. Also no problems using units "cthreads, cmem,
unix". I just FTP my project to the desired folder ("/var/www/Src/" in the example above) and it's smooth and fast. Project compiles in like 9-10 secs. No need of any graphics at all.
The following user(s) said Thank You: XANDR

Please Log in or Create an account to join the conversation.

Cross compile console application? 10 years 8 months ago #5300

  • XANDR
  • XANDR's Avatar
  • Visitor
  • Visitor
Thank you, but is too bad that there are no solution for Win7 host build. I my case I will loose many time to build the app on device (in my case is FriendlyARM tiny 210) directly. I hope that CT 4.8 will resolve this problem...

Please Log in or Create an account to join the conversation.

Cross compile console application? 10 years 8 months ago #5301

  • Javor
  • Javor's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • M.Sc in Computer Science, (ex-)freelancer
  • Posts: 72
  • Thank you received: 8
Why should you waste time? You can always compile under Windows to check for errors and make final compilation on your device. If it has some version of Linux there, project will compile fast enough from console.
I hope too that in CT 4.8 problem will be solved.

Please Log in or Create an account to join the conversation.

Cross compile console application? 10 years 7 months ago #5310

  • XANDR
  • XANDR's Avatar
  • Visitor
  • Visitor
The problem was solved!!!!

The problem in incorrect source file cprt0.as (c:\codetyphon\fpcsrc\rtl\linux\arm\).

Detailed described: bugs.freepascal.org/view.php?id=24056

1. correct cprt0.as file.
2. rebuild cross arm-linux element.

after this I can build console app for linux-arm with pthread and pl_Synapce support!

to sternas, please fix this file in your next CT release.

Please Log in or Create an account to join the conversation.

Cross compile console application? 10 years 7 months ago #5311

  • Alfred
  • Alfred's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 21
  • Thank you received: 5
Glad you succeeded !!
Sorry I didn't reply sooner ... snow-holiday-delays ... !!

Please Log in or Create an account to join the conversation.

Cross compile console application? 10 years 7 months ago #5312

  • Javor
  • Javor's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • M.Sc in Computer Science, (ex-)freelancer
  • Posts: 72
  • Thank you received: 8
:( doesn't work for me. I'll have to dig deeper when I have time. So far my projects deadline is near and can't even think of trying anything else. Currently in my project I use: lNet, rpi_hal, fpjson, jsonparser, sqlite3conn, sqlite3dyn, sqldb, synaser, ... so I'll have to try skipping those one by one until I get a success. What seems strange to me is that compiler message console spits out the following:
c:\codetyphon\fpc\bin\i386-win32\arm-linux-ld.exe: warning: link.res contains output sections; did you forget -T? <-- :huh: this one should be a warning only and not an error. It is reported to me as an error... ?!
c:\codetyphon\fpc\bin\i386-win32\arm-linux-ld.exe: cannot find -lpthread <-- this one I see for the first time... although cthreads, cmem and unix units are included.
Will try to play after I get my project finished as I currently have absolutely no time.
Thanks for the tip, XANDR

Please Log in or Create an account to join the conversation.

Cross compile console application? 10 years 7 months ago #5313

  • Alfred
  • Alfred's Avatar
  • Offline
  • Junior Member
  • Junior Member
  • Posts: 21
  • Thank you received: 5
@Markov:
What Linux are you using ?
I am using Arch Linux on Pi and BBB.
And I do not have to use the tric by XANDR to crosscompile succesfully from Windows to Linux !

Please Log in or Create an account to join the conversation.

Cross compile console application? 10 years 7 months ago #5314

  • Javor
  • Javor's Avatar Topic Author
  • Offline
  • Junior Member
  • Junior Member
  • M.Sc in Computer Science, (ex-)freelancer
  • Posts: 72
  • Thank you received: 8
I'm using Raspbian. Compiling from Windows to Raspbian works for GUI applications. What doesn't work is the pure console application cross-compile. Anyway it's still fast enough for me to FTP upload my project to RPi and compile via terminal ;)

Please Log in or Create an account to join the conversation.

  • Page:
  • 1