Pelles C forum

C language => Beginner questions => Topic started by: colepc on January 03, 2015, 07:18:46 PM

Title: Is there a tutorial on how to use Pellas C for beginners?
Post by: colepc on January 03, 2015, 07:18:46 PM
This tutorial should include all the steps needed to generate a simple running program such as printing "Hello, world" using the command prompt window. Perhaps it could then demonstrate additional features of Pelles C in simple steps.
Title: Re: Is there a tutorial on how to use Pellas C for beginners?
Post by: Vortex on January 03, 2015, 07:56:56 PM
Hello colepc,

Welcome to the forum.

Here is a quick example :

Start -> Programs -> Pelles C for Windows -> Pelles C Command Prompt

Code: [Select]
Setting 32-bit environment for Pelles C...

D:\PellesC>type hello.c
#include <stdio.h>

int main(void)
{
 printf("Hello world!\n");
 return 0;
}

D:\PellesC>pocc hello.c

D:\PellesC>polink hello.obj

D:\PellesC>hello.exe
Hello world!

pocc is the Pelles C compiler. It compiles the source code and creates an object module. The object file hello.obj is processed by the linker Polink and this tool outputs the final executable named hello.exe
Title: Re: Is there a tutorial on how to use Pellas C for beginners?
Post by: frankie on January 03, 2015, 11:44:09 PM
Read the help file, the basics are there.
Title: Re: Is there a tutorial on how to use Pellas C for beginners?
Post by: colepc on January 04, 2015, 12:36:19 AM
pocc seems to do OK using the default directory to read hello.c and to write hello.obj.

polink has problems using the default directory finding "external symbols".
Its first error was "Unresolved external symbol '_Rt11Unwind@16'."
Do I need to add to the "path" in Windows 7 to find the "external symbols"? If yes, what do I need to add and what is the safest way to add these paths?
Title: Re: Is there a tutorial on how to use Pellas C for beginners?
Post by: dizergin on January 04, 2015, 01:10:28 AM
to colepc
please answer next questions shortly (yes,no)
1.  is English  your native language (if no just name your language)
2. Are you new to any programming activity?
3. Are you new to the C language?
Title: Re: Is there a tutorial on how to use Pellas C for beginners?
Post by: colepc on January 04, 2015, 02:59:26 AM
1 = Yes.
2 = No.
3 = No. I've programmed with C over 10 years ago. I figure some or most of it will come back with a little use. My problem is not programming with C, it is using the compiler (Pelles C) and using it with Windows 7. I like using the Command Prompt but it's been 10 years or more since I've used BAT files and the ones I have will not run on Windows 7.  I need to know if PATH needs to be modified. I need to know what Windows 7 "system variables" are needed such as LIB, INCLUDE, INIT, etc. (if Windows 7 uses them). Is there a prepared simple BAT file I could look at that includes what needs to be done to use Windows 7? Someone said to use the help file. What help file? The one in "PELLES C IDE"? That help file didn't seem to be setup for the beginner. I don't really want to learn how to use the IDE, like I said, I prefer using the Command Prompt.
Title: Re: Is there a tutorial on how to use Pellas C for beginners?
Post by: frankie on January 04, 2015, 03:29:09 AM
I've programmed with C over 10 years ago. I figure some or most of it will come back with a little use. My problem is not programming with C, it is using the compiler (Pelles C) and using it with Windows 7. I like using the Command Prompt but it's been 10 years or more since I've used BAT files and the ones I have will not run on Windows 7.  I need to know if PATH needs to be modified.
I need to know what Windows 7 "system variables" are needed such as LIB, INCLUDE, INIT, etc. (if Windows 7 uses them). Is there a prepared simple BAT file I could look at that includes what needs to be done to use Windows 7? Someone said to use the help file. What help file? The one in "PELLES C IDE"? That help file didn't seem to be setup for the beginner. I don't really want to learn how to use the IDE, like I said, I prefer using the Command Prompt.
When you install PellesC it should put the pellesC directory in the PATH so you can use command line compiler and utilities. As many systems of years ago (i.e. MSC, BorlandC, etc.) there is a precompiled BAT , povars32.bat for 32bits compiler suite and povars64.bat for 64 bits, that sets the correct compiler paths.
Open a consolle, type the BAT name and then you can compile.
If it don't work try to reinstall the product.

