Command line compiler syntax to create executable?

Just starting out? Need help? Post your questions and find answers here.
segfault
User
User
Posts: 12
Joined: Wed May 24, 2017 7:17 am

Command line compiler syntax to create executable?

Post by segfault »

Hi,

My OS is Linux and I'm using the Linux IDE but would like to create a windows executable from the Wine emulator on the command line (using the source code written in the Linux IDE), but I keep getting errors when trying to use pbcompiler.exe to create an executable, either "no such switch" or "file not found". Could someone give me an example of the correct syntax? There isn't a specific example of this in the manual. Do I need to include quotes in the filename/path?

Sorry for the noob question, and thanks in advance for any help. :oops:
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8433
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Command line compiler syntax to create executable?

Post by netmaestro »

Not sure of Linux. No quotes needed.
Image
BERESHEIT
segfault
User
User
Posts: 12
Joined: Wed May 24, 2017 7:17 am

Re: Command line compiler syntax to create executable?

Post by segfault »

Hi netmaestro, thanks but I've already looked at the help and I'm still getting an error message "A filename needs to be specified".

Here's the output when I try to create an executable from a file "first.pb" in the folder "/home/jules/purebasic/code/".

Code: Select all

Z:\home\jules\.wine\drive_c\Program Files\PureBasic\Compilers>pbcompiler /EXE /home/jules/purebasic/code/first.pb
PureBasic 5.44 LTS (Windows - x86) - (c) 2016 Fantaisie Software
A filename need to be specified.
Type 'pbcompiler /?' for quick help.
Marc56us
Addict
Addict
Posts: 1479
Joined: Sat Feb 08, 2014 3:26 pm

Re: Command line compiler syntax to create executable?

Post by Marc56us »

You must provide the EXE filename you want to be created after /EXE (because it can be different of source file)

/EXE "Filename": Create an executable to the given filename

Code: Select all

Z:\home\jules\.wine\drive_c\Program Files\PureBasic\Compilers>pbcompiler /EXE "/home/jules/purebasic/code/first.exe" /home/jules/purebasic/code/first.pb
:arrow: Do not forget to add extension .exe (compiler does not add it by default)

:!: Note: without /EXE and filename, PB create an exe called PureBasic.exe in folder of pbcompiler (dangerous!)
IDE create PureBasic_Compilation0.exe (and 1, 2, 3 etc)

:idea: You are right, the message is not explicite, IMHO it must be
An output filename need to be specified.
segfault
User
User
Posts: 12
Joined: Wed May 24, 2017 7:17 am

Re: Command line compiler syntax to create executable?

Post by segfault »

Thanks Marc56us, but running that command I get "unknown switch":

Code: Select all

wine pbcompiler /EXE "/home/jules/purebasic/code/first.exe" /home/jules/purebasic/code/first.pb
/HOME/JULES/PUREBASIC/CODE/FIRST.PB: Unknown switch
Maybe it's easier if I just create the exe from the Windows IDE under Wine.
Marc56us
Addict
Addict
Posts: 1479
Joined: Sat Feb 08, 2014 3:26 pm

Re: Command line compiler syntax to create executable?

Post by Marc56us »

Code: Select all

wine pbcompiler /EXE "/home/jules/purebasic/code/first.exe" /home/jules/purebasic/code/first.pb
/HOME/JULES/PUREBASIC/CODE/FIRST.PB: Unknown switch
Try:

Code: Select all

