Can't compile my program in Release

Started by
6 comments, last by LGAB 15 years, 5 months ago
Hey people, I've been googling for several days, but I'm running out of leads! I can't compile this thing in release mode, only way it compiles is to set "Runtime Library" to "Multi-threaded Debug DLL (/MDd)," but I can't run the app on a another computer without VC++ installed on it because of that. Compiler output:

1>Compiling...
1>main.cpp
1>Compiling manifest to resources...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.0.5724.0
1>Copyright (C) Microsoft Corporation.  All rights reserved.
1>Linking...
1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification
1>glfont.obj : error LNK2001: unresolved external symbol @__security_check_cookie@4
1>glfont.obj : error LNK2001: unresolved external symbol _free
1>glfont.obj : error LNK2001: unresolved external symbol _malloc
1>glfont.obj : error LNK2001: unresolved external symbol _fopen
1>glfont.obj : error LNK2001: unresolved external symbol _fread
1>glfont.obj : error LNK2001: unresolved external symbol _fclose
1>main.obj : error LNK2001: unresolved external symbol _memmove_s
1>main.obj : error LNK2001: unresolved external symbol __Getcvt
1>main.obj : error LNK2001: unresolved external symbol _fputc
1>main.obj : error LNK2001: unresolved external symbol _sscanf_s
1>main.obj : error LNK2001: unresolved external symbol _perror
1>main.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall std::bad_cast::~bad_cast(void)" (??1bad_cast@std@@UAE@XZ)
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall std::bad_cast::bad_cast(char const *)" (??0bad_cast@std@@QAE@PBD@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall std::bad_cast::bad_cast(class std::bad_cast const &)" (??0bad_cast@std@@QAE@ABV01@@Z)
1>main.obj : error LNK2001: unresolved external symbol "long const std::_BADOFF" (?_BADOFF@std@@3JB)
1>main.obj : error LNK2001: unresolved external symbol "class std::basic_ostream<char,struct std::char_traits<char> > std::cout" (?cout@std@@3V?$basic_ostream@DU?
$char_traits@D@std@@@1@A)
1>main.obj : error LNK2001: unresolved external symbol "public: static class std::locale::id std::ctype<char>::id" (?id@?$ctype@D@std@@2V0locale@2@A)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual char const * __thiscall std::exception::what(void)const " (?what@exception@std@@UBEPBDXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall std::exception::~exception(void)" (??1exception@std@@UAE@XZ)
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall std::exception::exception(void)" (??0exception@std@@QAE@XZ)
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall std::exception::exception(char const * const &)" (??0exception@std@@QAE@ABQBD@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall std::exception::exception(char const * const &,int)" (??0exception@std@@QAE@ABQBDH@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall std::exception::exception(class std::exception const &)" (??0exception@std@@QAE@ABV01@@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: static void __cdecl std::_Locinfo::_Locinfo_dtor(class std::_Locinfo *)" (?_Locinfo_dtor@_Locinfo@st
@@SAXPAV12@@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: static void __cdecl std::_Locinfo::_Locinfo_ctor(class std::_Locinfo *,class std::basic_string<char,s
truct std::char_traits<char>,class std::allocator<char> > const &)" (?_Locinfo_ctor@_Locinfo@std@@SAXPAV12@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@2@@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall std::_Lockit::~_Lockit(void)" (??1_Lockit@std@@QAE@XZ)
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall std::_Lockit::_Lockit(int)" (??0_Lockit@std@@QAE@H@Z)
1>main.obj : error LNK2001: unresolved external symbol "private: static int std::locale::id::_Id_cnt" (?_Id_cnt@id@locale@std@@0HA)
1>main.obj : error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xran(void)" (?_Xran@_String_base@std@@SAXXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: static void __cdecl std::_String_base::_Xlen(void)" (?_Xlen@_String_base@std@@SAXXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: void __thiscall std::_Mutex::_Unlock(void)" (?_Unlock@_Mutex@std@@QAEXXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: void __thiscall std::_Mutex::_Lock(void)" (?_Lock@_Mutex@std@@QAEXXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall std::_Mutex::~_Mutex(void)" (??1_Mutex@std@@QAE@XZ)
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall std::_Mutex::_Mutex(void)" (??0_Mutex@std@@QAE@XZ)
1>main.obj : error LNK2001: unresolved external symbol "bool __cdecl std::uncaught_exception(void)" (?uncaught_exception@std@@YA_NXZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static void __cdecl std::locale::facet::facet_Register(class std::locale::facet *)" (?facet_Register@f
acet@locale@std@@CAXPAV123@@Z)
1>main.obj : error LNK2001: unresolved external symbol "private: static class std::locale::_Locimp * __cdecl std::locale::_Init(void)" (?_Init@locale@std@@CAPAV_Locimp
@12@XZ)
1>main.obj : error LNK2001: unresolved external symbol "private: static class std::locale::_Locimp * __cdecl std::locale::_Getgloballocale(void)" (?_Getgloballocale@lo
ale@std@@CAPAV_Locimp@12@XZ)
1>main.obj : error LNK2001: unresolved external symbol "struct _iobuf * __cdecl std::_Fiopen(char const *,int,int)" (?_Fiopen@std@@YAPAU_iobuf@@PBDHH@Z)
1>main.obj : error LNK2001: unresolved external symbol "private: static void __cdecl std::ios_base::_Ios_base_dtor(class std::ios_base *)" (?_Ios_base_dtor@ios_base@st
d@@CAXPAV12@@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: static void __cdecl std::ios_base::_Addstd(class std::ios_base *)" (?_Addstd@ios_base@std@@SAXPAV12@@Z)
1>main.obj : error LNK2001: unresolved external symbol _sprintf_s
1>main.obj : error LNK2001: unresolved external symbol "void * __cdecl operator new[](unsigned int)" (??_U@YAPAXI@Z)
1>main.obj : error LNK2001: unresolved external symbol __Tolower
1>main.obj : error LNK2001: unresolved external symbol _ungetc
1>main.obj : error LNK2001: unresolved external symbol _fgetpos
1>main.obj : error LNK2001: unresolved external symbol _memchr
1>main.obj : error LNK2001: unresolved external symbol _fflush
1>main.obj : error LNK2001: unresolved external symbol _atoi
1>main.obj : error LNK2001: unresolved external symbol _fgetc
1>main.obj : error LNK2001: unresolved external symbol _localeconv
1>main.obj : error LNK2001: unresolved external symbol "class boost::system::error_code __cdecl boost::filesystem::detail::not_found_error(void)" (?not_found_error@det
ail@filesystem@boost@@YA?AVerror_code@system@3@XZ)
1>main.obj : error LNK2001: unresolved external symbol "class boost::system::error_code __cdecl boost::filesystem::detail::dir_itr_first(void * &,class std::basic_stri
g<char,struct std::char_traits<char>,class std::allocator<char> > const &,class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > &,cla
ss boost::filesystem::file_status &,class boost::filesystem::file_status &)" (?dir_itr_first@detail@filesystem@boost@@YA?AVerror_code@system@3@AAPAXABV?$basic_string@D
U?$char_traits@D@std@@V?$allocator@D@2@@std@@AAV67@AAVfile_status@23@3@Z)
1>main.obj : error LNK2001: unresolved external symbol "class boost::system::error_code __cdecl boost::filesystem::detail::dir_itr_close(void * &)" (?dir_itr_close@det
ail@filesystem@boost@@YA?AVerror_code@system@3@AAPAX@Z)
1>main.obj : error LNK2001: unresolved external symbol "class boost::system::error_code __cdecl boost::filesystem::detail::get_current_path_api(class std::basic_string<
char,struct std::char_traits<char>,class std::allocator<char> > &)" (?get_current_path_api@detail@filesystem@boost@@YA?AVerror_code@system@3@AAV?$basic_string@DU?$char_
traits@D@std@@V?$allocator@D@2@@std@@@Z)
1>main.obj : error LNK2001: unresolved external symbol "struct std::pair<class boost::system::error_code,__int64> __cdecl boost::filesystem::detail::last_write_time_ap
i(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?last_write_time_api@detail@filesystem@boost@@YA?AU?$pair@Verror_
code@system@boost@@_J@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@@Z)
1>main.obj : error LNK2001: unresolved external symbol "class boost::filesystem::file_status __cdecl boost::filesystem::detail::status_api(class std::basic_string<char
,struct std::char_traits<char>,class std::allocator<char> > const &,class boost::system::error_code &)" (?status_api@detail@filesystem@boost@@YA?AVfile_status@23@ABV?$
basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAVerror_code@system@3@@Z)
1>main.obj : error LNK2001: unresolved external symbol "class boost::system::error_code __cdecl boost::filesystem::detail::dir_itr_increment(void * &,class std::basic_
string<char,struct std::char_traits<char>,class std::allocator<char> > &,class boost::filesystem::file_status &,class boost::filesystem::file_status &)" (?dir_itr_incr
ement@detail@filesystem@boost@@YA?AVerror_code@system@3@AAPAXAAV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@AAVfile_status@23@2@Z)
1>main.obj : error LNK2001: unresolved external symbol "struct std::pair<class boost::system::error_code,bool> __cdecl boost::filesystem::detail::create_directory_api(
class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?create_directory_api@detail@filesystem@boost@@YA?AU?$pair@Verror_co
de@system@boost@@_N@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@@Z)
1>main.obj : error LNK2001: unresolved external symbol "struct std::pair<class boost::system::error_code,unsigned __int64> __cdecl boost::filesystem::detail::file_size
_api(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &)" (?file_size_api@detail@filesystem@boost@@YA?AU?$pair@Verror_code
system@boost@@_K@std@@ABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@5@@Z)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual char const * __thiscall boost::thread_resource_error::what(void)const " (?what@thread_resource_
error@boost@@UBEPBDXZ)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall boost::thread_resource_error::~thread_resource_error(void)" (??1thread_resource_error
@boost@@UAE@XZ)
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall boost::thread_resource_error::thread_resource_error(void)" (??0thread_resource_error@boost@@Q
AE@XZ)
1>main.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall boost::thread_exception::~thread_exception(void)" (??1thread_exception@boost@@UAE@XZ)
1>main.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::get_system_category(void)" (?get_system_categ
ory@system@boost@@YAABVerror_category@12@XZ)
1>main.obj : error LNK2001: unresolved external symbol "class boost::system::error_category const & __cdecl boost::system::get_generic_category(void)" (?get_generic_cat
egory@system@boost@@YAABVerror_category@12@XZ)
1>main.obj : error LNK2001: unresolved external symbol "public: __thiscall boost::thread::~thread(void)" (??1thread@boost@@QAE@XZ)
1>main.obj : error LNK2001: unresolved external symbol "private: void __thiscall boost::thread::start_thread(void)" (?start_thread@thread@boost@@AAEXXZ)
1>main.obj : error LNK2001: unresolved external symbol _atexit
1>main.obj : error LNK2001: unresolved external symbol _fsetpos
1>main.obj : error LNK2001: unresolved external symbol __invalid_parameter_noinfo
1>main.obj : error LNK2001: unresolved external symbol __Getctype
1>main.obj : error LNK2001: unresolved external symbol _setvbuf
1>main.obj : error LNK2001: unresolved external symbol "void __cdecl operator delete[](void *)" (??_V@YAXPAX@Z)
1>main.obj : error LNK2001: unresolved external symbol __Toupper
1>main.obj : error LNK2001: unresolved external symbol _rand
1>main.obj : error LNK2001: unresolved external symbol _strcpy_s
1>main.obj : error LNK2001: unresolved external symbol _srand
1>main.obj : error LNK2001: unresolved external symbol __purecall
1>main.obj : error LNK2001: unresolved external symbol "void __cdecl operator delete(void *)" (??3@YAXPAX@Z)
1>main.obj : error LNK2001: unresolved external symbol _memcpy_s
1>main.obj : error LNK2001: unresolved external symbol _fwrite
1>main.obj : error LNK2001: unresolved external symbol _strcspn
1>main.obj : error LNK2001: unresolved external symbol _fseek
1>main.obj : error LNK2001: unresolved external symbol "const type_info::`vftable'" (??_7type_info@@6B@)
1>main.obj : error LNK2001: unresolved external symbol __time64
1>main.obj : error LNK2001: unresolved external symbol _exit
1>main.obj : error LNK2001: unresolved external symbol "void * __cdecl operator new(unsigned int)" (??2@YAPAXI@Z)
1>LINK : error LNK2001: unresolved external symbol _mainCRTStartup


