NO

Author Topic: Is there a tutorial on how to use Pellas C for beginners?  (Read 15433 times)

colepc

  • Guest
Is there a tutorial on how to use Pellas C for beginners?
« 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.

Offline Vortex

  • Member
  • *
  • Posts: 802
    • http://www.vortex.masmcode.com
Re: Is there a tutorial on how to use Pellas C for beginners?
« Reply #1 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
Code it... That's all...

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: Is there a tutorial on how to use Pellas C for beginners?
« Reply #2 on: January 03, 2015, 11:44:09 PM »
Read the help file, the basics are there.
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

colepc

  • Guest
Re: Is there a tutorial on how to use Pellas C for beginners?
« Reply #3 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?

dizergin

  • Guest
Re: Is there a tutorial on how to use Pellas C for beginners?
« Reply #4 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?

colepc

  • Guest
Re: Is there a tutorial on how to use Pellas C for beginners?
« Reply #5 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.

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: Is there a tutorial on how to use Pellas C for beginners?
« Reply #6 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.

It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

dizergin

  • Guest
Re: Is there a tutorial on how to use Pellas C for beginners?
« Reply #7 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?

colepc

  • Guest
Re: Is there a tutorial on how to use Pellas C for beginners?
« Reply #8 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".

dizergin

  • Guest
Re: Is there a tutorial on how to use Pellas C for beginners?
« Reply #9 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.

     
« Last Edit: January 04, 2015, 02:34:07 PM by dizergin »

colepc

  • Guest
Re: Is there a tutorial on how to use Pellas C for beginners?
« Reply #10 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?



Offline Vortex

  • Member
  • *
  • Posts: 802
    • http://www.vortex.masmcode.com
Re: Is there a tutorial on how to use Pellas C for beginners?
« Reply #11 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
Code it... That's all...

czerny

  • Guest
Re: Is there a tutorial on how to use Pellas C for beginners?
« Reply #12 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!

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: Is there a tutorial on how to use Pellas C for beginners?
« Reply #13 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.
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

colepc

  • Guest
Re: Is there a tutorial on how to use Pellas C for beginners?
« Reply #14 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.