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

How to use FreeImage as static library in VC 2010?

8 posts in this topic

The FreeImage source download has VC 2008 project files included. I convert them to VC 2010 and then build the FreeImageLib project. It builds fine but when I try to link to it I get the following errors:


[CODE]

2>msvcprt.lib(MSVCP100.dll) : error LNK2005: "public: void __thiscall std::_Container_base0::_Orphan_all(void)" (?_Orphan_all@_Container_base0@std@@QAEXXZ) already defined in FreeImage.lib(PluginGIF.obj)
2>msvcprt.lib(MSVCP100.dll) : error LNK2005: "public: class std::locale::facet * __thiscall std::locale::facet::_Decref(void)" (?_Decref@facet@locale@std@@QAEPAV123@XZ) already defined in FreeImage.lib(PluginEXR.obj)
2>libcpmt.lib(locale0.obj) : error LNK2005: "private: static void __cdecl std::locale::facet::_Facet_Register(class std::locale::facet *)" (?_Facet_Register@facet@locale@std@@CAXPAV123@@Z) already defined in msvcprt.lib(locale0_implib.obj)
2>libcpmt.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Getgloballocale(void)" (?_Getgloballocale@locale@std@@CAPAV_Locimp@12@XZ) already defined in msvcprt.lib(MSVCP100.dll)
2>libcpmt.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_dtor(class std::_Locinfo *)" (?_Locinfo_dtor@_Locinfo@std@@SAXPAV12@@Z) already defined in msvcprt.lib(MSVCP100.dll)
2>libcpmt.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_ctor(class std::_Locinfo *,char const *)" (?_Locinfo_ctor@_Locinfo@std@@SAXPAV12@PBD@Z) already defined in msvcprt.lib(MSVCP100.dll)
2>libcpmt.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Init(void)" (?_Init@locale@std@@CAPAV_Locimp@12@XZ) already defined in msvcprt.lib(MSVCP100.dll)
2>libcpmt.lib(ios.obj) : error LNK2005: "public: static void __cdecl std::ios_base::_Addstd(class std::ios_base *)" (?_Addstd@ios_base@std@@SAXPAV12@@Z) already defined in msvcprt.lib(MSVCP100.dll)
2>libcpmt.lib(ios.obj) : error LNK2005: "private: static void __cdecl std::ios_base::_Ios_base_dtor(class std::ios_base *)" (?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z) already defined in msvcprt.lib(MSVCP100.dll)
2>libcpmt.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in msvcprt.lib(MSVCP100.dll)
2>libcpmt.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in msvcprt.lib(MSVCP100.dll)
2>LIBCMT.lib(tidtable.obj) : error LNK2005: __encoded_null already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(tolower.obj) : error LNK2005: _tolower already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(dosmap.obj) : error LNK2005: __errno already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(lseeki64.obj) : error LNK2005: __lseeki64 already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(lconv.obj) : error LNK2005: _localeconv already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(crtheap.obj) : error LNK2005: __malloc_crt already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(mlock.obj) : error LNK2005: __unlock already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(mlock.obj) : error LNK2005: __lock already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(winxfltr.obj) : error LNK2005: ___CppXcptFilter already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRT.lib(cinitexe.obj)
2>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRT.lib(cinitexe.obj)
2>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRT.lib(cinitexe.obj)
2>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRT.lib(cinitexe.obj)
2>LIBCMT.lib(atox.obj) : error LNK2005: _atoi already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(strtol.obj) : error LNK2005: _strtol already defined in MSVCRT.lib(MSVCR100.dll)
2> libogg_static.lib(framing.obj) : MSIL .netmodule or module compiled with /GL found; restarting link with /LTCG; add /LTCG to the link command line to improve linker performance
2>msvcprt.lib(MSVCP100.dll) : error LNK2005: "public: void __thiscall std::_Container_base0::_Orphan_all(void)" (?_Orphan_all@_Container_base0@std@@QAEXXZ) already defined in FreeImage.lib(PluginGIF.obj)
2>msvcprt.lib(MSVCP100.dll) : error LNK2005: "public: class std::locale::facet * __thiscall std::locale::facet::_Decref(void)" (?_Decref@facet@locale@std@@QAEPAV123@XZ) already defined in FreeImage.lib(PluginEXR.obj)
2>libcpmt.lib(locale0.obj) : error LNK2005: "private: static void __cdecl std::locale::facet::_Facet_Register(class std::locale::facet *)" (?_Facet_Register@facet@locale@std@@CAXPAV123@@Z) already defined in msvcprt.lib(locale0_implib.obj)
2>libcpmt.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Getgloballocale(void)" (?_Getgloballocale@locale@std@@CAPAV_Locimp@12@XZ) already defined in msvcprt.lib(MSVCP100.dll)
2>libcpmt.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_dtor(class std::_Locinfo *)" (?_Locinfo_dtor@_Locinfo@std@@SAXPAV12@@Z) already defined in msvcprt.lib(MSVCP100.dll)
2>libcpmt.lib(locale0.obj) : error LNK2005: "public: static void __cdecl std::_Locinfo::_Locinfo_ctor(class std::_Locinfo *,char const *)" (?_Locinfo_ctor@_Locinfo@std@@SAXPAV12@PBD@Z) already defined in msvcprt.lib(MSVCP100.dll)
2>libcpmt.lib(locale0.obj) : error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Init(void)" (?_Init@locale@std@@CAPAV_Locimp@12@XZ) already defined in msvcprt.lib(MSVCP100.dll)
2>libcpmt.lib(ios.obj) : error LNK2005: "public: static void __cdecl std::ios_base::_Addstd(class std::ios_base *)" (?_Addstd@ios_base@std@@SAXPAV12@@Z) already defined in msvcprt.lib(MSVCP100.dll)
2>libcpmt.lib(ios.obj) : error LNK2005: "private: static void __cdecl std::ios_base::_Ios_base_dtor(class std::ios_base *)" (?_Ios_base_dtor@ios_base@std@@CAXPAV12@@Z) already defined in msvcprt.lib(MSVCP100.dll)
2>libcpmt.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z) already defined in msvcprt.lib(MSVCP100.dll)
2>libcpmt.lib(xlock.obj) : error LNK2005: "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ) already defined in msvcprt.lib(MSVCP100.dll)
2>LIBCMT.lib(tidtable.obj) : error LNK2005: __encoded_null already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(tolower.obj) : error LNK2005: _tolower already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(dosmap.obj) : error LNK2005: __errno already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(lseeki64.obj) : error LNK2005: __lseeki64 already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(crt0dat.obj) : error LNK2005: __initterm_e already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(crt0dat.obj) : error LNK2005: __amsg_exit already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(lconv.obj) : error LNK2005: _localeconv already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(crtheap.obj) : error LNK2005: __malloc_crt already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(mlock.obj) : error LNK2005: __unlock already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(mlock.obj) : error LNK2005: __lock already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(winxfltr.obj) : error LNK2005: ___CppXcptFilter already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(hooks.obj) : error LNK2005: "void __cdecl terminate(void)" (?terminate@@YAXXZ) already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_a already defined in MSVCRT.lib(cinitexe.obj)
2>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xi_z already defined in MSVCRT.lib(cinitexe.obj)
2>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_a already defined in MSVCRT.lib(cinitexe.obj)
2>LIBCMT.lib(crt0init.obj) : error LNK2005: ___xc_z already defined in MSVCRT.lib(cinitexe.obj)
2>LIBCMT.lib(atox.obj) : error LNK2005: _atoi already defined in MSVCRT.lib(MSVCR100.dll)
2>LIBCMT.lib(strtol.obj) : error LNK2005: _strtol already defined in MSVCRT.lib(MSVCR100.dll)
2> Creating library
2>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
2>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
2>LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
[/CODE]


