• 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
Lith

Visual Studio 2012 Command Line Building Woes

6 posts in this topic

Good evening ladies and gentlemen..

 

This is the first time I have tried to download source from the web and compile it myself. This is also the first time I'm building a relatively large project on the command line..

 

I'm using Visual Studio 2012's cl.exe tool to build. I've pushed through a number of errors so far but this one's been bugging me for a few days. The project compiles fine but it won't link. It complains of the entry point not being defined:

LINK1561: entry point must be defined. 

I've checked that the main.cpp file is being built and checked that there is a valid main function inside. I'm pretty sure it has something to do with the project depending on SDL. If it matters, I'm not sure I'm using the same version of SDL that the code was written for. A few years back I was writing small games with SDL and I have vague memories of it being very picky with regards to entry points. You had to link to SDLmain.lib and define the main function with all command line argument arguments.

 

Here's my super sexy home grown makefile:

CC=comp.bat
SRC_SOURCE=*.cpp
SRC_HEADER=*.h
SRC_INC_1=C:\DevLib\SDL_1.2\SDL-1.2.15\include
SRC_INC_2=C:\DevLib\SDL_1.2\SDL_image-1.2.12\include
LIB_PATH_1=C:\DevLib\SDL_1.2\SDL-1.2.15\lib\x86
LIB_PATH_2=C:\DevLib\SDL_1.2\SDL_image-1.2.12\lib\x86
LIB_PATH_3=C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\lib;C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\atlmfc\lib;C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib;
LIB=SDL.lib SDLmain.lib SDL_image.lib

all: $(SRC_SOURCE) $(SRC_HEADER)
	$(CC) $(SRC_SOURCE) /I$(SRC_INC_1) /I$(SRC_INC_2) /EHsc /link SDLmain.lib SDL.lib SDL_image.lib /LIBPATH:"$(LIB_PATH_1)" /LIBPATH:"$(LIB_PATH_2)"

clear: 
	del *.obj
        del *.exe

As i'm sure you'll notice, not all of my LIB_PATH macros are being used. Some of them are scars from previous struggles..

 

Here is comp.bat: (I found this online somewhere)

@echo on
:: Load compilation environment
call "C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\vcvarsall.bat"
:: Invoke compiler with any options passed to this batch file
"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\bin\cl.exe" %*

Please tell me if there's any vital info I have omitted. All help is appreciated, thanks.

0

Share this post


Link to post
Share on other sites

After you have called [b]vcvarsall.bat[/b], you should only have to call [b]cl.exe[/b] rather than the full path since your path env variable has now been extended to include the VC/bin directory.

 

The error you are getting is because it is not finding either the [b]main[/b] or [b]winmain[/b] functions.

As I recall, SDL is a little bit screwy on Windows so I think it needs [b]/SUBSYSTEM:CONSOLE[/b] to be defined as a compiler flag.

 

Perhaps try putting that either before or after the [b]/link[/b] argument.

1

Share this post


Link to post
Share on other sites

Since you mentioned SDL:
I seem to remember SDL requiring the use of a specific main function, i.e. more strict that e.g. Windows does natively.

 

While int main() will work for normal stuff, I think SDL requires the function to be int main(int argc, char *argv[]).

This might not be your problem (you didn't post your actual function), but it's worth double checking.

0

Share this post


Link to post
Share on other sites

After you have called vcvarsall.bat, you should only have to call cl.exe rather than the full path since your path env variable has now been extended to include the VC/bin directory.

 

The error you are getting is because it is not finding either the main or winmain functions.

As I recall, SDL is a little bit screwy on Windows so I think it needs /SUBSYSTEM:CONSOLE to be defined as a compiler flag.

 

Perhaps try putting that either before or after the /link argument.

 

That seemed to do the trick, thanks!

 

I'm still not out of the woods yet though.. I was having trouble before where I think I was linking to too many standard libs because, while in msvcrt.lib, it complained of functions being already defined in LIBCMT.lib. So I added this to the linker options

NODEFAULTLIB:msvcrt.lib 

And that brings me to my present situation.

 

Now I'm getting a few warnings followed by some unresolved externals:

SDLmain.lib WARNING LINK4217: Locally defined symbol _exit imported in function _main
SDLmain.lib WARNING LINK4217: Locally defined symbol _strrchr imported in function _main
SDLmain.lib WARNING LINK4217: Locally defined symbol ___iob_func imported in function _main
SDLmain.lib WARNING LINK4217: Locally defined symbol _fgetc imported in function _main
SDLmain.lib WARNING LINK4217: Locally defined symbol _fopen imported in function _main
*a few more of these*
SDLmain.lib ERROR LINK2019: unresolved external sumbol __imp__fprintf referenced in function _ShowError
.. And so on

Here's my full makefile:

CC=comp.bat
SRC_SOURCE=*.cpp
SRC_HEADER=*.h
SRC_INC_1=C:\DevLib\SDL_1.2\SDL-1.2.15\include
SRC_INC_2=C:\DevLib\SDL_1.2\SDL_image-1.2.12\include
LIB_PATH_1=C:\DevLib\SDL_1.2\SDL-1.2.15\lib\x86
LIB_PATH_2=C:\DevLib\SDL_1.2\SDL_image-1.2.12\lib\x86
LIB=SDL.lib SDLmain.lib SDL_image.lib

all: $(SRC_SOURCE) $(SRC_HEADER)
	$(CC) $(SRC_SOURCE) /I$(SRC_INC_1) /I$(SRC_INC_2) /EHsc /link SDL.lib SDLmain.lib SDL_image.lib /SUBSYSTEM:CONSOLE /NODEFAULTLIB:msvcrt.lib /LIBPATH:"$(LIB_PATH_1)"

clear: 
	del *.obj
    del *.exe
Edited by Lith
0

Share this post


Link to post
Share on other sites
Microsoft's C++ compiler has a flag that specifies whether to use the static runtime (/MT) or the dynamic runtime (/MD).
 
Issues arrise when different libraries / programs use different versions of the runtime (error messages about conflicting symbols as you saw). There seems to be no "standard" on this so you need to be weary which libraries you use because by default they might use the wrong one.

Since it is probably easier for you to just use whichever runtime SDL uses rather than recompile SDL to match your program we are going to have to add this flag to the Makefile.
 
So again, either before or after the /link flag (I think it is after because it seems to be a linker option, but not 100% sure), you need to add either /MT or /MD depending on what SDL uses.
You should also remove the NODEFAULTLIB:msvcrt.lib flag since it should hopefully be using the same runtime now smile.png Edited by Karsten_
1

Share this post


Link to post
Share on other sites

Microsoft's C++ compiler has a flag that specifies whether to use the static runtime (/MT) or the dynamic runtime (/MD).
 
Issues arrise when different libraries / programs use different versions of the runtime (error messages about conflicting symbols as you saw). There seems to be no "standard" on this so you need to be weary which libraries you use because by default they might use the wrong one.

Since it is probably easier for you to just use whichever runtime SDL uses rather than recompile SDL to match your program we are going to have to add this flag to the Makefile.
 
So again, either before or after the /link flag (I think it is after because it seems to be a linker option, but not 100% sure), you need to add either /MT or /MD depending on what SDL uses.
You should also remove the NODEFAULTLIB:msvcrt.lib flag since it should hopefully be using the same runtime now smile.png

 

It builds! (And runs without any problems first try)

 

Thanks for all your help. I'll try to commit all this to memory to get out of similar situations in the future.

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