Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Compatibility to other computers  (Read 16401 times)

0 Members and 1 Guest are viewing this topic.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Compatibility to other computers
« on: April 14, 2008, 06:57:29 pm »
Hi,
First of all, I have used SFML since some weeks, for my current graphic requests it's perfect! At the moment I am creating a little 2D Space Shooter ;)

There is just one matter worrying me: I don't know how to make SFML applications compatible so that they work on other computers (where Visual C++ Express 2008 which I use isn't installed). I always get the error http://www.sfml-dev.org/forum/viewtopic.php?t=216&postdays=0&postorder=asc&highlight=lnk2005&start=15 . But on this computer, there is no problem if I choose the right configuration.

The problem is, I would like to link statically, because static apps without SFML work on other computers. So the CRT itsself is compatible in static (release) configuration. But as soon as I use any SFML stuff, I get loads of linking errors trying to link statically. Recompiling the libs didn't improve the situation. And in dynamic configuration, I don't know how to handle it with the DLLs and I think, spending a whole day searching the internet for solutions is enough...

Is it true that SFML applications in VC++ cannot be built statically? This would make it a lot easier, because if I link dynamically, I would have to install DLLs on every computer into SxS directories and so on...
Or am I just doing wrong all the time? Is there a possibility?

I just can't imagine everyone using SFML on other computers is doing all that Side by Side setup configuration stuff while it might be much easier?
How do you configure your apps if you want to use them on other computers (without any additional SDKs and compilers)?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Avency

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Compatibility to other computers
« Reply #1 on: April 14, 2008, 09:29:24 pm »
Make sure that the target computer has the visualc++ 2008 redistributables installed (which I assume is the case if other apps run) and you don't redistribute an apllication containing debug information. Also make sure that you link with the correct libs (non-debug, static, in recent svn-versions marked with a -s suffix).
Static linking definitely works on vc++, I just compiled an application 2 days ago using TeamSuite 2008 which has been run successfully on a pc without VisualStudio intalled.

Here is a guide what I did:

1. Pull down the latest sources from svn

2. Open the SFML.sln in the vc2008 dir

3. Select Release

4. Rigth-click the solution and select recreate all (or something similar)

5. You will now find the libs in sfmldir/lib/vc2008

6. Create a new project and select win32 application, disable the option to use precompiled headers

6. Go to the release configuration and add the sfml-include directory to the c++ options and the sfml-lib directory to the linker settings.

7. Then add the required libs to the linker settings (for example sfml-graphics-s.lib)

8. Now add your source files to the project

9. Select release mode and compile

10. Hopefully you now have a working executable (it worked for me)

If you need more specific information where to find the settings, I can look it up as soon as I get back to a computer with VisualStudio.
If this doesn't work you can still try to add the required sfml-source files to you project directly (you will still have to configure the external libs like freetype, so this probably won't simplfy things).
Looking at the msdn docs could help too, I think they have a chapter about reditributing applications.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Compatibility to other computers
« Reply #2 on: April 14, 2008, 11:11:22 pm »
Sorry if I behave like a noob, but I already fail your first step (I've never done this). The other steps shouldn't be a problem, but without source I can't really do anything ;)
Is there a possibility to download all actual files from SVN? I don't like downloading every single file for itsself. And while trying to download missing files, I get lot of warnings during compile of SFML.sln.
Why doesn't the full SDK (SFML 1.2) work? Because if I try your steps with full SDK (what I already tried in past), the following linker errors  (just a small part) occur:
Code: [Select]
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) is already defined in Main.obj.
What do I have to download exactely? Is it really necessary to get files from SVN? What about the full SDK?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

dunce

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
Compatibility to other computers
« Reply #3 on: April 15, 2008, 04:59:58 am »
Quote
Is there a possibility to download all actual files from SVN?

1. Download an SVN client. TortoiseSVN is the most popular and free: http://tortoisesvn.net/downloads
2. Install it. While installing it integrates into the shell, and you may activate it with right-clicking on the folder you choose for downloading SVN sources
3. Create a folder for SFML SVN source
4. Right-click on it, then click on SVN Checkout and input the following URL of repository: http://sfml.svn.sourceforge.net/svnroot/sfml
5. Press OK button.

Avency

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Compatibility to other computers
« Reply #4 on: April 15, 2008, 06:17:45 pm »
Like dunce said, use TortoiseSVN or Subclipse (Eclipse plugin) (or even the command line).
More information on subversion:
http://subversion.tigris.org/