Title: Re: Is there a tutorial on how to use Pellas C for beginners?
Post by: dizergin on January 04, 2015, 09:03:26 AM
1 = Yes.
2 = No.
3 = No. I've programmed with C over 10 years ago. I figure some or most of it will come back with a little use. My problem is not programming with C, it is using the compiler (Pelles C) and using it with Windows 7. I like using the Command Prompt but it's been 10 years or more since I've used BAT files and the ones I have will not run on Windows 7.  I need to know if PATH needs to be modified. I need to know what Windows 7 "system variables" are needed such as LIB, INCLUDE, INIT, etc. (if Windows 7 uses them). Is there a prepared simple BAT file I could look at that includes what needs to be done to use Windows 7? Someone said to use the help file. What help file? The one in "PELLES C IDE"? That help file didn't seem to be setup for the beginner. I don't really want to learn how to use the IDE, like I said, I prefer using the Command Prompt.
tnx, what  are the typical tasks that you are going to perform with the aid  of the Pelles C?
Title: Re: Is there a tutorial on how to use Pellas C for beginners?
Post by: colepc on January 04, 2015, 12:48:25 PM
Dizergin - My "typical task" for Pelles C would be to write C programs that work on my computer with Windows 7 and 64 bit OS. As soon as I can get Pelles C to print "Hello, world" then my fun can begin.

The world has left me behind. I had to look up the meaning of "tnx" and I hope it means "thanks".
Title: Re: Is there a tutorial on how to use Pellas C for beginners?
Post by: dizergin on January 04, 2015, 01:31:37 PM
The world has left me behind. I had to look up the meaning of "tnx" and I hope it means "thanks".
yes, thanks.  :)
I started with Pelles C   nearly as you - so,  you  maybe find my experience  usefull for :
Unless  you like to face with some unpleasant "features" of  Pelles C you should:
1. Do not use RC6 - it is  too raw... v7 is  better choice
2. Use  the installation  dedicated  your  OS (32 bit Pelles C for 32 bit OS Win)
3. Shut down any antivirual program ( like avast) temporarily

After   installation:
      Check basic workflow via console 'hello world' program (or basic  winapi window program)
      To do that, just  use "File/New/Console Application wizard" ("File/New/Windows Application wizard") - to run  it  you must  type project name into name field and click  OK-button
      The wizard will generate simple project for you (so you can reach out the source file through right panel).
      The project can be compiled, build, and run by pressing dedicated button (on the tool panel) - if everything OK, you should see console (basic winapi) window with  the message.
      To debug the program you should set  up some fields in tabs (Compiler, Assembler, Linker) of the project options dialog ("Project/project options.. ") and then press "Go\Run" -button -
       - if everything  is OK - you should see the debugger's panels activated.

     
Title: Re: Is there a tutorial on how to use Pellas C for beginners?
Post by: colepc on January 04, 2015, 03:18:21 PM
I've programmed with C over 10 years ago. I figure some or most of it will come back with a little use. My problem is not programming with C, it is using the compiler (Pelles C) and using it with Windows 7. I like using the Command Prompt but it's been 10 years or more since I've used BAT files and the ones I have will not run on Windows 7.  I need to know if PATH needs to be modified.
I need to know what Windows 7 "system variables" are needed such as LIB, INCLUDE, INIT, etc. (if Windows 7 uses them). Is there a prepared simple BAT file I could look at that includes what needs to be done to use Windows 7? Someone said to use the help file. What help file? The one in "PELLES C IDE"? That help file didn't seem to be setup for the beginner. I don't really want to learn how to use the IDE, like I said, I prefer using the Command Prompt.
When you install PellesC it should put the pellesC directory in the PATH so you can use command line compiler and utilities. As many systems of years ago (i.e. MSC, BorlandC, etc.) there is a precompiled BAT , povars32.bat for 32bits compiler suite and povars64.bat for 64 bits, that sets the correct compiler paths.
Open a consolle, type the BAT name and then you can compile.
If it don't work try to reinstall the product.
Thanks Frankie for the help. There's always the problem of what does a beginner know. For example you told me about some BAT files but forgot to say where they are located. I finally found them at C:\Program Files\Pellesc\Bin.

I ran povars32.bat in a "Command Prompt" window and verified that PATH was modified. However, when I closed that window and opened it again, the PATH changes back to the default before running povars32.bat. With this procedure I will needed to run povars32.bat every time I open a new "Command Prompt" window. I don't want to do that every time so I will have to modify the default PATH. I think I know how to do that and will give it a try sooner or later.