I've just recently started using VC++ Express over mingw dev studio, since it's tons better for debugging among other things, but there's a bunch of Microsoft-centric issues I've never had to deal with before, pre-compiled headers, .NET frameworks and whatnot. I'm making a console app with an OpenGL window and I'd like to keep it as portable as possible, sticking to multi-platform libs, and I'm using Boost for a lot of stuff. I'm suspecting Boost.. but I've built all possible lib variants of Boost. What do I need to do? I don't want users to be required to install VC redistributables to get this to run. Can you work this way? I like the IDE, but there's a bunch of stuff which is just confusing and unnecessary. Any advice? :)
Advertisement
Those errors appear to be because you aren't linking with any of the standard runtime libraries. What linker settings / command line are you using?
Also, it's quite normal that you need to install the runtime components of Visual C++ on computers that doesn't have VS installed.
Adam_42: Here's the whole thing:

/OUT: /INCREMENTAL /NOLOGO /MANIFEST /MANIFESTFILE:"Release\.intermediate.manifest" /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /NODEFAULTLIB /DEBUG /PDB:".pdb" /SUBSYSTEM:CONSOLE /OPT:REF /OPT:ICF /LTCG /DYNAMICBASE /NXCOMPAT /MACHINE:X86 /ERRORREPORT:PROMPT /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:LIBCMT.lib SDL.lib SDLmain.lib FreeImage.lib opengl32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib

