using static libraries instead of dynamic libraries in opencv - c++

I have a project in visual studio 2012 which uses opencv dynamic libraries. It compiled, linked and worked well.
I want to change the project so it uses static libraries instead of dynamic libraries.
I changed the library directories in project VC++ directory from
C:\thirdparty\opencv\build\x86\vc11\lib
to:
C:\thirdparty\opencv\build\x86\vc11\staticlib
but when I want to build the project, I am getting a lot of linker error such as:
Error 110 error LNK2001: unresolved external symbol _TIFFWriteScanline myproject\opencv_highgui245.lib(grfmt_tiff.obj)
and more importantly a lot of error such as this:
Error 1 error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MD_DynamicRelease' in myproject.obj myproject\opencv_core245.lib(system.obj)
What other changes should I do to convert a project which uses dynamic libraries to use static libraries?
Edit 1
After change /md to /mt and adding some new libraries to the list of input libraries:
opencv_calib3d245.lib
opencv_contrib245.lib
opencv_core245.lib
opencv_features2d245.lib
opencv_flann245.lib
libtiff.lib
libpng.lib
libjpeg.lib
libjasper.lib
IlmImf.lib
zlib.lib
opencv_gpu245.lib
opencv_haartraining_engine.lib
opencv_highgui245.lib
opencv_imgproc245.lib
opencv_legacy245.lib
opencv_ml245.lib
opencv_nonfree245.lib
opencv_objdetect245.lib
opencv_photo245.lib
opencv_stitching245.lib
opencv_ts245.lib
opencv_video245.lib
opencv_videostab245.lib
I am getting some new errors:
Error 9 error LNK2001: unresolved external symbol _AVIFileCreateStreamA#12 myproject\opencv_highgui245.lib(cap_vfw.obj)
Error 8 error LNK2001: unresolved external symbol _AVIFileGetStream#16 myproject\opencv_highgui245.lib(cap_vfw.obj)
Error 5 error LNK2001: unresolved external symbol _AVIFileInit#0 myproject\opencv_highgui245.lib(cap_vfw.obj)
Error 7 error LNK2001: unresolved external symbol _AVIFileOpenA#16 myproject\opencv_highgui245.lib(cap_vfw.obj)
Apparently some library is missing, but which one?
Edit 2
need to add more library to list. Full list of library is as follow:
opencv_calib3d245.lib
opencv_contrib245.lib
opencv_core245.lib
opencv_features2d245.lib
opencv_flann245.lib
libtiff.lib
libpng.lib
libjpeg.lib
libjasper.lib
IlmImf.lib
zlib.lib
opencv_gpu245.lib
opencv_haartraining_engine.lib
opencv_highgui245.lib
opencv_imgproc245.lib
opencv_legacy245.lib
opencv_ml245.lib
opencv_nonfree245.lib
opencv_objdetect245.lib
opencv_photo245.lib
opencv_stitching245.lib
opencv_ts245.lib
opencv_video245.lib
opencv_videostab245.lib
Vfw32.Lib
comctl32.lib
This solved the problem.

I am able to get the static libraries working in VS 2013 by changing the project's Runtime Library to /MTd
and then including these Linker >> Input >> Additional Dependencies:
opencv_core248d.lib
opencv_imgproc248d.lib
opencv_highgui248d.lib
opencv_ml248d.lib
opencv_video248d.lib
opencv_features2d248d.lib
opencv_calib3d248d.lib
opencv_objdetect248d.lib
opencv_contrib248d.lib
opencv_legacy248d.lib
opencv_flann248d.lib
libpngd.lib
libtiffd.lib
zlibd.lib
IlmImfd.lib
libjasperd.lib
libjpegd.lib
comctl32.lib
gdi32.lib
vfw32.lib

If you are building using CMake then it is very simple because it is one of the OpenCV CMake options; just set BUILD_WITH_STATIC_CRT to off. Eg. on the CMake command-line
-DBUILD_WITH_STATIC_CRT=OFF