wine pbcompiler /EXE "/home/jules/purebasic/code/first.exe" "\home\jules\purebasic\code\first.pb"
Test: Linux Debian 8 x64 on VirtualBox 5 (yes I know I'm root :shock: it's bad, but it's to late for me)

Code: Select all

root@debian:~/Wine_PureBasic/PureBasicLTS/Compilers# wine pbcompiler /exe "/root/Documents/hello.exe" "\root\Documents\hello.pb" 

******************************************
PureBasic 5.44 LTS (Windows - x86)
******************************************

Compiling \root\Documents\hello.pb
Loading external libraries...
Starting compilation...
3 lines processed.
Creating executable "/root/Documents/hello.exe".

- Feel the ..PuRe.. Power -

root@debian:~/Wine_PureBasic/PureBasicLTS/Compilers# ls -l hello*
-rwxr-xr-x 1 root root 3072 mai   24 13:52 hello.exe
-rw-r--r-- 1 root root   31 mai   24 13:51 hello.pb

root@debian:~/Wine_PureBasic/PureBasicLTS/Compilers# 
It works :wink:

The last time I used Wine it was in 1999 (!) I just reinstall it today (18 years later...) just to solve your problem :mrgreen:
segfault
User
User
Posts: 12
Joined: Wed May 24, 2017 7:17 am

Re: Command line compiler syntax to create executable?

Post by segfault »

Marc56us wrote:The last time I used Wine it was in 1999 (!) I just reinstall it today (18 years later...) just to solve your problem :mrgreen:
I really appreciate your help, but sadly still no luck. Did you mean for the second path to be using forward slashes instead of backslashes? Anyway, I tried both ways and here are the results (note that I changed the file to "Gadget.pb" taken from the examples folder):

With forward slashes

Code: Select all

wine pbcompiler /EXE "/home/jules/purebasic/code/first.exe" "\home\jules\purebasic\code\Gadget.pb"

******************************************
PureBasic 5.44 LTS (Windows - x86)
******************************************

Compiling \home\jules\purebasic\code\Gadget.pb
Loading external libraries...
Error: File not found (\home\jules\purebasic\code\Gadget.pb).
with backslashes:

Code: Select all

wine pbcompiler /EXE "/home/jules/purebasic/code/first.exe" "/home/jules/purebasic/code/Gadget.pb"
/HOME/JULES/PUREBASIC/CODE/GADGET.PB: Unknown switch
So I'm guessing it worked on your system?
Marc56us
Addict
Addict
Posts: 1479
Joined: Sat Feb 08, 2014 3:26 pm

Re: Command line compiler syntax to create executable?

Post by Marc56us »

Source file exist ?

Code: Select all

Error: File not found (\home\jules\purebasic\code\Gadget.pb)
What result of:

Code: Select all

file /home/jules/purebasic/code/Gadget.pb
Reply must be:

Code: Select all

/home/jules/purebasic/code/Gadget.pb : ASCII text
segfault
User
User
Posts: 12
Joined: Wed May 24, 2017 7:17 am

Re: Command line compiler syntax to create executable?

Post by segfault »

Aha!

Code: Select all

/home/jules/purebasic/code/Gadget.pb: ISO-8859 text, with CRLF line terminators
So I guess the problem is it's not recognized as a Windows file. I need to convert it, or use Gadget.pb from the Windows installation.

I'll do that and try again.
segfault
User
User
Posts: 12
Joined: Wed May 24, 2017 7:17 am

Re: Command line compiler syntax to create executable?

Post by segfault »

Strange, I converted the file using unix2dos but the file command still returns

Code: Select all

/home/jules/purebasic/code/Gadget.pb: ISO-8859 text, with CRLF line terminators
Marc56us
Addict
Addict
Posts: 1479
Joined: Sat Feb 08, 2014 3:26 pm

Re: Command line compiler syntax to create executable?

Post by Marc56us »

:?: all works for me
(Test now with PB sample Gadget.pb)
(previous file created with (horrible) 'vi' just a ligne MessageRequester("", "Hello"))
(removed long prompt)

Code: Select all

# file ../Examples/Sources/Gadget.pb
../Examples/Sources/Gadget.pb: ISO-8859 text, with CRLF line terminators

# wine pbcompiler.exe /EXE "Gadget.exe" ../Examples/Sources/Gadget.pb

******************************************
PureBasic 5.44 LTS (Windows - x86)
******************************************

Compiling ../Examples/Sources/Gadget.pb
Loading external libraries...
Starting compilation...
125 lines processed.
Creating executable "Gadget.exe".

# ls -l Ga*
-rwxr-xr-x 1 root root 55296 mai   24 15:30 Gadget.exe

# file Gadget.exe 
Gadget.exe: PE32 executable (GUI) Intel 80386, for MS Windows
Then transfered on Windows for test = OK
:wink:
segfault
User
User
Posts: 12
Joined: Wed May 24, 2017 7:17 am

Re: Command line compiler syntax to create executable?

Post by segfault »

Ok it finally works, but only when I put the source file in the compilers folder. So I guess the problem was to do with path/environment variables. I'll have to find out how to add these in Wine. Thanks a lot for your help. :)
Post Reply