I added the NODEFAULTLIB switches because the compiler wanted me to earlier, I'm not sure why but it enabled me to skip unicode and pre-compiled headers and that stuff. I want to keep it as free of MS-specific code as possible.

Promethium: Yes I suppose so, but I'd prefer not, the app could run without all that on mingw, I don't see why I would need it now..

[Edited by - LGAB on May 5, 2009 3:37:20 AM]
Quote:I added the NODEFAULTLIB switches because the compiler wanted me to earlier, I'm not sure why but it enabled me to skip unicode and pre-compiled headers and that stuff. I want to keep it as free of MS-specific code as possible.

Promethium: Yes I suppose so, but I'd prefer not, the app could run without all that on mingw, I don't see why I would need it now..
Mingw does link default libraries. You are not doing so. If you are not using functions of the C standard library, either Boost or SDL or both are, so you must link them to your program.

If you wanted to keep your programs as free of MS-specific code as possible, why did you switch to Visual C++ in the first place?

Well, I switched because the IDE is better. At the end of the day I'll do what I have to do to get this to work, I'd like to know what I have to do, though.

So if use default libraries, I get this, at the last line, it's asking me to skip that specific default library, and after that a second one. Then it compiles in debug mode. No combination compiles in release.

1>Linking...1>LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/LTCG' specification1>msvcrt.lib(ti_inst.obj) : error LNK2005: "private: __thiscall type_info::type_info(class type_info const &)" (??0type_info@@AAE@ABV0@@Z) 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) already defined in LIBCMT.lib(typinfo.obj)1>msvcrt.lib(MSVCR90.dll) : error LNK2005: _isspace already defined in LIBCMT.lib(_ctype.obj)1>msvcrt.lib(MSVCR90.dll) : error LNK2005: ___iob_func already defined in LIBCMT.lib(_file.obj)1>msvcrt.lib(MSVCR90.dll) : error LNK2005: _fclose already defined in LIBCMT.lib(fclose.obj)1>msvcrt.lib(MSVCR90.dll) : error LNK2005: _exit already defined in LIBCMT.lib(crt0dat.obj)1>LIBCMT.lib(crt0init.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
Every library you use for one app needs to be built with the same CRT settings regarding Single vs Multi-threaded, Static vs DLL, & Release vs Debug.

MSVCRT.LIB is the single threaded lib, LIBCMT.lib is multi threaded. You need to recompile the libs you link to (SDL and FreeImage by the look of it) with the right settings.

However, given that newer versions of Visual Studio don't have the single threaded option, what you probably want to do first is upgrade to 2008 express.

See http://support.microsoft.com/kb/154753 for details of what default libs do what.
Actually, I'm using VC++ Express 2008 (v9.0). Sounds like a real mess to get this sorted.. thanks though

It's soo nearly there, I could just forget about it and install the redistributable and let people run the debug version. Don't see why I have to recompile libraries and do all sorts of stuff to get around this thing, I'm not even sure its related.. sigh..

edit: the redistributable didn't help, so far it only works on other computers if I actually install VC++ Express first

edit#2: by removing /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:LIBCMT.lib, required to build debug, it finally worked with release as well, in case someone would stumble into the same thing. I'm sure it's basic stuff, but I'm new to the IDE and all, so.. :) Redistributables still necessary to start the app on other computers though, I can't compile the program as /MT, only /MD. But that might be due to the other libs I'm using. Thanks for your help!

[Edited by - LGAB on November 25, 2008 10:17:49 AM]

This topic is closed to new replies.

Advertisement