Does Xojo Support File Opening on Linux?

I just purchased Xojo so I could generate a linux executable.

I copied the executable and libs over to a VM running Centos 7.9.

It complained about not being able to find libunwind.so, so I installed that via yum.

The application loaded up and the gui was displayed, but when it came to opening and reading a file it promptly segfaulted!.

I created a new simple App with one button whose action code is detailed below. I ran this on windows and a message box popped up telling me how many lines had been read.

I built this for linux and copied the files over, fired it up, pressed the button, chose a file in the file manager and it segfaulted.

Should this code work on Linux like it does in Windows? I wondering if Xojo Linux support isn’t that stable or as comprehensive as the marketing docs claim?

Thanks for your time,
Carl C.

Var File As FolderItem = FolderItem.showOpenFileDialog("")

Var lineIndex() As Integer

Var input As TextInputStream
input = TextInputStream.Open(file)

While Not input.EndOfFile
Var tmpStr As String = input.readLine()
lineIndex.Add(input.BytePosition())
Wend

MessageBox ("Read lines: " + lineIndex.LastIndex.toString + EndOfLine)

input.close()

If I don’t use the showOpenFileDialog call, and instead set the file path/name programmatically the code works fine (see below). So, I’m guessing that the FileDialog is returning a null/nil FolderItem, even though I’m opening the same file that I set programmatically.

Interestingly if I add a check for nill on the file variable before I use it, OR if I new the file FolderItem before trying to assign it to the return of showOpenFileDialog it still segFaults. Which would suggest that at least in Centos 7.9 the open file dialog becomes unstable after selecting a file and before returning, so it looks like its fundamentally broken as opposed to something I’m doing.

// Var file As FolderItem = FolderItem.showOpenFileDialog("")

Var file As FolderItem = New FolderItem("/home/user/Projects/Xojo/FileTestA/num.txt", FolderItem.PathModes.Shell)
var lineIndex() As Integer

Var input As TextInputStream
input = TextInputStream.Open(file)

While Not input.EndOfFile
Var tmpStr As String = input.readLine()
lineIndex.Add(input.BytePosition())
Wend

MessageBox ("Read lines: " + lineIndex.LastIndex.toString + EndOfLine)

input.close()