If you use the command line
Code: [Select]
svn co https://sfml.svn.sourceforge.net/svnroot/sfml sfml
should do the job.

The 1.2 SDK should work, too. You are probably missing the Windows SDK which doesn't come with the Express editions.
You can find it somewhere in the depths of Microsofts download center.
There are lots of resources on how to configure it for use with the Express edition.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Compatibility to other computers
« Reply #5 on: April 18, 2008, 10:42:56 pm »
Thank you for the quick guide how to use SVN. I just downloaded the newest source.

Unfortunately, it still doesn't work :(
As soon as I use any SFML Commands, I get those linker errors again. I am told there are some multiply defined external symbols.
I actually use the SFML libs sfml-graphics-s.lib, sfml-window-s.lib and sfml-system-s.lib (this order) which i rebuilt just before (I recompiled SFML.sln in Static Release Configuration).

Then, I read this post http://www.sfml-dev.org/forum/viewtopic.php?t=244 and followed the instructions described there. I downloaded Microsoft SDK and added its directories to VC++. There is no result at all, still my 21 lovely linker errors :?
Rebuilding SFML.sln several times in every possible configuration seems to be useless, too... I have no idea what to do, MSDN doesn't really help either...

Here is the full list of linker errors, I tried to ignore some of the CRT libraries, but without sucess...
Code: [Select]
1>------ Build started: Project: TestProjekt, Configuration: Release Win32 ------
1>Linking...
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@ABV01@@Z) is already defined in libcpmt.lib(string.obj).
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::~basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(void)" (??1?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@XZ) is already defined in Main.obj.
1>msvcprt.lib(MSVCP90.dll) : error LNK2005: "public: __thiscall std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >(char const *)" (??0?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@QAE@PBD@Z) is already defined in Main.obj.
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: "public: __thiscall std::exception::exception(char const * const &)" (??0exception@std@@QAE@ABQBD@Z) is already defined in LIBCMT.lib(stdexcpt.obj).
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: "public: virtual __thiscall std::exception::~exception(void)" (??1exception@std@@UAE@XZ) is already defined in LIBCMT.lib(stdexcpt.obj).
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: "public: __thiscall std::exception::exception(void)" (??0exception@std@@QAE@XZ) is already defined in LIBCMT.lib(stdexcpt.obj).
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: "public: __thiscall std::exception::exception(class std::exception const &)" (??0exception@std@@QAE@ABV01@@Z) is already defined in LIBCMT.lib(stdexcpt.obj).
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: __invalid_parameter_noinfo is already defined in LIBCMT.lib(invarg.obj).
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _free is already defined in LIBCMT.lib(free.obj).
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _exit is already defined in LIBCMT.lib(crt0dat.obj).
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _abort is already defined in LIBCMT.lib(abort.obj).
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _malloc is already defined in LIBCMT.lib(malloc.obj).
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _realloc is already defined in LIBCMT.lib(realloc.obj).
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _ldexp is already defined in LIBCMT.lib(_ldexp_.obj).
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _strtol is already defined in LIBCMT.lib(strtol.obj).
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _strncmp is already defined in LIBCMT.lib(strncmp.obj).
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _getenv is already defined in LIBCMT.lib(getenv.obj).
1>MSVCRT.lib(MSVCR90.dll) : error LNK2005: _memmove_s is already defined in LIBCMT.lib(memmove_s.obj).
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) is already defined in LIBCMT.lib(typinfo.obj).
1>MSVCRT.lib(ti_inst.obj) : error LNK2005: "private: class type_info & __thiscall type_info::operator=(class type_info const &)" (??4type_info@@AAEAAV0@ABV0@@Z) is already defined in LIBCMT.lib(typinfo.obj).
1>LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library
      (translated error report)
Are there any CRT libraries I have to ignore in my projects? If yes, what are their names? I tried to exclude some libraries not matching /MT configuration (described in MSDN), the consequence are other errors...
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

workmad3

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
Compatibility to other computers
« Reply #6 on: April 18, 2008, 10:53:32 pm »
you shouldn't need to ignore any CRT libs, but you will need to link against the multithreaded dll rather than the static CRT. This in turn means that you will need to provide the VC2008 redistributable with your app so that people without visual c++ 2008 can use it.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Compatibility to other computers
« Reply #7 on: April 18, 2008, 11:37:51 pm »
Quote from: "workmad3"
but you will need to link against the multithreaded dll rather than the static CRT
No, you won't ;) - I just succeeded linking statically.

