How to include Microsoft detours library in visual studio - c++

I am trying to use the detours library in a visual studio empty windows project. I cloned the repository (https://github.com/microsoft/Detours), I added the include directory into Project Properties / C/C++ / Additional Include Directories, and I added the lib.X86 directory into Project Properties / Linker / Additional Library Directories. I get no errors visible on the file, but when I build I get
1>Source.cpp
1>Source.obj : error LNK2019: unresolved external symbol _DetourTransactionBegin#0 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _DetourTransactionCommit#0 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _DetourUpdateThread#4 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _DetourAttach#8 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _DetourDetach#8 referenced in function _main
1>Source.obj : error LNK2019: unresolved external symbol _DetourRestoreAfterWith#0 referenced in function _main
1>C:\Users\colel\source\repos\Project3\Debug\Project3.exe : fatal error LNK1120: 6 unresolved externals
1>Done building project "Project3.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped =========
Which looks like the library wasn't included correctly. How do I properly include the detours library into a visual studio project and what am I doing wrong?

You need to add the specific .lib file, which I'm guessing is "detours.lib" (or similar) to the "Additional Dependencies" line.
Properties->Linker->Input->Additional Dependencies.

Related

Trouble installing GLFW: unresolved external symbol

I'm trying to run a program with GLFW in C++. I'm using visual studios 2019 on a windows 10 computer. I put the .h's and the .lib's in the proper folders and linked to them in the project settings. I'm running a minimal GLFW program I got off the internet. When I run it I get the following error:
1>------ Build started: Project: Riemannian, Configuration: Debug Win32 ------
1>Main.cpp
1>Main.obj : error LNK2019: unresolved external symbol __imp__glClear#4 referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwInit referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwTerminate referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwCreateWindow referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwWindowShouldClose referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwPollEvents referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwMakeContextCurrent referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _glfwSwapBuffers referenced in function _main
1>C:\Users\Aaron\source\repos\Riemannian\Debug\Riemannian.exe : fatal error LNK1120: 8 unresolved externals
1>Done building project "Riemannian.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
I tried adding glfw3.dll to system32, but that didn't change anything. (side note, GLFW came with a file glfw3dll.lib. Is that just a .lib file that serves the same purpose as glfw3.dll?) Next I tried linking to opengl32.lib in my project settings. This got rid of the first error, the one with the __imp__ prefix. After that there were only 7 unresolved external symbols. My project type is "Application (.exe)" if that's relevant. I'm out of ideas and tired of googling, does anyone know what to do?
On a broader note, I have wasted so many hours trying to get libraries to work in Python, Java, and C++. I am incredibly frustrated and I wish someone could just explain to me how libraries work once and for all so that next time I have a problem I won't be completely lost.
If all this setup is too complicated, you can also just take the Glitter project as a base. It takes care of all the boilerplate and just lets you get on with writing OpenGL. As a bonus, it is based on the cross-platform CMake build tool so your project should be easy to port to other operating systems.

Visual Studio Community 2017 linker problems - MariaDB

Its my first foray into messing with DB's in programming (specifically MariaDB) in Visual Studio and am not having much luck. It looks like I have configured external linking incorrectly however I am staring at my settings and just not seeing the error. Its probably going to be obvious to more experienced coders out there but I can't see the forest because of the trees.
I have tried compiling in both x86 and 64bit with their respective libraries. I've only included the x86 settings below but they are identical APART from pointing to "program files" instead of "program files x86"
My code is quite simple at the moment:
#include "stdafx.h"
#include <mysql.h>
int main()
{
MYSQL* temp;
temp = mysql_init(NULL);
return 0;
}
but when I try to compile I get the following output.
1>------ Build started: Project: test, Configuration: Debug Win32 ------
1>test.cpp
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
1>mariadbclient.lib(mariadb_lib.obj) : error LNK2019: unresolved external symbol __imp__ntohs#4 referenced in function _mysql_once_init
1>mariadbclient.lib(mariadb_lib.obj) : error LNK2019: unresolved external symbol __imp__getservbyname#8 referenced in function _mysql_once_init
1>mariadbclient.lib(mariadb_lib.obj) : error LNK2019: unresolved external symbol __imp__PathRemoveExtensionA#4 referenced in function _mysql_optionsv
1>mariadbclient.lib(mariadb_lib.obj) : error LNK2019: unresolved external symbol __imp__PathStripPathA#4 referenced in function _mysql_optionsv
1>mariadbclient.lib(ma_init.obj) : error LNK2019: unresolved external symbol __imp__WSAStartup#8 referenced in function _my_win_init
1>mariadbclient.lib(ma_init.obj) : error LNK2019: unresolved external symbol __imp__WSACleanup#0 referenced in function _ma_end
1>mariadbclient.lib(ma_pvio.obj) : error LNK2019: unresolved external symbol __imp__WSAGetLastError#0 referenced in function _ma_pvio_read_async
1>mariadbclient.lib(mariadb_async.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError#0
1>mariadbclient.lib(pvio_socket.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError#0
1>mariadbclient.lib(ma_default.obj) : error LNK2019: unresolved external symbol __imp__PathRemoveFileSpecA#4 referenced in function _get_default_configuration_dirs
1>mariadbclient.lib(mariadb_async.obj) : error LNK2019: unresolved external symbol __imp__connect#12 referenced in function _my_connect_async
1>mariadbclient.lib(pvio_socket.obj) : error LNK2001: unresolved external symbol __imp__connect#12
1>mariadbclient.lib(mariadb_async.obj) : error LNK2019: unresolved external symbol __imp__getsockopt#20 referenced in function _my_connect_async
1>mariadbclient.lib(pvio_socket.obj) : error LNK2001: unresolved external symbol __imp__getsockopt#20
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol ___WSAFDIsSet#8 referenced in function _pvio_socket_wait_io_or_timeout
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__bind#12 referenced in function _pvio_socket_connect
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__closesocket#4 referenced in function _pvio_socket_connect
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__ioctlsocket#12 referenced in function _pvio_socket_blocking
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__recv#16 referenced in function _pvio_socket_async_read
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__select#20 referenced in function _pvio_socket_wait_io_or_timeout
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__send#16 referenced in function _pvio_socket_async_write
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__setsockopt#20 referenced in function _pvio_socket_fast_send
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__shutdown#8 referenced in function _pvio_socket_close
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__socket#12 referenced in function _pvio_socket_connect
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__WSASetLastError#4 referenced in function _pvio_socket_wait_io_or_timeout
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__getaddrinfo#16 referenced in function _pvio_socket_connect
1>mariadbclient.lib(pvio_socket.obj) : error LNK2019: unresolved external symbol __imp__freeaddrinfo#4 referenced in function _pvio_socket_connect
1>mariadbclient.lib(ma_schannel.obj) : error LNK2019: unresolved external symbol __imp__CryptAcquireContextA#20 referenced in function _ma_schannel_load_private_key
1>mariadbclient.lib(ma_schannel.obj) : error LNK2019: unresolved external symbol __imp__CryptReleaseContext#8 referenced in function _ma_schannel_load_private_key
1>mariadbclient.lib(ma_schannel.obj) : error LNK2019: unresolved external symbol __imp__CryptDestroyKey#4 referenced in function _ma_schannel_load_private_key
1>mariadbclient.lib(ma_schannel.obj) : error LNK2019: unresolved external symbol __imp__CryptImportKey#24 referenced in function _ma_schannel_load_private_key
1>d:\nikuya\documents\visual studio 2017\Projects\test\Debug\test.exe : fatal error LNK1120: 27 unresolved externals
1>Done building project "test.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
My settings are below -
VC++ Directories -> Include Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\include\mysql
VC++ Directories -> Include Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\include\mysql\include
VC++ Directories -> Library Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\lib
VC++ Directories -> Library Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\lib\plugin
C++ Directories -> Addition Include Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\include\mysql
C++ Directories -> Addition Include Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\include
Linker -> General -> Addition Library Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\lib\plugin
Linker -> General -> Addition Library Directories -> C:\Program Files %28x86%29\MariaDB\MariaDB Connector C\lib
Linker -> Additional Dependancies -> mariadbclient.lib
Linker -> Additional Dependancies -> libmariadb.lib
Any help would be appreciated and please ask if any further info is needed.
note: I also tried including windows.h out of desperation but no dice.
The key line here is:
1>LINK : warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library
You are attempting to use a library which is incompatible with libcmt which is the multithreaded c run time library.
It is likely that you are compiling with a different switch (often /MD or /MT) somewhere to what was used to build the mariadb libs.
See here for more info:
https://msdn.microsoft.com/en-us/library/aa267384(v=vs.60).aspx

Link cURL in VS12

I am having a hard time linking cURL to my project on vs12 ...
I opted for the .msi solution that I picked here:
http://www.confusedbycode.com/curl/
and tried to link that to my project...
However I am still getting some errors after doing what I thought was right:
1>main.obj : error LNK2019: unresolved external symbol _curl_easy_init referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _curl_easy_setopt referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _curl_easy_perform referenced in function _main
1>main.obj : error LNK2019: unresolved external symbol _curl_easy_cleanup referenced in function _main
My configuration in my project vs12 is the following:
I included the include folder and the the lib folder in the vc++ directories
I added CURL_STATICLIB to the Preprocessor definition in C/C++ section as well as adding the proper include folder
I added the lib folder to the Linker sectio as well as libcurl.lib
Eventually I just included "curl.h" to the relevant .cpp file...
Is there something that I am missing?
Thank you a lot

Linking Error between matlab R2013a and MS VC++ 2013

I am writing a BCI game application in VC++ and require to implement Common Spatial Pattern Filtering (CSP) for feature extraction. Due to the hefty coding involved, I prefer to use an existing CSP Matlab function that I have. I followed the steps as given in here. However, I am getting the following Link error message:
1>------ Build started: Project: Test4, Configuration: Debug Win32 ------
1>test.obj : error LNK2019: unresolved external symbol _mxGetScalar referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _mxDestroyArray referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _mxCreateDoubleScalar referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _engEvalString referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _engOpen referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _engClose referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _engGetVariable referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _engPutVariable referenced in function _main
1>test.obj : error LNK2019: unresolved external symbol _engOutputBuffer referenced in function _main
1>D:\Test4\Debug\Test4.exe : fatal error LNK1120: 9 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Could anyone please help me fix the problem? Any comments would be appreciated. Thanks in advance.
As I said in the referred post, you have to keep the platforms consistent:
The platforms of MATLAB and VC++ compile platform must be the same, i.e. Win32/x86 VC++ compile platform can only use x86 MATLAB and x64 VC++ compile platform can only use x64 MATLAB.
You're using MATLAB x64, thus you have to build your VC project in x64 too.

Building m2crypto: 7 unresolved externals

I've tried to build M2Crypto (github) for win-amd64-py3.3:
python setup.py build --compiler msvc
And I've got an linker's unresolved external symbol errors (full log):
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:D:\Programy\Python33\libs /LIBPATH:D:\Programy\Python33\PCbuild\amd64 /LIBPATH:c:\pkg\lib ssleay32.lib libeay32.lib /EXPORT:PyInit___m2crypto build\temp.win-amd64-3.3\Release\SWIG/_m2crypto_wrap.obj /OUT:build\lib.win-amd64-3.3\M2Crypto\__m2crypto.pyd /IMPLIB:build\temp.win-amd64-3.3\Release\SWIG\__m2crypto.lib /MANIFESTFILE:build\temp.win-amd64-3.3\Release\SWIG\__m2crypto.pyd.manifest
_m2crypto_wrap.obj : warning LNK4197: export 'PyInit___m2crypto' specified multiple times; using first specification
Creating library build\temp.win-amd64-3.3\Release\SWIG\__m2crypto.lib and object build\temp.win-amd64-3.3\Release\SWIG\__m2crypto.exp
_m2crypto_wrap.obj : error LNK2019: unresolved external symbol PyString_AsStringAndSize referenced in function m2_PyString_AsStringAndSizeInt
_m2crypto_wrap.obj : error LNK2019: unresolved external symbol PyString_FromStringAndSize referenced in function bn_to_mpi
_m2crypto_wrap.obj : error LNK2019: unresolved external symbol PyInt_AS_LONG referenced in function asn1_integer_set
_m2crypto_wrap.obj : error LNK2019: unresolved external symbol PyBuffer_New referenced in function ec_key_get_public_der
_m2crypto_wrap.obj : error LNK2019: unresolved external symbol PyFile_AsFile referenced in function _wrap_err_print_errors_fp
_m2crypto_wrap.obj : error LNK2019: unresolved external symbol PyFile_Check referenced in function _wrap_err_print_errors_fp
_m2crypto_wrap.obj : error LNK2019: unresolved external symbol PyInstance_New referenced in function ssl_verify_callback
build\lib.win-amd64-3.3\M2Crypto\__m2crypto.pyd : fatal error LNK1120: 7 unresolved externals
What's going on? I'm using Win64 OpenSSL v1.0.1e. Do I need older libraries?
from the full log it looks like one first problem is that the compiler can't find the python c header files. Then the linker can't find the python library. Perhaps the options to cl.exe are not good (shouldn't it be /ID:\... instead of -ID:\...?) or you don't have the python header files installed.