For Visual Studio 2012 with OpenCV 3.0.0, these problems still apply, and the solutions in this thread are relevant. Here's my setup to get it to work:
Windows' System Environment Variables
Set in Windows' System Environment Variables: OPENCV_DIR = D:\OpenCV\build\x64\v11 (replace D:\OpenCV\ with whatever your path to opencv is. Also, x64 for 64-bit machines, x86 for 32-bit machines).
Use staticlib for AdditionalLibraryDirectories
Set the Additional Library Directories (View > Property Pages > Configuration Properties > Linker > General > Additional Library Directories) to: $(OPENCV_DIR)\staticlib;%(AdditionalLibraryDirectories)
Runtime Library
Change the Code Generation > Runtime Library to Multi-threaded Debug (/MTd) per uosɐſ's answer, otherwise you'll get this kind of error:
Error 1 error LNK2038: mismatch detected for 'RuntimeLibrary': value
'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in Source.obj
C:\Users\...\documents\visual studio 2012\Projects\OpenCVTest2\OpenCVTest2\opencv_core300d.lib(alloc.obj) OpenCVTest2
Finally, the Additional Dependencies list
My Additional Dependencies must include all the library names in the staticlib directory. Mind the version numbers; since I'm using OpenCV 3.0.0, the filenames ends with *300d.lib. I believe the comctl32.lib and vfw32.lib are not in the staticlib, but I added them just in case (View > Property Pages > Configuration Properties > Linker > Input > Additional Dependencies):
opencv_calib3d300d.lib
opencv_core300d.lib
opencv_features2d300d.lib
opencv_flann300d.lib
opencv_hal300d.lib
opencv_highgui300d.lib
opencv_imgcodecs300d.lib
opencv_imgproc300d.lib
opencv_ml300d.lib
opencv_objdetect300d.lib
opencv_photo300d.lib
opencv_shape300d.lib
opencv_stitching300d.lib
opencv_superres300d.lib
opencv_ts300d.lib
opencv_video300d.lib
opencv_videostab300d.lib
libtiffd.lib
libpngd.lib
libjpegd.lib
libjasperd.lib
IlmImfd.lib
libwebpd.lib
ippicvmt.lib
zlibd.lib
comctl32.lib
vfw32.lib
x86 vs x64
I also ran into this issue that VS2012 claims the target machine does not match the module machine type like this guy. The solution is given here.

Dude, let me tell you... been there done that..
I tried the static lib thing (a couple of times..) It's evil.
If you are using Visual Studio, you better degrade back to
VS2010. VS2012 and up wasn't used to build these libraries. And that
is true at least for version 244. You might just be able to link but
you will get crashes with very basic functions.. So spare yourself.
If you use GCC you might just find that the .a libs are evil
indeed.. They were cross-compiled in windows for LINUX. Trying to
link with cygwin, MinGw won't do the job.
After trying for 2 days I decided that it was enough time wasted, and retreated back to the DLL's, which work ok if you use VS2010.
Let it not be a turnoff.. If you did manage to link, please share with us all how :)

I have build an application which depends on OpenCV 2.4.9 with static linking.
1)
I have just added linker additional dependencies:
opencv_core249d.lib
opencv_imgproc249d.lib
opencv_highgui249d.lib
opencv_ml249d.lib
opencv_video249d.lib
opencv_features2d249d.lib
opencv_calib3d249d.lib
opencv_objdetect249d.lib
opencv_contrib249d.lib
opencv_legacy249d.lib
opencv_flann249d.lib
libpngd.lib
libtiffd.lib
zlibd.lib
IlmImfd.lib
libjasperd.lib
libjpegd.lib
comctl32.lib
gdi32.lib
vfw32.lib
2)
Linker => General => Additional Library Directories => changed $(OPENCV_DIR)\x86\vc12\lib to $(OPENCV_DIR)\x86\vc12\staticlib where OPENCV_DIR is environment variable set to:
C:\OpenCV 2.4.9\opencv\build
3)
and changed C/C++ => Code Generation => Multi-threaded debug DLL (MD) to Multi-threaded debug (MTd)
and enjoyed the successful build.
the same thing works for release mode (of course link against non-debug libs)

Related

How to use "webrtc.lib" static library in VS 2019 or CLion Project?