Thanks for your help, I could now compile my project...
My fault was: I always created empty applications and therefore didn't include stdafx.h and used main() instead of _tmain(..).

But even after linking statically, my apps don't work on other systems.
Is it really required to add the redistributable to make SFML programs run on computers without VC++? I don't want to force every user of my programs to install all those things, especially I am probably not allowed to do this on every computer (e.g. school computers). Besides, I like compact executions without loads of dlls and other dependencies, even if the exe size grows by doing this. I thought by linking statically I could include all required stuff into the exe file so that it works everywhere, but this doesn't seem to be right. Even if there were some DLLs in the same  directory like the .exe-file, it wouldn't be a problem, but I wanted to avoid setups and moving DLLs into system directories. Is this possible?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Julien_v42

  • Newbie
  • *
  • Posts: 26
    • View Profile
    • http://tinyrpgsim.wordpress.com
Compatibility to other computers
« Reply #8 on: April 19, 2008, 01:26:05 pm »
If the other computers gets strange errors complaining about wrong side by side configuration or the like, it means you provided a Debug .exe without the debug version of VC runtime. Giving a Release .exe should solve this issue (as msvcrt.dll is probably installed on the target computer).

For the link issue, I'm ignoring libcmt.lib in all my SFML projects now. Not sure if it's a good idea or not, but this way I don't get error messages.

I've also had a strange issue where my project is compiling fine on my XP PC with Visual C++ 2005 Express and not on my Vista laptop with same Visual, found out I had to add gdi32.lib and user32.lib to the linker files.
Working on TinyRPGSim

Avency

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Compatibility to other computers
« Reply #9 on: April 19, 2008, 03:11:02 pm »
As said above, static linking works just fine (the executables even run on Linux using WINE).
All you need to do is to provide the VC2008 redistribuables.
You can find more information here:
http://msdn2.microsoft.com/en-us/library/ms235299.aspx

You also might want to read this page (it's for the 2005 version, but it could help):
http://msdn2.microsoft.com/en-us/express/aa700755.aspx

There is no need for the stdafx and _tmain().
Just create a Win32 application and disable the option to use precompiled headers.
Then create a new source file with the main() function in it, it should work.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Compatibility to other computers
« Reply #10 on: April 19, 2008, 04:37:58 pm »
Yeah, it worked! Thanks for this great help! :)

But strangely I succeeded in DLL configuration... I just added the following files into my application directory: Microsoft.VC90.CRT.manifest, msvcm90.dll, msvcp90.dll, msvcr90.dll. Like this I don't have to download any redistributables which is what I aimed at ;)

But there is something odd with these things.. Now I am not even sure anymore if this was static linking I succeeded before (which I said three posts above), because now I can't manage it (got linker errors again) :?
Besides, I think I already tried DLL linking before, but without success... Maybe I was just too tired when I tried this :)
Or am I just incapable of linking statically? I think I followed every of your steps, Avency, and this should work on computers with VC++ installed without the redistributable, shouldn't it? At the moment I am happy with DLL mode, but I'd nevertheless be interested in static link ;)
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Avency

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Compatibility to other computers
« Reply #11 on: April 19, 2008, 06:17:16 pm »
Make sure that
Code: [Select]
Configuration Properties/C/C++/Code Generation/Runtime
is set to Multithreaded-DLL (/MD).
Mixing /MD (sfml) and /MT is known to cause problems.

Quote
All modules passed to a given invocation of the linker must have been compiled with the same run-time library compiler option
(taken from msdn)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Compatibility to other computers
« Reply #12 on: April 19, 2008, 07:49:59 pm »
Ok this is what I did (that was the only way my apps worked).

I thought by setting configuration to /MD (Multithreaded DLL) I would link dynamically... So what does "linking statically" mean? Does it only refer to SFML and not to CRT? So static CRT link is not possible while using SFML, is it?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

Avency

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Compatibility to other computers
« Reply #13 on: April 20, 2008, 02:13:40 pm »
This setting is related to the VC runtime only.
Static linking means that you include the library in your executable, dynamic linking uses an external shared library (.dll on windows, for example sfml-graphics.dll).
You could try to rebuild sfml with /MT, but I'm not sure if this is really a good idea.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Compatibility to other computers
« Reply #14 on: April 20, 2008, 04:36:33 pm »
Ok thanks a lot. So there are rather few people linking SFML with /MT. But why are there so many possible configurations in SFML.sln? If static mode is no good idea, or doesn't work at all, why can we choose it? Or is it only designed for some rare special cases?
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development: