Welcome! Log In Create A New Profile

Advanced

running text book source code

Posted by princedavinci 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
running text book source code
August 14, 2012 04:07PM
hello guys

i am having a problem with running programs from the book that were posted out by the lecturer on my unisa. if i copy and paste the programs on my dev C++ compiler and try to compile the code i get an error like so:
error C:\unisa\COS3712\Untitled11.cpp:233`main' must return `int'
C:\unisa\COS3712\Makefile.win [Build Error] exe: *** [Untitled11.o] Error 1

much appreciate it in advance.
Re: running text book source code
August 14, 2012 05:39PM
It's probably that your compiler is set to "strict" mode or whatever.
Since it says that your main function needs to return an int, make it return an int.

The int will be your exit status (0 - Normal Termination , 1 - Abnormal Termination)

Do like so

Language: C++
#include <whateverwhatever>   int main() { someGLFunctionCallHere(); ... ... ...   return 0; }
Re: running text book source code
August 15, 2012 12:37PM
i did that and it still gives me the same error
avatar Re: running text book source code
August 15, 2012 03:12PM
The error message merely means that the build failed.
Check the log to see why.

Possible cause is that you need to link to the correct libraries.
Check you compiler settings.
avatar Re: running text book source code
August 15, 2012 03:14PM
Should have mentioned -

Have a look at the Unisa CD - COS2611
There is some useful info on troubleshooting Dev C++.
Re: running text book source code
August 15, 2012 03:23PM
bigron11 everything is setup as instructed in the unisa cd and when i run programs using just the normal source files they run ok, only when im using opengl i get those errors. but another thing is that the opengl test program included in the unisa disk runs with no problem, its just the book code provided by the lecturer... 5th edition code.
avatar Re: running text book source code
August 15, 2012 03:39PM
Google this:

Makefile.win [Build Error] exe: *** [Untitled11.o] Error 1

and you will get some useful info.
Re: running text book source code
August 15, 2012 03:44PM
ok cool, thanks
avatar Re: running text book source code
August 15, 2012 03:46PM
Troubleshooting
It is possible that Dev-C++ doesn't know where the MinGW compiler is. Check the following in "Tools | Compiler Options" under the "Directories" tab:
C:\unisa\mingw\bin should be added to "Binaries".
C:\unisa\mingw\lib should be added to "Libraries".
C:\unisa\mingw\include should be added to "C Includes".
"C++ Includes" should be empty.
Note that if you installed the MinGW compiler in a directory other than the default (i.e. not in C:\unisa\mingw) then you will have to change these paths accordingly.
Also check that the correct make program is being used: Click on "Tools | Compiler Oprions" and then on the "Programs" tab. Make sure that mingw32-make.exe is specified as the make program (and not gmake.exe).

If you get an error of this type:
C:\unisa\xxxx\Makefile.win [Build Error] * [xxx_private.res] Error 1
during make, retry the make/compile again and the error should dissappear.
Re: running text book source code
August 15, 2012 03:52PM
that part is 100%
Re: running text book source code
August 16, 2012 01:56AM
>princedavinci

try the following it helped me get my program to work.

1. Use DevC++ 4.9.9.2 available here:http://sourceforge.net/projects/dev-cpp/files/Binaries/Dev-C%2B%2B%204.9.9.2/devcpp-4.9.9.2_setup.exe/download for free
2. Once installed do the following:
3. Go Tools Menu
4. Click Check for Updates/Packages
5. Under Select devpak server: choose devpaks.org Community Devpaks
6. Click Check for updates
7. Scroll down and look for glut and freeglut
8. Tick inside the square box next to glut and freeglut
9. Click Check for updates again glut wil be downloaded and installed automatically
10. After installation is finished you will have templates for glut programs under the multimedia tab in the create project window

If this don't help check your program. I didn't tried to run Angel's codes in the book.
Re: running text book source code
August 16, 2012 12:56PM
ok cool will try that now!
avatar Re: running text book source code
September 21, 2012 08:52PM
Quote

error C:\unisa\COS3712\Untitled11.cpp:233`main' must return `int'
C:\unisa\COS3712\Makefile.win [Build Error] exe: *** [Untitled11.o] Error 1

You're all over-analysing and missing the point. You need to actually read the error messages before wildly guessing at possible causes.

When I read these two message lines, what I see is that there is one error. The second line merely restates that the compile, as a whole, failed, so it's not a second error.

The crux of the problem is described in the first line.

What it's saying is that it found an error on line 233 of Untitled11.cpp. ((The mere fact that this error line was reported means that your compiler is setup properly. There's no need to go on a wild goose chase looking to see if MinGW is installed correctly or not. If it wasn't, you wouldn't have gotten this far.))

The error is saying that 'main' must return 'int'. This is in the format or <FUNCTION> must return a value of <TYPE>. That's all it's saying. This kind of error is most commonly shown when you forget to return a value, or if you are returning a value, then you're returning a value of a different type and that type cannot be automatically converted into the expected type.


FYI:
The main function is a very special function. You have to have one so that the startup code (added automatically by the compiler) knows which part of your code must start.

Although you are usually told to create the function with a return type of int, this is not a requirement. Any of the following prototypes are allowed for the main function:

void main();
void main(int argc, char **argv);
int main();
int main(int argc, char **argv);

(There may be more acceptable versions)

When you define a return type, make sure you return a value, and that if you have conditional constructs (eg if () statements), that all possible execution paths return a value.
avatar Re: running text book source code
September 21, 2012 09:00PM
Quote
dubbelodub
The int will be your exit status (0 - Normal Termination , 1 - Abnormal Termination)

This is not a rule, this is merely a convention. You can return any value you wish. The return value is only of use if your program was executed by some other program and it needs to know whether your program succeeded or not, or if some other state was achieved. The actual values are irrelevant but both programs must agree what the various values mean.
Re: running text book source code
September 23, 2012 11:34PM
@robanaurochs

Oh okay, I see you're right.

Just out of interest have you done/are you doing this course?
avatar Re: running text book source code
September 24, 2012 11:25AM
I'm an old student. I just haven't visited Osprey in a while.
Re: running text book source code
September 24, 2012 04:06PM
Well stick around man. You're a legend
Sorry, only registered users may post in this forum.

Click here to login