I have been working with WebRtc Development for the Windows Platform. I want to develop webrtc based desktop application. I am doing it from scratch for learning and better understanding.
The normal process of WebRtc Library Compilation:
I have initially started with (Getting Started with WinRTC). I followed the normal compilation process. After that, I have tried multiple ways to generate project files for webrtc such as;
1.Default
gn gen --ide=vs2019 out/Default
2.Custom Flags
gn gen --ide=vs2019 out/Default --args="use_rtti=true is_clang=false rtc_build_tools=false rtc_include_tests=false rtc_build_examples=false"
3.Custom Flags
gn gen --ide=vs2019 out\Default --filters=//:webrtc "--args=is_debug=true use_lld=false is_clang=false rtc_include_tests=true rtc_build_tools=true rtc_win_video_capture_winrt=true target_cpu=\"x86\" target_os=\"win\" rtc_build_examples=true rtc_win_use_mf_h264=true enable_libaom=true rtc_enable_protobuf=true"
For the building process, I have Followed these methods:
With command line:
Run the following command to build the patched WebRTC from the command line.
ninja -C out\Default\x64
With Visual Studio 2019:
Open the generated Visual Studio solution with the following command:
devenv out\Default\x64\all.sln
I have tried almost all available combinations to generate build files and to build webrtc.lib static library. I have successfully managed to compile the static webrtc library webrtc.lib for both architectures;
x64 (Default Arch) (For Debug as well as release)
x86 (Custom Arch) (For Debug as well as release)
IMPORTANT:
I have successfully managed to run peerconnection_server.exe and
peerconnection_client.exe on windows. These examples are
successfully running on localhost.
Using VS2019:
After that, I created a new Console based project using VS2019 to consume generated binaries and followed these steps;
Add include folders
Configuration Properties → C/C++ → General → Additional Include Directories and add the following paths:
c:\webrtc\src
c:\webrtc\src\out\Default\$(Configuration)\$(PlatformTarget)\gen
c:\webrtc\src\third_party\abseil-cpp
c:\webrtc\src\third_party\libyuv\include
Preprocessor macros:
Click on Preprocessor → Preprocessor Definitions and add the following definitions:
USE_AURA=1;_HAS_EXCEPTIONS=0;__STD_C;_CRT_RAND_S;_CRT_SECURE_NO_DEPRECATE;_SCL_SECURE_NO_DEPRECATE;_ATL_NO_OPENGL;_WINDOWS;CERT_CHAIN_PARA_HAS_EXTRA_FIELDS;PSAPI_VERSION=2;WIN32;_SECURE_ATL;WINUWP;__WRL_NO_DEFAULT_LIB__;WINAPI_FAMILY=WINAPI_FAMILY_PC_APP;WIN10=_WIN32_WINNT_WIN10;WIN32_LEAN_AND_MEAN;NOMINMAX;_UNICODE;UNICODE;NTDDI_VERSION=NTDDI_WIN10_RS2;_WIN32_WINNT=0x0A00;WINVER=0x0A00;NDEBUG;NVALGRIND;DYNAMIC_ANNOTATIONS_ENABLED=0;WEBRTC_ENABLE_PROTOBUF=0;WEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE;RTC_ENABLE_VP9;HAVE_SCTP;WEBRTC_LIBRARY_IMPL;WEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0;WEBRTC_WIN;ABSL_ALLOCATOR_NOTHROW=1;HAVE_SCTP;WEBRTC_VIDEO_CAPTURE_WINRT
Linker additional library path:
Click on Linker → General → Additional Library Directories and add the following path:
c:\webrtc\src\out\Default\$(Configuration)\$(PlatformTarget)\obj
WebRTC library name:
Click on Input → Additional Dependencies and add the following filename:
webrtc.lib
Now, when I simply use this basic implementation such as;
#include <iostream>
#include "rtc_base/thread.h"
#include "rtc_base/logging.h"
#include "rtc_base/ssl_adapter.h"
#include "rtc_base/arraysize.h"
#include "rtc_base/net_helpers.h"
#include "rtc_base/string_utils.h"
#include "rtc_base/signal_thread.h"
int main(int argc, char** argv) {
rtc::InitializeSSL();
return 0;
}
The program is flooded with two types of errors:
1. LNK2038 mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug'
and another one is
2. LNK2038 mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2'
You can also see as given; Here I have used webrtc.lib with Configuration (Release) & Platform (x64).
Using Clion-2021.2.1 and CMAKE:
Here I have used webrtc.lib with Configuration (Release) & Platform (x86).
CMakeLists.txt is given as;
cmake_minimum_required(VERSION 3.20)
project(NewRtc)
set(CMAKE_CXX_STANDARD 14)
#set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
include_directories(
"c:/webrtc/src"
"C:/webrtc/src/out/Default/x86/obj"
"c:/webrtc/src/third_party/abseil-cpp"
"c:/webrtc/src/third_party/libyuv/include"
)
# error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
# Solution:
#1. _ITERATOR_DEBUG_LEVEL = 0 // disabled (for release builds)
#2. _ITERATOR_DEBUG_LEVEL = 1 // enabled (if _SECURE_SCL is defined)
#3. _ITERATOR_DEBUG_LEVEL = 2 // enabled (for debug builds)
add_definitions(
-D_ITERATOR_DEBUG_LEVEL=0
-DUSE_AURA=1
-D_HAS_EXCEPTIONS=0
-D__STD_C
-D_CRT_RAND_S
-D_CRT_SECURE_NO_DEPRECATE
-D_SCL_SECURE_NO_DEPRECATE
-D_ATL_NO_OPENGL
-D_WINDOWS
-DCERT_CHAIN_PARA_HAS_EXTRA_FIELDS
-DPSAPI_VERSION=2
-DWIN32
-D_SECURE_ATL
-DWINUWP
-D__WRL_NO_DEFAULT_LIB__
-DWINAPI_FAMILY=WINAPI_FAMILY_PC_APP
-DWIN10=_WIN32_WINNT_WIN10
-DWIN32_LEAN_AND_MEAN
-DNOMINMAX
-D_UNICODE
-DUNICODE
-DNTDDI_VERSION=NTDDI_WIN10_RS2
-D_WIN32_WINNT=0x0A00
-DWINVER=0x0A00
-DNDEBUG
-DNVALGRIND
-DDYNAMIC_ANNOTATIONS_ENABLED=0
-DWEBRTC_ENABLE_PROTOBUF=0
-DWEBRTC_INCLUDE_INTERNAL_AUDIO_DEVICE
-DRTC_ENABLE_VP9
-DHAVE_SCTP
-DWEBRTC_LIBRARY_IMPL
-DWEBRTC_NON_STATIC_TRACE_EVENT_HANDLERS=0
-DWEBRTC_WIN
-DABSL_ALLOCATOR_NOTHROW=1
-DHAVE_SCTP
-DWEBRTC_VIDEO_CAPTURE_WINRT)
#set(CMAKE_CXX_FLAGS_RELEASE "/MT")
#set(CMAKE_CXX_FLAGS_DEBUG "/MTd")
set(-Dwebrtc.lib)
add_executable(NewRtc main.cpp)
set_property(TARGET NewRtc PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_link_libraries(NewRtc
PRIVATE "C:/webrtc/src/out/Default/x86/obj/webrtc.lib"
)
But when I simply build the project, this error comes up for every implementation of WebRtc. Here you can see:
Please assist me that how can I simply use webrtc library in any project on windows suing VS2019 or Clion. I am trying to solve these problems, I have tried multiple solutions over stack overflow and other communities using cmake or adding flags inside project properties such as;
Linker Tool Errors
/MD, /MT, /LD (Use Run-Time Library)
LNK2038 mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2'
Mismatch Detected for 'RuntimeLibrary'
I have tried my best to explain the complete solution and associated problem so that someone might help me accordingly.
Well Guys, After spending almost 12 hours of research, I have made my day. I have exactly figured out what was wrong with my development setup in (VS2019/Clion) of using static webrtc.lib in executable projects.
I must thank Mr.#drescherjm for his support on my question. It's
really appreciated it.
All things were in a positive direction from library compilation to its usage in VS2019/Clion projects. Actually, webrtc development in .netCore projects required some useful libraries for the normal use of webrtc.lib in your projects.
Here is the list of libraries that you must use during development such as;
For Windows:
Required Modules for building WebRtc projects for Windows as follows;
WS2_32 secur32.lib winmm.lib dmoguids.lib wmcodecdspuuid.lib msdmo.lib Strmiids.lib
For Linux:
Required Modules for building WebRtc projects for Linux as follows;
Secur32 Msdmo Winmm Dmoguids wmcodecdspuuid
These are the important libraries as webrtc peer-to-peer communication mostly comes up with the extensive implementation of socket programming in C/C++ for both Linux as well as Windows Operating Systems.
How to use these libraries in projects:
using CmakeLists.txt
using #pragma keyword
For CMakeLists.txt:
You can simply include these modules in target_link_libraries() in which you are also linking webrtc.lib such as;
add_executable(NewRtc main.cpp)
set_property(TARGET NewRtc PROPERTY
MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
target_link_libraries(NewRtc
PRIVATE "{$LIB_PATH}/webrtc.lib"
# Required Modules for building projects
WS2_32 secur32.lib winmm.lib dmoguids.lib wmcodecdspuuid.lib msdmo.lib Strmiids.lib
)
For #Pragma Keyword:
You can directly include all the required libraries using the #pragma keyword inside your executable files (in my case main.cpp) such as;
# pragma comment(lib, "webrtc.lib")
# pragma comment(lib,"WS2_32")
# pragma comment(lib, "secur32.lib")
# pragma comment(lib, "winmm.lib")
# pragma comment(lib, "dmoguids.lib")
# pragma comment(lib, "wmcodecdspuuid.lib")
# pragma comment(lib, "msdmo.lib")
# pragma comment(lib, "Strmiids.lib")
Both procedures will 100% serve the same purpose. I hope it would help someone.

Need to use release library in cmake debug build

I have generated a release library using CMAKE that needs to be kept proprietary. I plan to put header files into an include directory and library files into a lib directory.
The CMAKE line used to generate the library is:
add_library(Ethernet STATIC ${eth_srcs} $<TARGET_OBJECTS:EthernetBootloader>)
There are separate Visual Studio solutions for generating a library and running a control panel that uses the library. Running the Control Panel in debug mode only works with a debug library. If the Control Panel compiles and runs in debug mode and the library was built in release mode I get several errors that look like:
Ethernet.lib(ethernet.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in main.obj
Ethernet.lib(ethernet.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MDd_DynamicDebug' in main.obj
I am beginning to write a "ethernet-config.cmake" file that contains:
set(ETHERNET_INCLUDE_DIR "${CMAKE_CURRENT_LIST_DIR}/include")
set(ETHERNET_LIBRARIES "${CMAKE_CURRENT_LIST_DIR}/lib/Ethernet.lib")
string(STRIP "${ETHERNET_LIBRARIES}" ETHERNET_LIBRARIES)
and the CMakeLists.txt looks something like:
set(Ethernet_DIR "C:/MotorController/public")
find_package(Ethernet REQUIRED)
include_directories(${ETHERNET_INCLUDE_DIR})
target_link_libraries(ControlPanel ${ETHERNET_LIBRARIES})
How do I use a release library in a Visual Studio 2015 Windows 7 64-bit debug application? I think I need to adapt my CMakeLists.txt for the debug application but haven't figured it out.

mismatch detected for 'vccorlib_lib_should_be_specified_before_msvcrt_lib_to_linker': value '1' doesn't match value '0' in msvcrtd.lib

I have a C library project for UWP. There are some C files which are calling C++ WINRT functions defined in CPP file.It is compiling successfully and generating a library file(LIB). I am compiling in Visual Studio 2015 with update 1 and target platform is 10.0.10240.0
But, I want to generate DLL instead of LIB file. Here's the changes I did to change the project so that it generates DLL instead of LIB.
Try1:
So, In the startup project, In Configuration Properties => General I change Configuration from Static Library to Dynamic Library.
And in all the project, I changed from Multi-threaded Debug(/MTd) to Multi-threaded Debug DLL(/MDd).
Try2:
Created a new project Windows Universal Project and added the all the files from the project creating LIB to this project. Still, I am getting the below errors.
Now, I am getting the errors
vccorlibd.lib(init.obj) : error LNK2038: mismatch detected for 'vccorlib_lib_should_be_specified_before_msvcrt_lib_to_linker': value '1' doesn't match value '0' in msvcrtd.lib(app_appinit.obj)
vccorlibd.lib(init.obj) : error LNK2005: __crtWinrtInitType already defined in msvcrtd.lib(app_appinit.obj)
msvcrtd.lib(initializers.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
Any Suggestions how to resolve this.
I had the same Issue and fixed it using the linker flags:
/nodefaultlib:vccorlib /nodefaultlib:msvcrt vccorlib.lib msvcrt.lib
for debug builds you can use:
/nodefaultlib:vccorlibd /nodefaultlib:msvcrtd vccorlibd.lib msvcrtd.lib
The standard /nodefaultlib did not work for me.
The following linker flags (for debug) did the trick in my case:
/defaultlib:'vccorlibd.lib' /defaultlib:'msvcrtd.lib'

CRT library: wrong version

During the compilation process of my application (Debug mode), I am getting the following error, related to the CRT library:
16>libcpmt.lib(stdhndlr.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in poStat.obj
According to the Microsoft MSDN topic, I need to set the runtime library to /MTd in order to append the correct library compiled with debug mode. I also have to define a _DEBUG flag - and thats exactly what I have done.
Even though I have did everything it requires to use the CRT with debug mode, its still trying to use one without the debug mode (libcpmt.lib instead of the libcpmtd.lib).
How can I fix this?
Update
When I go to the C:\Program Files\Microsoft Visual Studio 11.0\VC\lib and change the name of libcpmtd.lib to the libcpmt.lib (had to temporary remove the existing libcpmt.lib) it builds successfully in a debug mode.
As Hans Passant already pointed out, the reason you have this is because some of the .lib or .obj files you are linking were compiled with Release settings, and some with Debug. The real question for you now is how to find which libraries or object files need to be fixed. Here is one way to do this
link /dump /all "Path_To_Lib_or_Obj" | findstr /L "\/DEFAULTLIB"
This will print out all default libraries, including CRT. This command has to be executed for each .lib and .obj that appears on your linker build command. For Debug you should see something like:
/DEFAULTLIB:msvcprtd
/DEFAULTLIB:MSVCRTD
/DEFAULTLIB:OLDNAMES
...
and for Release:
/DEFAULTLIB:msvcprt
/DEFAULTLIB:MSVCRT
/DEFAULTLIB:OLDNAMES
...

Linker errors against custom built tcl85.lib, works against ActiveState distribution's tcl85.lib

We are building Tcl ourselves in order to distribute our own compiled binaries with an application. The application itself links against the Tcl library and uses the API internally.
To build Tcl we got the sources from http://sourceforge.net/projects/tcl/, we then navigate into the /win directory, change the buildall.vc.bat file to point to our MSVC installation and then we run that bat file. Building works as expected and outputs are produced in /win/Release_VC11. More specifically, tcl85.lib and tcl85.dll are produced.
When we link against this .lib from within our Qt C++ application, we get a bunch of linker errors. For example:
commands.obj : error LNK2019: unresolved external symbol __imp_Tcl_AppendResult
referenced in function "int __cdecl CallQMessageBox(void *,struct Tcl_Interp *,
int,char * * const)" (?CallQMessageBox##YAHPEAXPEAUTcl_Interp##HQEAPEAD#Z)
However, when we link against the tcl85.lib file provided as part of the ActiveState Tcl distribution, the linker does not have any issues and builds fine. We verified that its the exact same version of Tcl in both cases.
We are using MSVC 2012 (Express Edition) to build Tcl, and the build command remains unmodified in buildall.vc.bat:
::set OPTS=threads
if not %SYMBOLS%.==. set OPTS=symbols
nmake -nologo -f makefile.vc release OPTS=%OPTS% %1
We've been trying all sorts of things with not luck.
Ok, figured it out:
I was building Tcl as a 32bit binary instead of a 64bit one.
Replacing
call "D:\tools\Microsoft Visual Studio 11.0\VC\bin\vcvars32.bat"
with
call "D:\tools\Microsoft Visual Studio 11.0\VC\bin\x86_amd64\vcvarsx86_amd64.bat"
and adding AMD64 to the nmake command like this
nmake -nologo -f makefile.vc release OPTS=%OPTS% %1 MACHINE=AMD64
in buildall.vc.bat seems to have fixed it.