Can't link with libtiff in QT Creator/MSVC - c++

I am trying to write an application that saves 16 bit tiffs. I use QT Creator and the QT API, but can't use the QT tiff features because of the 16 bit need. My application needs to work in both Windows and Linux.
The Linux version works fine. When I try and link in Visual C++/Win 7, I get the following error messages:
FrameSaveRunnable.obj : error LNK2019: unresolved external symbol __imp_TIFFClose referenced in function "protected: virtual void __cdecl FrameSaveRunnable::run(void)" (?run#FrameSaveRunnable##MEAAXXZ)
FrameSaveRunnable.obj : error LNK2019: unresolved external symbol __imp_TIFFSetField referenced in function "protected: virtual void __cdecl FrameSaveRunnable::run(void)" (?run#FrameSaveRunnable##MEAAXXZ)
FrameSaveRunnable.obj : error LNK2019: unresolved external symbol __imp_TIFFWriteScanline referenced in function "protected: virtual void __cdecl FrameSaveRunnable::run(void)" (?run#FrameSaveRunnable##MEAAXXZ)
FrameSaveRunnable.obj : error LNK2019: unresolved external symbol __imp_TIFFOpen referenced in function "protected: virtual void __cdecl FrameSaveRunnable::run(void)" (?run#FrameSaveRunnable##MEAAXXZ)
debug\avtcam.exe : fatal error LNK1120: 4 unresolved externals
The relevant parts of my .pro file look like this:
INCLUDEPATH += "C:\Program Files (x86)\GnuWin32\include"
LIBS += -L"C:\Program Files (x86)\GnuWin32\lib" -llibtiff
I have googled and searched all over, and it seems that the problem has to do with C/C++ name incompatabilities. There are some suggestions as to how to fix it inside of Visual Studio, but I am working in the QT environment, and dont use VS at all--just the compiler. Is there an answer to this problem?
My environment: QT 5.4.0, Visual Studio 12, win 7 Pro, libtiff binaries downloaded from http://gnuwin32.sourceforge.net/packages/tiff.htm

You need libtiff compiled for MSVC. MSVC is the significant part of your environment, not Qt.
See http://www.remotesensing.org/libtiff/build.html#PC for instructions for building it (though I'm not sure if those are up to date), or there are other answers on stackoverflow on how to do it (eg Installing LibTiff to Visual Studio 2010).

Related

FLAC++ Unresolved external symbols (FLAC::Encoder::Stream::State::resolved_as_cstring and FLAC::Encoder::Stream::operator bool(void) const)

I am trying to set up the FLAC++ to allow me to encode/decode audio data, but when I attempt to compile I get 2 unresolved external errors:
LNK2019 unresolved external symbol "__declspec(dllimport) public: char const * __cdecl FLAC::Encoder::Stream::State::resolved_as_cstring(class FLAC::Encoder::Stream const &)const " (_imp?resolved_as_cstring#State#Stream#Encoder#FLAC##QEBAPEBDAEBV234##Z) referenced in function "public: int __cdecl"
LNK2019 unresolved external symbol "__declspec(dllimport) public: __cdecl FLAC::Encoder::Stream::operator bool(void)const " (_imp??BStream#Encoder#FLAC##QEBA_NXZ) referenced in function "public: int __cdecl"
I am linking both the FLAC.lib and FLAC++.lib files from program files (C:\Program Files (x86)\FLAC\lib).
I have tried installing 4 different versions of FLAC (1.3.3, 1.3.4, 1.4.0 and 1.4.1) but the linking errors still persist.
Does anyone have any suggestion to why this might be happening or what I might be missing here?
Thanks!
Edit: I am using Visual Studio 2022. I have ensured that CMake is configured to generate for Visual Studio 2022, and am compiling FLAC from the same version.
Edit 2: I have solved this by downloading the library from the latest GitHub commit from (https://github.com/xiph/flac). I am unsure why, but all stable releases seem to result in the same linking errors.

Including Lua in VS2015 C++ Project

I would like to integrate Lua into my current C++ application I build with VisualStudio 2015 (x64 mode).
I grabbed a simple Lua wrapper from here, and the Lua binaries for windows x64 from here (the lua-5.1.5_Win32_dll14_lib.zip one).
Next, I added the include and library path to the project preferences. Works so far in the IDE. However, when I try to compile the code it throws 24 errors (like these first two):
1>LuaScript.obj : error LNK2019: unresolved external symbol "lua_close" referenced in function ""public: __cdecl LuaScript::~LuaScript(void)" (??1LuaScript##QEAA#XZ)".
1>LuaScript.obj : error LNK2019: unresolved external symbol "lua_gettop" referenced in function ""public: void __cdecl LuaScript::clean(void)" (?clean#LuaScript##QEAAXXZ)".
which tells me next to nothing. Seems that the linker is unable to find the library but the includes are working and the path to library is set, too. Any suggestions what I might have missed or should look into? Any hint would be appreciated!

how to compile Leptonica library for windows x64 bit using VS2010?

I can build Leptonica libraries(DLL) for 32-bit windows using VS2010 by the help of http://www.leptonica.com/vs2008doc/building-liblept.html .
But when I change the Target into x64, I got below errors. How can I resolve this? Is it possible to compile the 32-bit source files in 64 bit?
2>tiffio.obj : error LNK2019: unresolved external symbol TIFFReadRGBAImageOriented referenced in function pixReadFromTiffStream
2>tiffio.obj : error LNK2019: unresolved external symbol TIFFReadScanline referenced in function pixReadFromTiffStream
2>tiffio.obj : error LNK2019: unresolved external symbol TIFFScanlineSize referenced in function pixReadFromTiffStream
2>tiffio.obj : error LNK2019: unresolved external symbol TIFFGetField referenced in function pixReadFromTiffStream
You are most likely missing the x64 libraries or you have not correctly placed the x64 libraries where the linker is looking for them.

OpenCV - SURF functionality issue

I am trying to build an OpenCV program which uses SURF matching algorithm, the code is in the following link :
http://feelmare.blogspot.ro/2011/10/sift-matching-c-source-code-using.html
However, I am obtaining 2 errors regarding some external symbols : _cvExtractSurf and _cvSURFParams.
error LNK2019: unresolved external symbol _cvExtractSURF referenced in function "public: bool __thiscall CMareMatchingClass::ExtractBGsurf(struct _IplImage *)" (?ExtractBGsurf#CMareMatchingClass##QAE_NPAU_IplImage###Z)
error LNK2019: unresolved external symbol _cvSURFParams referenced in function "public: __thiscall CMareMatchingClass::CMareMatchingClass(void)" (??0CMareMatchingClass##QAE#XZ)
Do you know how can I solve this errors? I am running the code by using opencv 2.3.0 in visual studio 2010 in Windows 7 - 64 bit.
You didn't link a needed library - try to link all OpenCV libraries in project settings. See documentation.

Linking Lua with Visual Studio 2010

We use Lua (www.lua.org) script to let users to customize our server software written in C++.
At the moment we are porting the 32 bits Windows version of our project to Visual Studio 2010.
Once everything works fine with VS 2008, we thought that we would have no problem on upgrade process.
Unfortunately whenever we tried to link the lualib (as dll) to our project in VS 2010, the lua functions could not be found by the linker (the error messages are displayed below).
It seems that some calling convention is wrong on 2010, like the application may be looking for the lua functions with a prefix '_'.
To access lua functions (written in C) from our project modules (C++) we use this:
extern "C" {
#include "lua/src/lua.h"
#include "lua/src/lualib.h"
#include "lua/src/lauxlib.h"
}
The same project compiles and links with lualib successfully on VS 2008 and Linux (g++).
Could anybody help me with this ?
1>dscscript.obj : error LNK2019: unresolved external symbol __imp__luaL_openlibs referenced in function "public: int __thiscall DsCScriptEngine::Init(void)" (?Init#DsCScriptEngine##QAEHXZ)
1>dscscript.obj : error LNK2019: unresolved external symbol __imp__luaL_newstate referenced in function "public: int __thiscall DsCScriptEngine::Init(void)" (?Init#DsCScriptEngine##QAEHXZ)
1>dscscript.obj : error LNK2019: unresolved external symbol __imp__lua_close referenced in function "public: void __thiscall DsCScriptEngine::Shutdown(void)" (?Shutdown#DsCScriptEngine##QAEXXZ)
1>dscscript.obj : error LNK2019: unresolved external symbol __imp__lua_pcall referenced in function "public: long __thiscall DsCScriptEngine::Execute(char const *)" (?Execute#DsCScriptEngine##QAEJPBD#Z)
etc.
The reported missing names are correct, this not a compile problem. You must be linking the wrong .lib. The name you use sounds wrong, it isn't "lualib", the current version of the import library is named lua5.1.lib (or lua51.lib, not sure what the difference is). Download it from here.