• 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.
Sign in to follow this  
Followers 0
CodeRot

Problem: undefined reference to 'WinMain@16'

4 posts in this topic

Hello,
 
I'm using two compilers: VS2005 Professional Edition and a pre-built distribution of the GCC toolchain obtained here.  I'm using two compilers simply to test my code over alternative compilers.  Also I'm a newbie to GCC.
 
I have a static library which contains the framework and implementation of the WinMain function and an executable which links in the static library.  This works fine when I compile and link with the MS toolchain, however I get the error mentioned above when using the GCC toolchain. I know that this error is caused by the linker not finding the function in any of the object files that it is linking to the executable.  Is there anyway of getting around this using either a command-line compilation and linkage (using GCC) or using Code::Blocks 10.05 to make the applicable compile and link settings to get this to work?.
 
Thanks.
 
 

0

Share this post


Link to post
Share on other sites

I'm not a GCC/MinGW expert, but I would suggest that your linker settings may be in the wrong order, do you have -lmingw32 (or -lmingw64) listed ahead of other libraries (indicated by the -l prefix) or is it after a bunch of them?

 

Also worth a check, are you using the -mwindows flag? (I would guess you are as I wouldn't expect it to complain about WinMain otherwise).

Edited by dmatter
0

Share this post


Link to post
Share on other sites

I've checked the linker settings in Code::Blocks and neither of those libraries were present (at least I couldn't see if they were there).  I added each one in turn (separately) and the linker reported that neither of the libraries were present on my system. I don't want to install these incase it messes up something else since I'm using someone elses GCC distribution and given that GCC is particularily picky when it comes to linking libraries and such.  

As a test I created a standard Win32 GUI application and noted that it links in kernel32, user32 and gdi32 (same as my executable) there didn't appear to be any reference or link setting to either of the libraries that you mentioned. So I assume no problems there.  

Anymore help appreciated.

0

Share this post


Link to post
Share on other sites

I've checked the linker settings in Code::Blocks and neither of those libraries were present (at least I couldn't see if they were there).  I added each one in turn (separately) and the linker reported that neither of the libraries were present on my system.

I'm not really familiar with C::B, when you added the lib did you put the -l prefix on? It's quite possible you need to link to the library differently in C::B than you would from the commandline (e.g. maybe with a fullblown path rather than the -l shorthand stuff). Or maybe it just doesn't know where the lib is (mis)located; there will be a way to add a lib directory if that's the case.

Can you find libmingw32.a in your mingw install? I believe this is a library you need to link with and to do so ahead of your custom lib containing WinMain.

My current hypothesis is this:
Your WinMain is in a separate lib, while the MS compiler is fine with that GCC is not because it will not link unused symbols and WinMain is, at that point, unused. The fix is to link with mingw32, a teeny(?) library that just has a regular main() function that forwards onto your WinMain function. You link it in ahead of your custom lib which therefore causes the linker to actually use your WinMain rather than ignore it. Edited by dmatter
1

Share this post


Link to post
Share on other sites

My apologies.  I've just double checked mingw32.a and it is in fact in my MinGW\lib installation directory.  I checked the link line in C::B and I had "-lming32" not '-lmingw32' as it should have been.  This now links and runs as it does with the MS toolchain.

 

Many thanks for your time and assistance.  :)

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0