From [url="http://stackoverflow.com/questions/7824859/how-static-link-freeimage-library"]this[/url] post on stack overflow I would assume the problem is with using the VC 2008 project files but I don't know why? Any ideas what I'm doing wrong? Edited by EnigmaticProgrammer
0

Share this post


Link to post
Share on other sites
I ran into that as well, but can't remember the details. Are you mixing CRT versions? I think this came up when I rebuilt FreeImage but didn't rebuild all its dependencies.
1

Share this post


Link to post
Share on other sites
[quote name='SymLinked' timestamp='1336410244' post='4938113']
I ran into that as well, but can't remember the details. Are you mixing CRT versions? I think this came up when I rebuilt FreeImage but didn't rebuild all its dependencies.
[/quote]

Yes, it is the CTR. I knew the CTR was the problem many months ago but I had forgotten. Now the problem is that I can change the CTR to match my program (Multi-threaded DLL (/MD)) but then the compiler builds a separate DLL which means it's no longer a static library. I know I can't mix CRT types but I'm linking to several other static libraries without a problem. Confused?[img]http://public.gamedev.net//public/style_emoticons/default/huh.png[/img]
0

Share this post


Link to post
Share on other sites
"[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][background=rgb(250, 251, 252)]Multi-threaded DLL" doesn't mean that it will build DLL file. It will still build exelib or whatever you are building. Only difference from "[/background][/left][/size][/font][/color][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][background=rgb(250, 251, 252)]Multi-threaded" will be that your program will use CRT from DLL file and static CRT linked in your exe.[/background][/left][/size][/font][/color]
2

