• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

StoNeD_TrOLL

wtf???

26 posts in this topic

Im using CodeWarrior Learning Edditon.My project has two files that have no flaws(made sure).When i got to run my project i get a link error about something wrong with main in both files.Whats wrong here?
0

Share this post


Link to post
Share on other sites
please list the exact error message, and you''ll probably get a more appropriate response.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
0

Share this post


Link to post
Share on other sites
did u check to make suere that u have the proper header fies included? u sould also make suer u have the proper .lib files included

,Matt

-= kill one, your a murderer, kill thousands your a conquerer =-
0

Share this post


Link to post
Share on other sites
#include <iostream> is a header file right?
and i dont know what .lib files are.
here are the errors:
Link Error : multiply-defined ''main'' (descriptor)
Defined in bkla.cpp
Defined in HelloWorld.cp

Link Error : multiply-defined ''main'' (code)
Defined in bkla.cpp
Defined in HelloWorld.cp

0

Share this post


Link to post
Share on other sites
Have you got more than one WinMain or main() function? If so, that''s your problem right there.
0

Share this post


Link to post
Share on other sites
quote:
Original post by Anonymous Poster
Have you got more than one WinMain or main() function? If so, that''s your problem right there.

wait,i only need one main out of my two files?
0

Share this post


Link to post
Share on other sites
Only one main, always remember that.

By the way, anything that is a .h is a header file. Header files basically are used to include the .lib in your program, but you have to add the .lib to your project. If your not using an API like Windows or DX/OpenGL, you don't have to worry about .libs yet.

You only need one main in your whole project, because you are including the other files which are connected to the file that has main in it.
------------------------------
Simple DirectMedia Layer:

Main Site - (www.libsdl.org)
Cone3D Tutorials- (cone3D.gamedev.net)
GameDev.net's Tutorials - (Here)

OpenGL:

Main Site - (www.opengl.org)
NeHe Tutorials - (nehe.gamedev.net)
Online Books - (Red Book) (Blue Book)


Edited by - Drizzt DoUrden on January 12, 2002 12:39:20 PM
0

Share this post


Link to post
Share on other sites
quote:
Original post by Drizzt DoUrden
Only one main, always remember that.
------------------------------------------------------
I know one main per a file, but do you mean one main out of all my files in my project??


0

Share this post


Link to post
Share on other sites
definitely one "main" per project. the linker looks for a function named "main" and sets the program to start here. thus if there were two "main"''s then it wouldn''t know which one to choose.

To the vast majority of mankind, nothing is more agreeable than to escape the need for mental exertion... To most people, nothing is more troublesome than the effort of thinking.
0

Share this post


Link to post
Share on other sites
Thank you!!!So in my other files i just put in the header and go straight to the coding?like this:
#include <iostream>
{
std::cout <<"Hi!\n";
return 0;
}


Edited by - StoNeD_TrOLL on January 12, 2002 12:53:31 PM
0

Share this post


Link to post
Share on other sites
No. You make another function, like -

  
int PrintHi()
{
std::cout <<"Hi!\n";
return 0;
}


Remember to use function prototypes. Have you read any books/tutorials on C++ yet?

------------------------------
Simple DirectMedia Layer:

Main Site - (www.libsdl.org)
Cone3D Tutorials- (cone3D.gamedev.net)
GameDev.net''s Tutorials - (Here)

OpenGL:

Main Site - (www.opengl.org)
NeHe Tutorials - (nehe.gamedev.net)
Online Books - (Red Book) (Blue Book)
0

Share this post


Link to post
Share on other sites
No, you create functions with names other than main.

int myReallyCoolUsefulFunction(void)
{
std::cout << "Hi!\n";
return 0;
}

Edit: Crap! You beat me to it...

Edited by - Martee on January 12, 2002 1:02:27 PM
0

Share this post


Link to post
Share on other sites
Sorry.

Stoned Troll, you should check out the book ''sams teach yourself c++ in 21 days.'' It''s a really great book; you''ll learn alot from it.

------------------------------
Simple DirectMedia Layer:

Main Site - (www.libsdl.org)
Cone3D Tutorials- (cone3D.gamedev.net)
GameDev.net''s Tutorials - (Here)

