Visual Studio 6, C++, SDL

Ok,

I am trying to compile a sdl program at the same time im trying to use
Visual C’s standard c++ libary.

eg.

#include “SDL.h”
#include <iostream.h>

int main(int argc,char **argv)
{
cout << “hello”;
return 0;
}

well to get a sdl program to compile i need to go into project properties and
ignore default properties, link agains msvcrt.lib sdlmain.lib and sdl.lib.
Well when i add the c++ calls it gives me errors like

main.obj : error LNK2001: unresolved external symbol “public: class ostream
& __thiscall ostream::operator<<(char const *)” (??6ostream@@QAEAAV0 at PBD@Z)
main.obj : error LNK2001: unresolved external symbol “class
ostream_withassign cout” (?cout@@3Vostream_withassign@@A)
main.obj : error LNK2001: unresolved external symbol “public: class ostream
& __thiscall ostream::operator<<(unsigned char)” (??6ostream@@QAEAAV0 at E@Z)
main.obj : error LNK2001: unresolved external symbol “public: class ostream
& __thiscall
ostream::flush(void)” (?flush at ostream@@QAEAAV1 at XZ)

Because im not linking agains thoes libaries. Well when i start adding the
c++ libaries
back to the project then i get some conflicting libaries.
like:

LIBCD.lib(crt0dat.obj) : error LNK2005: _exit already defined in
msvcrt.lib(MSVCRT.dll)
LIBCD.lib(crt0dat.obj) : error LNK2005: __exit already defined in
msvcrt.lib(MSVCRT.dll)
LIBCD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in
msvcrt.lib(cinitexe.obj)
LIBCD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in
msvcrt.lib(cinitexe.obj)
LIBCD.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in
msvcrt.lib(cinitexe.obj)
LIBCD.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in
msvcrt.lib(cinitexe.obj)
LIBCD.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in
msvcrt.lib(MSVCRT.dll)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _strncpy already defined in
LIBCD.lib(strncpy.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _fclose already defined in
LIBCD.lib(fclose.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: __isctype already defined in
LIBCD.lib(isctype.obj)

Has anyone ever gotten c++ calls to compile with sdl nicely?

thanks
Brad LaFountain

I am trying to compile a sdl program at the same time im trying
to use Visual C’s standard c++ libary.

Has anyone ever gotten c++ calls to compile with sdl nicely?

I have had no problems. See glelite.sf.net.

#include “SDL.h”
#include <iostream.h>

You should use #include instead, as the .h version
is older and different one.

well to get a sdl program to compile i need to go into project properties and
ignore default properties, link agains msvcrt.lib sdlmain.lib and sdl.lib.

Don’t do that. Check which version of runtime libraries is used in SDL
project and your project, and if they are not the same, make them same,
and recompile both SDL and your program.

LIBCD.lib(crt0dat.obj) : error LNK2005: _exit already defined in
msvcrt.lib(MSVCRT.dll)

This means you have both static and shared runtime libraries, and you
should do as above. You might find detail instructions from mailing list
archives, mail posted by me few weeks ago.

– Timo Suoranta – @Timo_K_Suoranta

Hi,

These errors are common when you have not selected the same Code
Generation settings under your C++ settings (Settings/C++/Code Generation)

Make sure that whatever you used to compile SDL is the same as what you
are compiling your test program with.

Typically you would use: Debug Multi-threaded DLL for debug versions
and Multi-threaded DLL for release builds.

BTW, I took your small sample and compiled and linked it just fine. If
you want a copy of my test project send me an email and I will email it
to you.

  • Ken> ----- Original Message -----

From: sdl-admin@libsdl.org [mailto:sdl-admin at libsdl.org]On Behalf Of
Brad LaFountain
Sent: Monday, July 30, 2001 11:12 AM
To: sdl at libsdl.org
Subject: [SDL] Visual Studio 6, C++, SDL

Ok,

I am trying to compile a sdl program at the same time im trying to use
Visual C’s standard c++ libary.

eg.

#include “SDL.h”
#include <iostream.h>

int main(int argc,char **argv)
{
cout << “hello”;
return 0;
}

well to get a sdl program to compile i need to go into project properties
and
ignore default properties, link agains msvcrt.lib sdlmain.lib and sdl.lib.
Well when i add the c++ calls it gives me errors like

main.obj : error LNK2001: unresolved external symbol “public: class ostream
& __thiscall ostream::operator<<(char const *)” (??6ostream@@QAEAAV0 at PBD@Z)
main.obj : error LNK2001: unresolved external symbol “class
ostream_withassign cout” (?cout@@3Vostream_withassign@@A)
main.obj : error LNK2001: unresolved external symbol “public: class ostream
& __thiscall ostream::operator<<(unsigned char)” (??6ostream@@QAEAAV0 at E@Z)
main.obj : error LNK2001: unresolved external symbol “public: class ostream
& __thiscall
ostream::flush(void)” (?flush at ostream@@QAEAAV1 at XZ)

Because im not linking agains thoes libaries. Well when i start adding the
c++ libaries
back to the project then i get some conflicting libaries.
like:

LIBCD.lib(crt0dat.obj) : error LNK2005: _exit already defined in
msvcrt.lib(MSVCRT.dll)
LIBCD.lib(crt0dat.obj) : error LNK2005: __exit already defined in
msvcrt.lib(MSVCRT.dll)
LIBCD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in
msvcrt.lib(cinitexe.obj)
LIBCD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in
msvcrt.lib(cinitexe.obj)
LIBCD.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in
msvcrt.lib(cinitexe.obj)
LIBCD.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in
msvcrt.lib(cinitexe.obj)
LIBCD.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in
msvcrt.lib(MSVCRT.dll)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _strncpy already defined in
LIBCD.lib(strncpy.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _fclose already defined in
LIBCD.lib(fclose.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: __isctype already defined in
LIBCD.lib(isctype.obj)

Has anyone ever gotten c++ calls to compile with sdl nicely?

thanks
Brad LaFountain


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hi Sam,

I want to make a request for a change to the VC++ DSP files.

Can you modify the projects to build different DLL’s for
debug versions of SDL? What I do is change it to build

SDL-dbg.dll SDL-dbg.lib SDLmain-dbg.lib

The benefit is that I can have a project that uses SDL and if
I am building the Debug version of my app I can just link with
SDL-dbg.lib. The release version links with SDL.lib. The
saves me from having to rebuild SDL if I want to switch between
debug and release builds.

I also added a post-build step to copy the files to the SDL\lib
folder.

The Post-Build commands for copying the files are:

(For SDL)
copy $(OutDir)*.lib …\Lib
copy $(OutDir)*.dll …\Lib

(For SDLmain)
copy $(OutDir)*.lib …\Lib

Let me know what you think about these minor changes.

I am trying to compile a sdl program at the same time im trying to use
Visual C’s standard c++ libary.

#include “SDL.h”
#include <iostream.h>

int main(int argc,char **argv)
{
cout << “hello”;
return 0;
}

And you need to use namespace

#include “SDL.h”
#include

using namespace std;

int main(int argc,char **argv) {
cout << “hello”;
return 0;
}

// or

#include “SDL.h”
#include

int main(int argc,char **argv) {
std::cout << “hello”;
return 0;
}

That’s not a bad idea - I’ve been doing this all along in my copy of the
project, except I produce ‘dSDL.lib’, ‘dSDL_main.lib’, and ‘dSDL.dll’.

-Jesse> ----- Original Message -----

From: ken@homebrewsoftware.com (Ken Rogoway)
To:
Sent: Monday, July 30, 2001 12:21 PM
Subject: [SDL] Visual Studio project file change request

Hi Sam,

I want to make a request for a change to the VC++ DSP files.

Can you modify the projects to build different DLL’s for
debug versions of SDL? What I do is change it to build

SDL-dbg.dll SDL-dbg.lib SDLmain-dbg.lib

The benefit is that I can have a project that uses SDL and if
I am building the Debug version of my app I can just link with
SDL-dbg.lib. The release version links with SDL.lib. The
saves me from having to rebuild SDL if I want to switch between
debug and release builds.

I also added a post-build step to copy the files to the SDL\lib
folder.

The Post-Build commands for copying the files are:

(For SDL)
copy $(OutDir)*.lib …\Lib
copy $(OutDir)*.dll …\Lib

(For SDLmain)
copy $(OutDir)*.lib …\Lib

Let me know what you think about these minor changes.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

At 09:29 PM 7/30/2001 +0200, you wrote:

I am trying to compile a sdl program at the same time im trying to use
Visual C’s standard c++ libary.

#include “SDL.h”
#include <iostream.h>

int main(int argc,char **argv)
{
cout << “hello”;
return 0;
}

And you need to use namespace

#include “SDL.h”
#include

using namespace std;

int main(int argc,char **argv) {
cout << “hello”;
return 0;
}

// or

#include “SDL.h”
#include

int main(int argc,char **argv) {
std::cout << “hello”;
return 0;
}

Just to clearify i do understand the difference between

and
<iostream.h>

and also I do understand what namespaces are.

I did have the wrong type of runtime libary.
I changed this and it worked fine.

thanks>_______________________________________________

SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

SDL-dbg.dll SDL-dbg.lib SDLmain-dbg.lib

We use “_d”, e.g. "sdl_d.dll"
I’ve seen other libraries come configured that way (Python I think), so
there’s some precedent for it. Anyway, it’s less wordy :slight_smile:

–Manny

Hi,

doesn’t really matter what is used, just the technique of having
them separate. Whatever Sam or the SDL group thinks is the best
name will work fine for me :slight_smile:

From: sdl-admin@libsdl.org [mailto:sdl-admin at libsdl.org]On Behalf Of
Manny
Sent: Monday, July 30, 2001 4:09 PM
To: sdl at libsdl.org
Subject: Re: [SDL] Visual Studio project file change request

SDL-dbg.dll SDL-dbg.lib SDLmain-dbg.lib

We use “_d”, e.g. "sdl_d.dll"
I’ve seen other libraries come configured that way (Python I think), so
there’s some precedent for it. Anyway, it’s less wordy :slight_smile:

–Manny


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I second this motion.

(Although I have always used a ‘d’ after the name. ie ‘SDLd.lib’,
‘SDL_maind.lib’, and ‘SDLd.dll’.)

Evil wrote:>

That’s not a bad idea - I’ve been doing this all along in my copy of the
project, except I produce ‘dSDL.lib’, ‘dSDL_main.lib’, and ‘dSDL.dll’.

-Jesse

----- Original Message -----
From: “Ken Rogoway”
To:
Sent: Monday, July 30, 2001 12:21 PM
Subject: [SDL] Visual Studio project file change request

Hi Sam,

I want to make a request for a change to the VC++ DSP files.

Can you modify the projects to build different DLL’s for
debug versions of SDL? What I do is change it to build

SDL-dbg.dll SDL-dbg.lib SDLmain-dbg.lib

The benefit is that I can have a project that uses SDL and if
I am building the Debug version of my app I can just link with
SDL-dbg.lib. The release version links with SDL.lib. The
saves me from having to rebuild SDL if I want to switch between
debug and release builds.

I also added a post-build step to copy the files to the SDL\lib
folder.

The Post-Build commands for copying the files are:

(For SDL)
copy $(OutDir)*.lib …\Lib
copy $(OutDir)*.dll …\Lib

(For SDLmain)
copy $(OutDir)*.lib …\Lib

Let me know what you think about these minor changes.


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

I second this motion.

(Although I have always used a ‘d’ after the name. ie ‘SDLd.lib’,
‘SDL_maind.lib’, and ‘SDLd.dll’.)

me too! me too!

I mean, seriously, this is the only way to switch easily between debug &
release builds on a development platform where release binaries can’t simply
be ‘stripped’ from their debug buddies…

hello,

I have a similar problem under vc6…

I start a workspace, then a project, I add the SDL lib files as described in
the mini how to… but vc tells me to check "ignoe default libraries"
in project settings while I compile… but then, the linker shows errors
that only disappear when I add msvcrt.lib to the project files.

I am using pure C (aka .c files extension… perhaps vc makes any difference)

any ideas ??

thanks.> -----Message d’origine-----

De : sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org]De la part de
Brad LaFountain
Envoye : lundi 30 juillet 2001 17:12
A : sdl at libsdl.org
Objet : [SDL] Visual Studio 6, C++, SDL

Ok,

I am trying to compile a sdl program at the same time im trying to use
Visual C’s standard c++ libary.

eg.

#include “SDL.h”
#include <iostream.h>

int main(int argc,char **argv)
{
cout << “hello”;
return 0;
}

well to get a sdl program to compile i need to go into project
properties and
ignore default properties, link agains msvcrt.lib sdlmain.lib and sdl.lib.
Well when i add the c++ calls it gives me errors like

main.obj : error LNK2001: unresolved external symbol “public:
class ostream
& __thiscall ostream::operator<<(char const *)”
(??6ostream@@QAEAAV0 at PBD@Z)
main.obj : error LNK2001: unresolved external symbol “class
ostream_withassign cout” (?cout@@3Vostream_withassign@@A)
main.obj : error LNK2001: unresolved external symbol “public:
class ostream
& __thiscall ostream::operator<<(unsigned char)” (??6ostream@@QAEAAV0 at E@Z)
main.obj : error LNK2001: unresolved external symbol “public:
class ostream
& __thiscall
ostream::flush(void)” (?flush at ostream@@QAEAAV1 at XZ)

Because im not linking agains thoes libaries. Well when i start
adding the
c++ libaries
back to the project then i get some conflicting libaries.
like:

LIBCD.lib(crt0dat.obj) : error LNK2005: _exit already defined in
msvcrt.lib(MSVCRT.dll)
LIBCD.lib(crt0dat.obj) : error LNK2005: __exit already defined in
msvcrt.lib(MSVCRT.dll)
LIBCD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in
msvcrt.lib(cinitexe.obj)
LIBCD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in
msvcrt.lib(cinitexe.obj)
LIBCD.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in
msvcrt.lib(cinitexe.obj)
LIBCD.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in
msvcrt.lib(cinitexe.obj)
LIBCD.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in
msvcrt.lib(MSVCRT.dll)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _strncpy already defined in
LIBCD.lib(strncpy.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _fclose already defined in
LIBCD.lib(fclose.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: __isctype already defined in
LIBCD.lib(isctype.obj)

Has anyone ever gotten c++ calls to compile with sdl nicely?

thanks
Brad LaFountain


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

You are creating a Win32 application, aren’t you? Don’t select MFC or
anything else. Then add the 2 .LIB files to the project (right click on the
project pane and select “Add file to project”), alter the include path to
point to where the SDL.h header is located and you should have no problems!

Neil.> ----- Original Message -----

From: damienmascre@free.fr (Damien Mascre)
To:
Sent: Wednesday, August 01, 2001 10:03 PM
Subject: RE: [SDL] Visual Studio 6, C++, SDL

hello,

I have a similar problem under vc6…

I start a workspace, then a project, I add the SDL lib files as described
in
the mini how to… but vc tells me to check "ignoe default libraries"
in project settings while I compile… but then, the linker shows errors
that only disappear when I add msvcrt.lib to the project files.

I am using pure C (aka .c files extension… perhaps vc makes any
difference)

any ideas ??

thanks.

-----Message d’origine-----
De : sdl-admin at libsdl.org [mailto:sdl-admin at libsdl.org]De la part de
Brad LaFountain
Envoye : lundi 30 juillet 2001 17:12
A : sdl at libsdl.org
Objet : [SDL] Visual Studio 6, C++, SDL

Ok,

I am trying to compile a sdl program at the same time im trying to use
Visual C’s standard c++ libary.

eg.

#include “SDL.h”
#include <iostream.h>

int main(int argc,char **argv)
{
cout << “hello”;
return 0;
}

well to get a sdl program to compile i need to go into project
properties and
ignore default properties, link agains msvcrt.lib sdlmain.lib and
sdl.lib.

Well when i add the c++ calls it gives me errors like

main.obj : error LNK2001: unresolved external symbol “public:
class ostream
& __thiscall ostream::operator<<(char const *)”
(??6ostream@@QAEAAV0 at PBD@Z)
main.obj : error LNK2001: unresolved external symbol “class
ostream_withassign cout” (?cout@@3Vostream_withassign@@A)
main.obj : error LNK2001: unresolved external symbol “public:
class ostream
& __thiscall ostream::operator<<(unsigned char)”
(??6ostream@@QAEAAV0 at E@Z)

main.obj : error LNK2001: unresolved external symbol “public:
class ostream
& __thiscall
ostream::flush(void)” (?flush at ostream@@QAEAAV1 at XZ)

Because im not linking agains thoes libaries. Well when i start
adding the
c++ libaries
back to the project then i get some conflicting libaries.
like:

LIBCD.lib(crt0dat.obj) : error LNK2005: _exit already defined in
msvcrt.lib(MSVCRT.dll)
LIBCD.lib(crt0dat.obj) : error LNK2005: __exit already defined in
msvcrt.lib(MSVCRT.dll)
LIBCD.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in
msvcrt.lib(cinitexe.obj)
LIBCD.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in
msvcrt.lib(cinitexe.obj)
LIBCD.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in
msvcrt.lib(cinitexe.obj)
LIBCD.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in
msvcrt.lib(cinitexe.obj)
LIBCD.lib(winxfltr.obj) : error LNK2005: __XcptFilter already defined in
msvcrt.lib(MSVCRT.dll)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _strncpy already defined in
LIBCD.lib(strncpy.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: _fclose already defined in
LIBCD.lib(fclose.obj)
msvcrt.lib(MSVCRT.dll) : error LNK2005: __isctype already defined in
LIBCD.lib(isctype.obj)

Has anyone ever gotten c++ calls to compile with sdl nicely?

thanks
Brad LaFountain


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Damien Mascre wrote:
hum… je ne suis pas sur de bien comprendre…
mais ceci dit msvcr.dll est indispensable des que l’on fait appel a la
moindre fonction externe, malloc ? free ? printf ? …

ce n’est pas une libraireie c++ mais une librairie standart sous
windows…

Brad LaFountain wrote:

Brad (or indeed anyone who happens to be listening!),

I have exactly the same problem on Linux. If I compile a standard SDL app
using KDevelop and a “C program” everything works fine. When I move to a
C++ program I get the same errors as you did (although they display
different text!).

Could you just clarify exactly which solution fixed it and I will try and
replicate this on Linux.

To clarify the position,

I have tried

<iostream.h> and cout <<
and using namespace std;
and std::cout

None of them have fixed it. If I remove the -lSDL and comment out the SDL
references everything compiles fine - but that sort of defeats the object!

Thanks in advance for any help, but I have just resigned myself to another
head banging night for a VERY simple port from C to C++…

Mike> At 09:29 PM 7/30/2001 +0200, you wrote:

I am trying to compile a sdl program at the same time im trying to use
Visual C’s standard c++ libary.

#include “SDL.h”
#include <iostream.h>

int main(int argc,char **argv)
{
cout << “hello”;
return 0;
}

And you need to use namespace

#include “SDL.h”
#include

using namespace std;

int main(int argc,char **argv) {
cout << “hello”;
return 0;
}

// or

#include “SDL.h”
#include

int main(int argc,char **argv) {
std::cout << “hello”;
return 0;
}

Just to clearify i do understand the difference between

and
<iostream.h>

and also I do understand what namespaces are.

I did have the wrong type of runtime libary.
I changed this and it worked fine.

thanks


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Its OK,

I was banging my head against the wall all night, but eventually was
inspired to look through the /usr/lib/*.so files for something that had the
symbol F97ostream or some such… can’t quite remember what exactly.

When I found one with this symbol I looked at what the library was linked
to and looked for anything I wasn’t linking to…

turned out to be /usr/lib/libstdc+±libc6.2-2.so.3

Still can’t claim to fully understand it, but I found it and it now work…

Cheers

Mike Arnold wrote:> Brad LaFountain wrote:

Brad (or indeed anyone who happens to be listening!),

I have exactly the same problem on Linux. If I compile a standard SDL app
using KDevelop and a “C program” everything works fine. When I move to a
C++ program I get the same errors as you did (although they display
different text!).

Could you just clarify exactly which solution fixed it and I will try and
replicate this on Linux.

To clarify the position,

I have tried

<iostream.h> and cout <<
and using namespace std;
and std::cout

None of them have fixed it. If I remove the -lSDL and comment out the SDL
references everything compiles fine - but that sort of defeats the object!

Thanks in advance for any help, but I have just resigned myself to another
head banging night for a VERY simple port from C to C++…

Mike