How to read sqlite data using C++.? - c++

I want to read sqlite database file using c++ and VS2010 and i am writing below code.
sqlite3 *db;
int rc = sqlite3_open("test.db", &db);
I am getting this kind of error
lib(MSVCR100.dll) : error LNK2005: _strncmp already defined in LIBCMTD.lib(strncmp.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _malloc already defined in LIBCMTD.lib(dbgmalloc.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _free already defined in LIBCMTD.lib(dbgfree.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _realloc already defined in LIBCMTD.lib(dbgrealloc.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _memmove already defined in LIBCMTD.lib(memmove.obj)
1>MSVCRT.lib(MSVCR100.dll) : error LNK2005: _atoi already defined in LIBCMTD.lib(atox.obj)
1>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 LIBCMTD.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 LIBCMTD.lib(typinfo.obj)
1>LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>output\win32\Debug\SC.exe : fatal error LNK1169: one or more multiply defined symbols found
I did included sqlite3.lib in project and had given path ..

Within your project, you are trying to use both the DEBUG version and the RELEASE (NON-DEBUG) version of the C standard library.
This means that sqlite3.lib is using one kind of C standard library, and your project is using another. Your project, and the used libraries must match the Debug/Release choice, and the Static/Dynamic use of Standard Library choice.

Related

How do I use 2 libraries with same external symbols?

I have 2 libraries in my project - MySQL C++ Connector and OpenSSL library for sockets, and as I think MySQL library already has OpenSSL functions inside.
Errors I get
Errors I get (in text format):
1>libcrypto.lib(libcrypto-lib-x509_d2.obj) : error LNK2005: X509_STORE_load_locations already defined in mysqlcppconn-static.lib(libcrypto-1_1-x64.dll)
1>libcrypto.lib(libcrypto-lib-ct_policy.obj) : error LNK2005: CT_POLICY_EVAL_CTX_free already defined in mysqlcppconn-static.lib(libcrypto-1_1-x64.dll)
1>libcrypto.lib(libcrypto-lib-ct_policy.obj) : error LNK2005: CT_POLICY_EVAL_CTX_set1_cert already defined in mysqlcppconn-static.lib(libcrypto-1_1-x64.dll)
1>libcrypto.lib(libcrypto-lib-ct_policy.obj) : error LNK2005: CT_POLICY_EVAL_CTX_set1_issuer already defined in mysqlcppconn-static.lib(libcrypto-1_1-x64.dll)
1>libcrypto.lib(libcrypto-lib-ct_policy.obj) : error LNK2005: CT_POLICY_EVAL_CTX_set_shared_CTLOG_STORE already defined in mysqlcppconn-static.lib(libcrypto-1_1-x64.dll)
1>libcrypto.lib(libcrypto-lib-ct_policy.obj) : error LNK2005: CT_POLICY_EVAL_CTX_set_time already defined in mysqlcppconn-static.lib(libcrypto-1_1-x64.dll)
1>libcrypto.lib(libcrypto-lib-srp_lib.obj) : error LNK2005: SRP_Calc_A already defined in mysqlcppconn-static.lib(libcrypto-1_1-x64.dll)
1>libcrypto.lib(libcrypto-lib-srp_lib.obj) : error LNK2005: SRP_Calc_server_key already defined in mysqlcppconn-static.lib(libcrypto-1_1-x64.dll)
1>libcrypto.lib(libcrypto-lib-srp_lib.obj) : error LNK2005: SRP_Verify_A_mod_N already defined in mysqlcppconn-static.lib(libcrypto-1_1-x64.dll)
1>libcrypto.lib(libcrypto-lib-srp_lib.obj) : error LNK2005: SRP_Verify_B_mod_N already defined in mysqlcppconn-static.lib(libcrypto-1_1-x64.dll)
1>libcrypto.lib(libcrypto-lib-srp_lib.obj) : error LNK2005: SRP_check_known_gN_param already defined in mysqlcppconn-static.lib(libcrypto-1_1-x64.dll)
1>libcrypto.lib(libcrypto-lib-srp_lib.obj) : error LNK2005: SRP_get_default_gN already defined in mysqlcppconn-static.lib(libcrypto-1_1-x64.dll)
1>libcrypto.lib(libcrypto-lib-store_lib.obj) : error LNK2005: OSSL_STORE_INFO_free already defined in mysqlcppconn-static.lib(libcrypto-1_1-x64.dll)
1>libcrypto.lib(libcrypto-lib-store_lib.obj) : error LNK2005: OSSL_STORE_INFO_get0_CERT already defined in mysqlcppconn-static.lib(libcrypto-1_1-x64.dll)
1>libcrypto.lib(libcrypto-lib-store_lib.obj) : error LNK2005: OSSL_STORE_INFO_get0_NAME already defined in mysqlcppconn-static.lib(libcrypto-1_1-x64.dll)
1>libcrypto.lib(libcrypto-lib-store_lib.obj) : error LNK2005: OSSL_STORE_INFO_get_type already defined in mysqlcppconn-static.lib(libcrypto-1_1-x64.dll)
1>libcrypto.lib(libcrypto-lib-store_lib.obj) : error LNK2005: OSSL_STORE_close already defined in mysqlcppconn-static.lib(libcrypto-1_1-x64.dll)
1>libcrypto.lib(libcrypto-lib-store_lib.obj) : error LNK2005: OSSL_STORE_eof already defined in mysqlcppconn-static.lib(libcrypto-1_1-x64.dll)
1>libcrypto.lib(libcrypto-lib-store_lib.obj) : error LNK2005: OSSL_STORE_error already defined in mysqlcppconn-static.lib(libcrypto-1_1-x64.dll)
1>libcrypto.lib(libcrypto-lib-store_lib.obj) : error LNK2005: OSSL_STORE_load already defined in mysqlcppconn-static.lib(libcrypto-1_1-x64.dll)
1>libcrypto.lib(libcrypto-lib-store_lib.obj) : error LNK2005: OSSL_STORE_open already defined in mysqlcppconn-static.lib(libcrypto-1_1-x64.dll)
My project include directories:
\asio-1.24.0\include
\openssl\Lib\x64\Release\include
\MySQL\Connector C++ 8.0\include\jdbc
Linker input:
\openssl\Lib\x64\Release\lib\libcrypto.lib
\openssl\Lib\x64\Release\lib\libssl.lib
crypt32.lib
mysqlcppconn-static.lib
Static and shared libraries cannot be mixed like that.
mysqlcppconn-static is statically linked with libssl, and attempting to link, again, with libssl is not going to work.
mysqlcppconn-static is meant to be used with special-purpose applications that get statically linked only with mysql, and so they can be distributed without the mysql and openssl libraries.
Whenever multiple libraries are involved the only practical approach is to link only with shared libraries.

LNK2005 error when linking multiple projects that use boost

I have a project that consists from one main project, 3 projects that use boost and few other projects that links to static libraries. These 3 projects use boost. But I can't build my main project. I've got a lot of error LNK2005: .... already defined in ...
errors. As I understood, boost automaticaly links libraries to both of this projects. I tried to use BOOST_ALL_NO_LIB, but it didn't work. After adding this macro I've got unresolved symbols errors, but the redefinition errors still here. How can I solve this problem?
UPD1: there about 400+ errors. Here are first of them:
1>Project_with_boost_1.lib(VS_Project_with_boost_1.obj) : error LNK2005: "unsigned long __cdecl boost::asio::detail::win_tss_ptr_create(void)" (?win_tss_ptr_create#detail#asio#boost##YAKXZ) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(VS_Project_with_boost_1.obj) : error LNK2005: "void __cdecl boost::asio::detail::do_throw_error(class boost::system::error_code const &,char const *)" (?do_throw_error#detail#asio#boost##YAXABVerror_code#system#3#PBD#Z) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(VS_Project_with_boost_1.obj) : error LNK2005: "class boost::system::error_category const & __cdecl boost::asio::error::get_misc_category(void)" (?get_misc_category#error#asio#boost##YAABVerror_category#system#3#XZ) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(VS_Project_with_boost_1.obj) : error LNK2005: "protected: static void __cdecl boost::asio::detail::winsock_init_base::startup(struct boost::asio::detail::winsock_init_base::data &,unsigned char,unsigned char)" (?startup#winsock_init_base#detail#asio#boost##KAXAAUdata#1234#EE#Z) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(VS_Project_with_boost_1.obj) : error LNK2005: "protected: static void __cdecl boost::asio::detail::winsock_init_base::cleanup(struct boost::asio::detail::winsock_init_base::data &)" (?cleanup#winsock_init_base#detail#asio#boost##KAXAAUdata#1234##Z) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(VS_Project_with_boost_1.obj) : error LNK2005: "protected: static void __cdecl boost::asio::detail::winsock_init_base::throw_on_error(struct boost::asio::detail::winsock_init_base::data &)" (?throw_on_error#winsock_init_base#detail#asio#boost##KAXAAUdata#1234##Z) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(VS_Project_with_boost_1.obj) : error LNK2005: "public: void __thiscall boost::asio::detail::win_iocp_io_service::post_deferred_completions(class boost::asio::detail::op_queue<class boost::asio::detail::win_iocp_operation> &)" (?post_deferred_completions#win_iocp_io_service#detail#asio#boost##QAEXAAV?$op_queue#Vwin_iocp_operation#detail#asio#boost###234##Z) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(VS_Project_with_boost_1.obj) : error LNK2005: "struct boost::asio::detail::signal_state * __cdecl boost::asio::detail::get_signal_state(void)" (?get_signal_state#detail#asio#boost##YAPAUsignal_state#123#XZ) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(VS_Project_with_boost_1.obj) : error LNK2005: _boost_asio_signal_handler already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(VS_Project_with_boost_1.obj) : error LNK2005: "public: static void __cdecl boost::asio::detail::signal_set_service::deliver_signal(int)" (?deliver_signal#signal_set_service#detail#asio#boost##SAXH#Z) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(Some_file.obj) : error LNK2005: "unsigned long __cdecl boost::asio::detail::win_tss_ptr_create(void)" (?win_tss_ptr_create#detail#asio#boost##YAKXZ) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(Some_file.obj) : error LNK2005: "void __cdecl boost::asio::detail::do_throw_error(class boost::system::error_code const &,char const *)" (?do_throw_error#detail#asio#boost##YAXABVerror_code#system#3#PBD#Z) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(Some_file.obj) : error LNK2005: "class boost::system::error_category const & __cdecl boost::asio::error::get_misc_category(void)" (?get_misc_category#error#asio#boost##YAABVerror_category#system#3#XZ) already defined in Project_with_boost_2.lib(asio.obj)
1>Project_with_boost_1.lib(Some_file.obj) : error LNK2005: "protected: static void __cdecl boost::asio::detail::winsock_init_base::startup(struct boost::asio::detail::winsock_init_base::data &,unsigned char,unsigned char)" (?startup#winsock_init_base#detail#asio#boost##KAXAAUdata#1234#EE#Z) already defined in Project_with_boost_2.lib(asio.obj)
UPD2: I also tried to use macros kind of BOOST_SYSTEM_NO_LIB, BOOST_ASIO_NO_LIB. Result is the same as by using BOOST_ALL_NO_LIB
UPD3: I can set linker option in my main project "Force File Output" to "Multiply Defined Symbols Only /FORCE:MULTIPLE" and project compiles successfully, but during execution it crashes, so I can't use this option.
Your issues have nothing to do with auto linking. The issue is the fact that you've imported boost::asio, a header only library that has some global state, into two separate binaries and linked them together (probably one or more dlls and an exe).
By doing this, you're creating more than one definition of these objects/functions, hence the LNK2005 errors. A bit on that in this post. You need to follow what the manual says about this situation, and build properly. From the docs:
Optional separate compilation
By default, Boost.Asio is a header-only library. However, some
developers may prefer to build Boost.Asio using separately compiled
source code. To do this, add #include <boost/asio/impl/src.hpp> to one
(and only one) source file in a program, then build the program with
BOOST_ASIO_SEPARATE_COMPILATION defined in the project/compiler
settings. Alternatively, BOOST_ASIO_DYN_LINK may be defined to build a
separately-compiled Boost.Asio as part of a shared library.
Emphasis mine. Make sure you define BOOST_ASIO_SEPARATE_COMPILATION is all associated projects that include boost::asio. About the /FORCE:MULTIPLE option, pretend this flag doesn't exist. It's evil, as you can see. It's throwing errors in the garbage that were there to tell you that something is seriously wrong.

fatal error LNK1169

The below error list pops up.
I am okay if this had happened on Release build.
It is quite surprising that it has happened in DEBUG build.
1>libcmtd.lib(dbgheap.obj) : error LNK2005: malloc already defined in libcmt.lib(malloc.obj)
1>libcmtd.lib(dbgheap.obj) : error LNK2005: _heap_alloc already defined in libcmt.lib(malloc.obj)
1>libcmtd.lib(dbgheap.obj) : error LNK2005: calloc already defined in libcmt.lib(calloc.obj)
1>libcmtd.lib(dbgheap.obj) : error LNK2005: realloc already defined in libcmt.lib(realloc.obj)
1>libcmtd.lib(dbgheap.obj) : error LNK2005: _recalloc already defined in libcmt.lib(realloc.obj)
1>libcmtd.lib(dbgheap.obj) : error LNK2005: _expand already defined in libcmt.lib(expand.obj)
1>libcmtd.lib(dbgheap.obj) : error LNK2005: free already defined in libcmt.lib(free.obj)
1>libcmtd.lib(dbgheap.obj) : error LNK2005: _msize already defined in libcmt.lib(msize.obj)
1>libcmtd.lib(dbgheap.obj) : error LNK2005: _aligned_malloc already defined in libcmt.lib(align.obj)
1>libcmtd.lib(dbgheap.obj) : error LNK2005: _aligned_realloc already defined in libcmt.lib(align.obj)
1>libcmtd.lib(dbgheap.obj) : error LNK2005: _aligned_recalloc already defined in libcmt.lib(align.obj)
1>libcmtd.lib(dbgheap.obj) : error LNK2005: _aligned_offset_malloc already defined in libcmt.lib(align.obj)
1>libcmtd.lib(dbgheap.obj) : error LNK2005: _aligned_offset_realloc already defined in libcmt.lib(align.obj)
1>libcmtd.lib(dbgheap.obj) : error LNK2005: _aligned_offset_recalloc already defined in libcmt.lib(align.obj)
1>libcmtd.lib(dbgheap.obj) : error LNK2005: _aligned_free already defined in libcmt.lib(align.obj)
1>libcmtd.lib(dbgheap.obj) : error LNK2005: _aligned_msize already defined in libcmt.lib(align.obj)
1>libcmtd.lib(dbghook.obj) : error LNK2005: __crt_debugger_hook already defined in libcmt.lib(dbghook.obj)
1>libcmtd.lib(isctype.obj) : error LNK2005: _isctype_l already defined in libcmt.lib(isctype.obj)
1>libcmtd.lib(isctype.obj) : error LNK2005: _isctype already defined in libcmt.lib(isctype.obj)
It looks like you're linking to the Debug runtime as well as the Release runtime - probably you have a Release build that links statically to a Debug lib or vice versa.
If your application use any LIBs or DLLs any of those are statically link with run-time assemblies. that's the reason for this linking error.
Run-time assemblies statically liking is not a recommended method
But if you need to get rid from this linking error here you go, right-click on project file in project explorer -> properties -> configuration properties -> linker -> Input -> Ignore Specific Library -> add libcmtd.lib

How can the Interactive Brokers API C++ test socket client be built with VS2010

Having followed the instructions given here http://www.interactivebrokers.com/php/apiUsersGuide/apiguide.htm#apiguide/c/using_the_c__testsocketclient_sample_program.htm
under Visual Studio Professional 2010, the c++ project always gives the following output:
1> Generating Code...
1>LIBCMT.lib(invarg.obj) : error LNK2005: __initp_misc_invarg already defined in libcmtd.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: __call_reportfault already defined in libcmtd.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: __set_invalid_parameter_handler already defined in libcmtd.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: __get_invalid_parameter_handler already defined in libcmtd.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: __invoke_watson already defined in libcmtd.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: "void __cdecl _invoke_watson(unsigned short const *,unsigned short const *,unsigned short const *,unsigned int,unsigned int)" (?_invoke_watson##YAXPBG00II#Z) already defined in libcmtd.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: __invalid_parameter already defined in libcmtd.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: "void __cdecl _invalid_parameter(unsigned short const *,unsigned short const *,unsigned short const *,unsigned int,unsigned int)" (?_invalid_parameter##YAXPBG00II#Z) already defined in libcmtd.lib(invarg.obj)
1>LIBCMT.lib(invarg.obj) : error LNK2005: ___pInvalidArgHandler already defined in libcmtd.lib(invarg.obj)
1> Creating library C:\Syncing\VCPlusPlus\IBTestSocketClientVS2010\Debug\SampleSocketClient.lib and object C:\Syncing\VCPlusPlus\IBTestSocketClientVS2010\Debug\SampleSocketClient.exp
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>C:\Syncing\VCPlusPlus\IBTestSocketClientVS2010\Debug\SampleSocketClient.exe : fatal error LNK1169: one or more multiply defined symbols found
1>
1>Build FAILED.
1>
1>Time Elapsed 00:01:30.63
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
If anyone has had experience of this or understands how to fix this bug, it would be much appreciated!
I guess I found the answer for you. I followed the indication of the error LNK2005 description and it indicates that there is some double linking thing happening behind the scenes.
The only thing you need to do is change the properties of your project Configuration:
Properties->Linker->Input->Ignore Specific Default Libraries
Here, you should set up the library you wanna ignore which is libcmt.lib. After setting up, you should see the value of Ignore Specific Default Libraries is:
libcmt.lib;%(IgnoreSpecificDefaultLibraries)
Then build, binggo~~~~ Please try it out.
Looks like you need to fix your lib references. By the looks of below error, your project is referencing both the release and debug versions, hence the linker is not sure where to look for specific symbols as it is defined in multiple places (both debug and release):
BlockquoteLIBCMT.lib(invarg.obj) : error LNK2005: ___pInvalidArgHandler already defined in libcmtd.lib(invarg.obj)
In case you are not referencing any libs and the IB dll is doing it behind the scenes, you may want to explore the NODEFAULTLIB option through your VS.
The problem is that the PosixSocketClient code assumes that when compiled with a Microsoft compiler, Microsoft Foundation Library (MFC) is going to be used. Maybe it used to work like that in the past but I never got it working with VS2010. But I did get it working by removing dependency on/linking with MFC.
Unfortunately, code in Shared subfolder automatically assumes MFC if _MSC_VER is defined.
(_MSC_VER gives the version of Microsoft C++ compiler).
It cannot be simply undef-ined because some standard Windows headers use it.
This is clearly a bug as the presence of MFC is signalled by _MFC_VER, not _MSC_VER.
Therefore I had to change
#ifdef _MSC_VER
everywhere in EClientSocketBaseImpl.h into
#ifdef _MFC_VER
Also, in file _StdAfx.h, #include <afxwin.h> should be wrapped additionally in a conditional compilation directive:
#ifdef _MFC_VER
#include <afxwin.h>
#endif

Huge Amount of Linker Issues with Release Build Only

Anyone have idea on this? Linker errors are way out of my wheelhouse, especially ones like this.
Is there any more info I should include?
1>Linking...
1>freeglut_static.lib(freeglut_window.obj) : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:ICF' specification
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __heap_alloc already defined in LIBCMT.lib(malloc.obj)
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __recalloc already defined in LIBCMT.lib(recalloc.obj)
1>LIBCMTD.lib(dbgheap.obj) : error LNK2005: __msize already defined in LIBCMT.lib(msize.obj)
1>LIBCMTD.lib(malloc.obj) : error LNK2005: _V6_HeapAlloc already defined in LIBCMT.lib(malloc.obj)
1>LIBCMTD.lib(dbghook.obj) : error LNK2005: __crt_debugger_hook already defined in LIBCMT.lib(dbghook.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_pHeaderDefer already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: __get_sbh_threshold already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: __set_sbh_threshold already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: __set_amblksiz already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: __get_amblksiz already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_heap_init already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_find_block already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_free_block already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_alloc_block already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_alloc_new_region already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_alloc_new_group already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_resize_block already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_heapmin already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(sbheap.obj) : error LNK2005: ___sbh_heap_check already defined in LIBCMT.lib(sbheap.obj)
1>LIBCMTD.lib(isctype.obj) : error LNK2005: __isctype_l already defined in LIBCMT.lib(isctype.obj)
1>LIBCMTD.lib(isctype.obj) : error LNK2005: __isctype already defined in LIBCMT.lib(isctype.obj)
1>LINK : warning LNK4098: defaultlib 'LIBCMTD' conflicts with use of other libs; use /NODEFAULTLIB:library
You seem to be linking projects built with different CRT library settings, one with Multi-Threaded, another one with Multi-Threaded Debug. Adjust the settings for all the projects to use the very same flavour of the library and the issue should go away!
You wouldn't normally try and pull in LIBCMTD in a release build, it's the debug version of LIBCMT.
It seems that your release build is trying to link to something that was built debug. You probably have a broken dependency in your build, (or you missed rebuilding something to release by hand if your project is normally built in pieces).
It would seem likely that it's the freeglut_static.lib that wasn't rebuilt for retail. If that isn't it then try deleting all of your build products (*.obj, *.lib, *.pch, *.pdb) of course being careful to not delete things that you don't produce - third party libs, etc. Then build just release.
To add to the other remarks: Don't use "Edit and Continue" /EDITANDCONTINUE in release builds. That's a useful feature while debugging, as it can reduce rebuild times. But it does so by packing your executable in a non-optimized form.
You get the warning because the /OPT:ICF option will fold identical function bodies. This means two functions share the same address. Obviously this means you cannot edit & replace only one of them.