I was finally successful creating hello.exe and running it in a "Command Prompt" window. I had to use povars32.bat to do that which I found interesting as my computer is a "64-bit Operating System" so I assumed I had to run povars64.bat. However, when I run povars64.bat, polink does not work. What works when povars64.bat is used?


Title: Re: Is there a tutorial on how to use Pellas C for beginners?
Post by: Vortex on January 04, 2015, 03:29:51 PM
Hi colepc,

My Pelles C installation is located on D:\PellesC. This should work on your 64-bit system :
Code: [Select]
D:\>cd PellesC\Bin

D:\PellesC\Bin>povars32.bat
Setting 32-bit environment for Pelles C...

D:\PellesC\Bin>polink.exe | find "Version"
Pelles Linker, Version 8.00.1

D:\PellesC\Bin>cd ..

D:\PellesC>polink.exe | find "Version"
Pelles Linker, Version 8.00.1

D:\PellesC>cd ..

D:\>polink.exe | find "Version"
Pelles Linker, Version 8.00.1
Title: Re: Is there a tutorial on how to use Pellas C for beginners?
Post by: czerny on January 04, 2015, 04:24:11 PM
I was finally successful creating hello.exe and running it in a "Command Prompt" window. I had to use povars32.bat to do that which I found interesting as my computer is a "64-bit Operating System" so I assumed I had to run povars64.bat. However, when I run povars64.bat, polink does not work. What works when povars64.bat is used?
Why do you want to work at the command line. Use the ide!
Title: Re: Is there a tutorial on how to use Pellas C for beginners?
Post by: frankie on January 04, 2015, 08:43:06 PM
Thanks Frankie for the help. There's always the problem of what does a beginner know. For example you told me about some BAT files but forgot to say where they are located. I finally found them at C:\Program Files\Pellesc\Bin.
You're welcome.
I understood your concerns, but your problems are more related to the OS than the compiler.
When you install PellesC the installer tell you where files will be located, everything related to PellesC is there.

I ran povars32.bat in a "Command Prompt" window and verified that PATH was modified. However, when I closed that window and opened it again, the PATH changes back to the default before running povars32.bat. With this procedure I will needed to run povars32.bat every time I open a new "Command Prompt" window. I don't want to do that every time so I will have to modify the default PATH. I think I know how to do that and will give it a try sooner or later.
Under windows the environment is private to local command shell, when you close consolle settings are lost.
You have to modify the default path and OS environment variables using the system applet. You can use the values found in povars bat.

I was finally successful creating hello.exe and running it in a "Command Prompt" window. I had to use povars32.bat to do that which I found interesting as my computer is a "64-bit Operating System" so I assumed I had to run povars64.bat. However, when I run povars64.bat, polink does not work. What works when povars64.bat is used?
It should work if you set the compiler switch for 64 bits executables.
Open the help and read at least the command line commands section.
Anyway the best part of PellesC is the IDE, I strongly suggest you to start to use it. The project files (ppj) are makefile like.
Title: Re: Is there a tutorial on how to use Pellas C for beginners?
Post by: colepc on January 05, 2015, 03:15:07 AM
Thanks Frankie again for your suggestions and help. I grew up with CP/M then went to Microsoft DOS so I've used command lines a lot. However, I've never been real good with BAT files. I remember using Borland Turbo C IDE and it was tough converting everything to the Microsoft C command line compiler for some hardware projects I had to do (a long time ago). So far I'm excited that I can program again with C on my home computer. Pelles C command line allowed me to do that. I got up at 5:00am today and have been going strong all day. I've only eaten breakfast and it is getting close to bed time. It's been a fun day.
Title: Re: Is there a tutorial on how to use Pellas C for beginners?
Post by: Bitbeisser on January 05, 2015, 03:48:11 AM
Thanks Frankie again for your suggestions and help. I grew up with CP/M then went to Microsoft DOS so I've used command lines a lot.
Well, that makes you roughly as old as I am, I got started with CP/M, Apple DOS, Trash-DOS etc back in the '70s myself.

But ever since Turbo Pascal 1.0 on CP/M came out, I preferred to use an IDE for any compiler, in any language as much as I possibly could. This was also the main reason why I switched from DeSmet C to Turbo C as soon as that came out back in the early '80s.

You just have to see the IDE as a tool that is able to help you getting things done without having to deal with learning how each and every part of a compiler setup works on the command line. And pretty much each and every compiler is different, differences in the underlying OS notwithstanding...  ;)