OpenGL:

Main Site - (www.opengl.org)
NeHe Tutorials - (nehe.gamedev.net)
Online Books - (Red Book) (Blue Book)
0

Share this post


Link to post
Share on other sites
Im reading a c++in twenty four hours.And Drizzt,when i do your code my complier gives me this:
Error : undefined identifier 'std'
bkla.cpp line 3 std:: cout <<"Hi!\n";



Edited by - StoNeD_TrOLL on January 12, 2002 1:07:55 PM
0

Share this post


Link to post
Share on other sites
Just leave out the "std::". It''s not supposed to be there.
0

Share this post


Link to post
Share on other sites
cout is unidentified to my complier if i dont put"std::"...................none of this is working.

Edited by - StoNeD_TrOLL on January 12, 2002 4:41:08 PM
0

Share this post


Link to post
Share on other sites
The #include <iostream.h> worked but now where back to main!!!!How do you guys make a file when you already have a file with main???

Edited by - StoNeD_TrOLL on January 12, 2002 4:57:47 PM
0

Share this post


Link to post
Share on other sites
Hold it!

Erroneous info is being passed around here. <iostream.h> is the old-style C++ stream I/O header; the new one is <iostream>. You should aim to always use the new header unless you''re just prototyping some code you won''t have to live with in the future.

Having included the new-style header, cin, cout and all other iostream-defined objects and classes are declared under the std namespace. You can import the entire namespace into your working namespace (the top-level unnamed namespace), but that''s a bad idea in the long run.
using namespace std; 

Alternatively, you can import particular entities from a namespace:
using std::cout; 

After this line above, you can refer to cout anywhere in the same file (if it''s a header file, you can refer to cout without prefix in any other files that include it).

The third option is to explicitly qualify the object name every time you use it:
std::cout << "H1!" << std::endl; 

As you can see, endl is also under the std namespace.

Finally, there''s no substitute for a good book and tons of trial and error. If you have more problems, the great folks here at GameDev are only too willing to help.

Happy Hacking!

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!
0

Share this post


Link to post
Share on other sites
You whole project needs to only have one main() function, as others have pointed out. The other .c or .cpp files are used to declare other functions to use with your program.

-------In file1.cpp--------------

#include <iostream>
using namespace std;

void MyOtherFunction(char *str);

int main(int argc, char *argv[])
{
MyOtherFunction("hello";
return 0;
}


-----In file2.cpp---------------

#include <iostream>
using namespace std;

void MyOtherFunction(char *str)
{
printf("%s", str);
return
}


Multiple source files are used only to organize source code and they only build to one program. In the above example you could use the file2.cpp in another project that needs the MyOtherFunction() function.

I hope that clears the mystery behind it.


Oh for the other guys that are confused about std::,

when you include <iostream> function/classes are in "namespaces" and you need to specify "using namespace std" to use classes in that namespace. When you include <iostream.h>, this doesn''t have any namespace and is similar to the older C style headers.

By saying "using namespace std" you tell the compiler that you want to use ALL the classes/functions in that namespace, but if you want to use only a few, you could do "using std::cout;" using std::cin;" and this will let you call cin and cout without typinh "std::cout << "hello"" all the time.

Ok, enough typing for now.


0

Share this post


Link to post
Share on other sites
Heres my little file2.cpp:
#include <iostream>
using namespace std;
void
{
std::cout <<"This dosnt work";
}
i get these errors:
Error : declaration syntax error
ngw.cpp line 4 {

Error : declaration syntax error
ngw.cpp line 5 std::cout <<"This dosnt work";

Error : declaration syntax error
ngw.cpp line 6 }

what is wrong now?!!!

Edited by - StoNeD_TrOLL on January 12, 2002 6:54:05 PM
0

Share this post


Link to post
Share on other sites
quote:
Original post by StoNeD_TrOLL
void
{

void is a return type declarator or an indicator that a function takes no parameters. You can not declare a variable of type void, and you can not simply place the void keyword in the middle of nowhere.

Try this:
#include <iostream>
using namespace std;
int main(void)
{
std::cout << "This works." << endl;
return 0;
}

(The C++ standard requires main to have a return type of int).

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!
0

Share this post


Link to post
Share on other sites