Some "Noob" questions from someone who shouldn't be a noob

Started by
6 comments, last by juanpaco 16 years, 11 months ago
Hi, In my past lives, I developed games for a living, and i recently have decided I want to brush up on my C/C++ skills (having lived in an PHP/Perl world for the past few years). I discovered SDL and am enjoying it. I just finished a tetris like game in Linux and with the exception of some fine tuning, its quite playable. So I started to port it to windows. Well I don't have a Windows Dev environment, so I found Dev-C++ which seems to do the trick, but I havef several questions (and I've googled the heck out of them and read a lot of try this messages. My first problem is I get a ton of linker errors, most of them are stdlib/libc type things like printf, read, strchr, etc. Mind you the code compiles file and links fine in Linux. I get no compile errors so its finding the header files fine. In addition to not finding the libc things, its not finding any SDL libs. I have most of them installed (questions on that to follow). Any way, I have the -lmingw32 -lSDLmain -lSDL -lSDL_mixer -lmwindows in my linker options for the project (I've tried them on one line and on seperate lines in the project manager). The project's dev file is set to be a CPP+ program. If I try and build the app like this, I get a zillion linker errors on stuff that it should be finding. I can turn on the "Make an Objective C" option and the mass link errors go away, but I'm left with it not being able to find -lobjc. ( Don't think I want to be building an objective C, since its just a straigth up C/C++ program (some objects, but mostly C'ish stuff). This was a brand new fresh install of Dev-C++ 4.9.9.x (the latest). I also downloaded the SDL and SDL_mixer install packs and Dev-C++ installed them with no problems. So I'm missing somehthing quite obvious, any ideas? Also, How do I get the TTF library and the SDL_image library as devpaks? Thanks Rob
Advertisement
I'm sure you could figure out what's wrong with your setup and get it working, but the latest Dev-C++ build is over 2 years old. It includes Mingw/GCC 3.4.2, but GCC just released 4.2.0. It doesn't look like their site has been updated since 2005. I'm not sure it's worth even trying to get Dev-C++ to work. I'd recommend you look into Visual C++ 2005 Express. It's free, and it's really the official dev environment for Windows. SDL even releases pre-built binaries for Visual C++.
Or Code::Blocks

Beginner in Game Development?  Read here. And read here.

 

You might have downloaded Dev-C++ without mingw, so it can't find it's directories on libraries, includes or binaries. Check the compiler options and see if it's pointing to anything.

BTW, yeah, Dev-C++ is old and stuff... I'm "migrating" to Code::Blocks myself.
Go with Visual C++ Express it much better than Code::Blocks, code blocks has a bunch of lazy developers who only make nightly builds and won't make a solid release just like Dev-C++.
I'm not sure I would characterize anyone who makes nightly builds "Lazy", that seems rather active to me.

But to be fair, I've downloaded both and both are giving me similar but different problems.

VC++ doesn't come with the ability to make non-console win32 apps. You to install a separate template for that. I followed the instructions for that and now it game won't link against any libc routines. I found a flag about using CRT (Common Run Time library I assume, I've done very little windows apps, I did all the Unix backend parts in my past game writing life) and when I toggle it, all the resolutions errors go away, but I'm left with a single error that it can't find another library (that sounds like libc.dll). Unfortunately, as I type this, I'm booted up in Linux, my primary desktop, so I can't get specific errors.

I also installed Code:Blocks and while it seems to work well, its giving me a different set of issues. When I created the project, I selected an SDL project. I cut/pasted my source over top of the existing main.cpp that it created (though I kept a couple of different headers). It instantly started complaining about missing headers including "SDL/SDL.h" so bright me, I point the include directors to where I have the SDL files I downloaded for VC. Great, my compile time dependencies went away, but I was left again with linker errors where it couldn't find the SDL libs. I (and this was probably stupid), pointed the project to the lib folder for all the SDL libs I downloaded for VC++. That cleaned up most of my linker errors except for the TTL library which is still throwing linker errors for all TTF routines that I use. There is one additional SDL call its complaining about as well. (again booted up in Linux so I can't get specifics).

I would have thought that by selecting SDL as the project type it would have handled all the headers and libraries.

Thoughts?

Thanks
Rob
I guess I forgot how far I got with VC. I'm now getting the same TTF linker errors:
MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
robbie1.obj : error LNK2019: unresolved external symbol _TTF_OpenFont referenced in function "struct _TTF_Font * __cdecl LoadFont(char *,char *,int)" (?LoadFont@@YAPAU_TTF_Font@@PAD0H@Z)
robbie1.obj : error LNK2019: unresolved external symbol _IMG_Load referenced in function "struct SDL_Surface * __cdecl load_image(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?load_image@@YAPAUSDL_Surface@@V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z)
robbie1.obj : error LNK2019: unresolved external symbol _TTF_RenderText_Blended referenced in function "void __cdecl show_paused(void)" (?show_paused@@YAXXZ)
robbie1.obj : error LNK2019: unresolved external symbol _TTF_Init referenced in function "bool __cdecl init(void)" (?init@@YA_NXZ)
robbie1.obj : error LNK2019: unresolved external symbol _TTF_FontLineSkip referenced in function "void __cdecl show_high_scores(void)" (?show_high_scores@@YAXXZ)
robbie1.obj : error LNK2019: unresolved external symbol _TTF_Quit referenced in function "void __cdecl clean_up(void)" (?clean_up@@YAXXZ)
robbie1.obj : error LNK2019: unresolved external symbol _TTF_CloseFont referenced in function "void __cdecl clean_up(void)" (?clean_up@@YAXXZ)
C:\Documents and Settings\rwm\My Documents\Visual Studio 2005\Projects\robbie1\Debug\robbie1.exe : fatal error LNK1120: 7 unresolved externals

It looks to me like you're missing the sdl image and ttf libraries. Take a look here*. It has directions for setting up other libraries for use with sdl. It has directions for both visual studio and code::blocks (and even devc++). If this doesn't help, let us know.

Here* = http://lazyfoo.net/SDL_tutorials/lesson03/preview.php

I post links so rarely... I can never remember the little pseudo tag for it. (Would anyone mind posting where that page it that has all the guidelines for things like links and source blocks? Thanks.)

In any case though, that tutorial goes through loading the image libraries for sdl, but the process is basically the same for any other sdl extension.

Hope that helps and happy coding!

This topic is closed to new replies.

Advertisement