Share this post


Link to post
Share on other sites
[quote name='Martins Mozeiko' timestamp='1336414422' post='4938135']
"
[left][background=rgb(250, 251, 252)]Multi-threaded DLL" doesn't mean that it will build DLL file. It will still build exelib or whatever you are building. Only difference from "[/background][/left]
[left][color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][background=rgb(250, 251, 252)]Multi-threaded" will be that your program will use CRT from DLL file and static CRT linked in your exe.[/background][/size][/font][/color][/left]

[/quote]

Yeah, I just realized I was accidentally building the entire solution. Anyway, the CRT was not the problem. I'm still getting those errors... I believe I had already compiled it with the right CRT a few months ago when I did it. Edited by EnigmaticProgrammer
0

Share this post


Link to post
Share on other sites
These errors are typical of mixing two different runtimes as noted above. I do not have any other explanation for the symptoms in the original post. Something you are linking together was compiled using a different runtime than the rest of the code. Note that although you cannot mix the /MT and /MD runtimes, you cannot mix neither /MTd with /MT nor /MDd with /MD.

Edit: Also, since you mentioned compiling it a few months back, it is possible for (possibly automatic) updates to modify the version of the runtime. If that happens, even a previously /MD compiled library could possibly show the same symptoms when linking it with a current /MD program (the same goes for /MT, /MTd and /MDd). I did not keep track of the MSVC 2010 update schedule but I faintly remember something like this happening in MSVC 2008 at one point. Edited by BitMaster
1

Share this post


Link to post
Share on other sites
[quote name='BitMaster' timestamp='1336462471' post='4938314']
These errors are typical of mixing two different runtimes as noted above. I do not have any other explanation for the symptoms in the original post. Something you are linking together was compiled using a different runtime than the rest of the code. Note that although you cannot mix the /MT and /MD runtimes, you cannot mix neither /MTd with /MT nor /MDd with /MD.

Edit: Also, since you mentioned compiling it a few months back, it is possible for (possibly automatic) updates to modify the version of the runtime. If that happens, even a previously /MD compiled library could possibly show the same symptoms when linking it with a current /MD program (the same goes for /MT, /MTd and /MDd). I did not keep track of the MSVC 2010 update schedule but I faintly remember something like this happening in MSVC 2008 at one point.
[/quote]

Thanks to your response I realized it must be the other projects in the solution. I thought when I right clicked on a project and clicked build it was only building that project. However, it turns out that there was another sub menu which only builds that project but when I do that it says it needs the other projects. So I just had to set each project to Multi-threaded DLL and now it works perfectly! Thank you all for the help!
0

Share this post


Link to post
Share on other sites
Actually problem is still not solved... Compiled prefect but all of the functions are returning null? [img]http://public.gamedev.net//public/style_emoticons/default/blink.png[/img]

EDIT: Just needed to initialize it. [img]http://public.gamedev.net//public/style_emoticons/default/rolleyes.gif[/img]
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