Ralf
Title: Re: Is there a tutorial on how to use Pellas C for beginners?
Post by: frankie on January 06, 2015, 03:31:50 PM
Thanks Frankie again for your suggestions and help. I grew up with CP/M then went to Microsoft DOS so I've used command lines a lot.
Well, that makes you roughly as old as I am, I got started with CP/M, Apple DOS, Trash-DOS etc back in the '70s myself.

But ever since Turbo Pascal 1.0 on CP/M came out, I preferred to use an IDE for any compiler, in any language as much as I possibly could. This was also the main reason why I switched from DeSmet C to Turbo C as soon as that came out back in the early '80s.

You just have to see the IDE as a tool that is able to help you getting things done without having to deal with learning how each and every part of a compiler setup works on the command line. And pretty much each and every compiler is different, differences in the underlying OS notwithstanding...  ;)

Ralf

We are all on the same side ...  ;)
Anyway get your time to move on, CP/M was great, but that times are gone, and as we already have done you'll get your way on  :D
Title: Re: Is there a tutorial on how to use Pellas C for beginners?
Post by: czerny on January 06, 2015, 06:43:39 PM
This tutorial should include all the steps needed to generate a simple running program such as printing "Hello, world" using the command prompt window. Perhaps it could then demonstrate additional features of Pelles C in simple steps.
http://wiki.pellesc.de/doku.php/command (http://wiki.pellesc.de/doku.php/command)
Title: Re: Is there a tutorial on how to use Pellas C for beginners?
Post by: colepc on January 09, 2015, 03:29:23 PM
This tutorial should include all the steps needed to generate a simple running program such as printing "Hello, world" using the command prompt window. Perhaps it could then demonstrate additional features of Pelles C in simple steps.
http://wiki.pellesc.de/doku.php/command (http://wiki.pellesc.de/doku.php/command)
Thanks Czerny for the link for a quick guide for using the IDE. Should I get more adventuresome, I'll give it a try. Right now things are simple for me using the command prompt concept.

At this point I'm just kind of re-learning C after being away from it for so long. I need to re-read my copy of Kernighan/Ritchie "The C Programming Language" so I can re-remember how to use pointers, structures, and the other hard to learn stuff. Currently using a lot of while, if, and if/else but have yet to use for, do/while, and the others I've forgotten.

I created a program to view a file in hexadecimal, a program to create passwords, a program to encrypt a file using those passwords, and a program to decrypt the encrypted file. All of these I have done using simple command lines with no support for graphics or windows. I'm still having fun though, perhaps too much fun as I was mostly in C la la land all day and forgot to finish my laundry.   :P
Title: Re: Is there a tutorial on how to use Pellas C for beginners?
Post by: Bitbeisser on January 09, 2015, 09:56:31 PM
Thanks Frankie again for your suggestions and help. I grew up with CP/M then went to Microsoft DOS so I've used command lines a lot.
Well, that makes you roughly as old as I am, I got started with CP/M, Apple DOS, Trash-DOS etc back in the '70s myself.

But ever since Turbo Pascal 1.0 on CP/M came out, I preferred to use an IDE for any compiler, in any language as much as I possibly could. This was also the main reason why I switched from DeSmet C to Turbo C as soon as that came out back in the early '80s.

You just have to see the IDE as a tool that is able to help you getting things done without having to deal with learning how each and every part of a compiler setup works on the command line. And pretty much each and every compiler is different, differences in the underlying OS notwithstanding...  ;)

Ralf

We are all on the same side ...  ;)
Anyway get your time to move on, CP/M was great, but that times are gone, and as we already have done you'll get your way on  :D
I am honestly a bit puzzled how/why you reply to me like this?  :-\

Ralf
Title: Re: Is there a tutorial on how to use Pellas C for beginners?
Post by: frankie on January 10, 2015, 03:53:34 PM
I am honestly a bit puzzled how/why you reply to me like this?  :-\

Ralf
:(
Sorry Ralf. I meant:
As Ralf said ....
Title: Re: Is there a tutorial on how to use Pellas C for beginners?
Post by: Bitbeisser on January 11, 2015, 06:04:42 AM
I am honestly a bit puzzled how/why you reply to me like this?  :-\

Ralf
:(
Sorry Ralf. I meant:
As Ralf said ....
Aaahhh, that clears things up! ;-)

Ralf  8)