Oh, and if I use the code from the xojo docs on openFileDialog (http://docs.xojo.com/OpenFileDialog which explicitly mentions “TargetLinux” it also SegFaults on Centos 7.9. Guess I’ll need to implement some kind of file chooser myself, or reduce the functionality to users needing to cut ‘n’ paste their path/file into a TextBox. Kind of disappointing for my first foray into Xojo/Linux … but at least it can be worked around.

Have you checked whether the two folderitems are really pointing to the same file? Check their NativePath properties. It’s fairly possible the OpenFileDialog returns another file (e.g. by resolving symbolic links).

If you’re sure they are the same file, that’s surprising. I can’t see how showing an OpenFileDialog would interfere with reading the file later. Perhaps the dialog retains some kind of preview?

I’d try some more things:
1: try reading as a binary stream instead of a text input stream.
2: try not reading at all. e.g. Show a MessageBox telling the size of the file.
3: try delaying between showing the OpenFileDialog and accessing the file; perhaps a delay would allow the file to be released, should it be retained…
4: put a breakpoint before opening the file and check if its properties are correct.
5: either build your app or run it paused; in both cases, you get an executable file not yet launched. Open the Terminal and launch your app from there. When the SegFault occurs, the Terminal should tell you more about the problem.

Thanks for the feedback.

It’s definitely the same file, its a text file with numbers from 0 to 100 that tested the code against of windows and then moved to linux, in the same place that I copied the xojo executable to.

I can’t check the actual “pointers” since the executable crashes before the openFileDialog returns a FolderItem handler, pointer, object (whatever xojo calls it). E.g. if I do

Var file As New FolderItem
file = FolderItem.showOpenFileDialog("")
If file <> Nil Then
MessageBox (“File opened”)
Else
MessageBox (“File was Nil”)
End If

It crashes with the SegFault right after I select the file in the dialog, and before it gets to the Nil check. Note: I’m not even trying to open the file or do operations on it… just a simple Nil check as per the xojo documentation for openFileDialog.

Re 1: it dies before I can even open it as a text stream, so I’m guessing the binary stream wont help.
Re 2: Yep, I tried that and it dies after clicking the file in the dialog.
Re 3: Hmmm, I can’t expect my users to wait an arbitrary time before interacting with the dialog that just opened for them. But, I tried it and it still dies.
Re 4: It dies before I can even check if the FolderItem is Nil, so nope cant check its properties.

Re 5: I’m actually building on windows and then copying over to linux, I think you’re suggesting that I install xojo onto linux and build there… I’ll give this a go.

My suspicion is that there is a incompatibility between centos 7.9 and whatever xojo is doing on the backend for linux, but I think trying the linux installation of xojo is a good idea.

Thanks,
Carl C.

Well I think that confirms that there is a problem with Xojo and Centos 7.9 at least where file dialogs are concerned.

I installed the linux version of Xojo. It fired up fine, I created a new project. Added a button with an action handler… cut n pasted my code over from windows. Then I went to run it.

Before I could run, I needed to save it. The save dialog window opened, I navigated to my project directory, I created a new folder I clicked save… and BAM!!

libocci.so.10.1: cannot open shared object file: No such file or directorySegmentation fault (core dumped)

According the forums one should remove the OraclePlugin … so I did that.

Started up Xojo again, created a project, added a button… blah blah.

Went to save the project, and BAM…

Segmentation fault (core dumped).

Soooooo… I’m guessing the previous error message was actually two errors.

I’m pretty sure there is an issue with Centos 7.9 and the file dialog windows.

Carl C.

So it’s safe to say that it crashes “in” the file dialog. Please fill a feedback report (use the Feedback button in Xojo) and report this bug, that you could reproduce.

This will still eliminate potential bugs.
And once you’ve built right on Linux, use the Terminal to launch your app. That’s important as you’ll probably see more information about the crash in the Terminal window (rather than just the app disappearing).

Please make sure this file is actually installed. I’m guessing your current installation isn’t 100% supported yet and you have to install this library. You can check the compatibility page of Xojo.

I’ve filled a support ticket with the issue and a reference to this thread.

Unfortunately, it looks like I can’t save the project to get to running my app. So, yep definitely a little flakey on Centos 7.9.

Carl C.

Apparently that requires me to install the “Oracle Instant Client” from Oracle… I’m probably not going to do that. I was really excited with the prospect of developing cross platform apps, especially those that claimed to be self contained. My experience is that most companies don’t give you root access to linux and getting the corporate IT department to install things like “Oracle Instant Client” on all the workstations is going to dissuade potential users. Something like gnu libunwind may be doable, but when it comes to installing a whole package from oracle just for a simple $20 labor saving app is probably not going to fly. I’ll do some more research, but its not looking as simple as “just develop the app and share it across different platforms”, if that linux platform has to be a very customized distribution.

Several Linux distributions are supported, including CentOS. I’m not a Linux expert, so I don’t know how much that represents, but you can already take a look there: Resources:System Requirements - Xojo Documentation

It says:

CentOS 7 or later

So, apparently I should be good to go with Centos 7.9.

Have you customised your CentOS installation in a way that it wouldn’t work for Xojo? :man_shrugging:

64Bits ?

The LR have examples and these use TRY…

Read there:

https://docs.xojo.com/TextInputStream

Try/catch blocks won’t help when an app hard crashes. These handle exceptions, but hard crashes don’t generate exceptions (the app is just terminated).

Apparently the Xojo Devs have recreated the issue themselves (#65751), so I guess this isn’t something peculiar to my relatively clean install on centos 7.9 in a VM.

Thanks for all the suggestions!

1 Like

I worked around this by creating my own open file dialog, which works perfectly on both windows and linux.

LinuxFileChooser

I’m able to double click on folders to navigate up and down the folder hierarchy, and then once a file is selected and the open button clicked, I get back a FolderItem for the file that was selected. So far no SegFaults in sight :grinning: .

Its simple, but effective. I’m a little happier with Xojo … it took me a while to get my head around getting an object into and out of a modal window, but other than that it was relatively straight forward and painless. I’m pretty sure I can make it more fancy as and when I need to.

1 Like

While it’s true you can make your own “select file” dialog, it’s usually not a great idea. As soon as your original issue with the built-in dialog gets resolved, I suggest you to use it again.

Here are some things an intermediate or advanced user may want:
Control+N or Command+N to create a new folder.
Backspace or Command-Up arrow to move to the parent folder.
Auto-detect when an item is added, removed or renamed in the current list (refresh the list).
Columns showing other data than just the name.
An expected UI.
(etc.).
Some users would be disappointed to not see these things.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.