GLFW not working in Visual Studio Community - c++

I am using Visual Studio for C++. I have tried to link GLFW in Visual Studio. The steps I went through are as follows:
Specify include directories under VC++ properties.
Specify the library directories under VC++ properties.
Add the .lib file in additional dependencies under Linker -> Input
Visual Studio recognises the header #include <GLFW/glfw3.h> and recognised glfwInit() but when glfwInit() is called it causes the build to fail. I get this build error:
LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
I then also get some unresolved externals:
LNK2019 unresolved external symbol __imp__vsnprintf referenced in function __glfwInputError
LNK2001 unresolved external symbol __imp__vsnprintf
LNK2019 unresolved external symbol __imp__sscanf referenced in function _parseVersionString
LNK2001 unresolved external symbol __imp___vsnprintf
LNK1120 3 unresolved externals

Sneaky... when I downloaded GLFW it had multiple lib folders (for the different releases) and only one include folder. I assumed that the include folder would work for all of the lib folders because there was only one. However that was not the case, the include folder only worked for the latest lib folder and I tried to use the 2013 GLFW instead of the latest 2015 GLFW lib folder with the include folder to no avail. I was using 2013 GLFW because that was the version the tutorial series I was watching used if you were wondering.

Related

Visual Studio 15 __imp___iob, __imp___pctype, __imp___mb_cur_max

I am trying to use a library compiled with mingw in visual studio. However, I get the following linker errors:
error LNK2001: unresolved external symbol __imp___iob
error LNK2019: unresolved external symbol __imp___pctype referenced in function
error LNK2019: unresolved external symbol __imp____mb_cur_max referenced in function
error LNK2001: unresolved external symbol _fprintf
I was able to fix the _fprintf error by linking against legacy_stdio_definitions.lib as per this post : unresolved external symbol __imp__fprintf and __imp____iob_func, SDL2.
However, I have no idea how to fix the other three unresolved externals. How can I fix this? The libraries work perfectly under Visual Studio 2013.
Edit:
Okay here is an update. I moved libmsvcrt.a from the mingw lib folder into Visual Studio, and I added that to the linker settings. Now it seems to work correctly.
The libraries were compiled against an old version of the CRT. The unresolved symbols you get are internal symbols of the CRT that are present in the compiled library. You have to recompile the library against the VS2015 CRT (the Universal CRT). But I'm not sure if MinGW supports this.
If you can't do that, you have to continue to use the VS2013 compiler. (You can use the VS2015 IDE, by setting the toolset to vs2013 in the project options. But you'll still be limited to the C++ features the 2013 compiler supports.)
I encountered the same problem (library compiled with static CRT instead of CRT in DLL) and I managed to make it work by changing the two following parameters in Project Properties:
Linker > Input > Ignore specific default libraries: libc.lib
C/C++ > Code Generation > Runtime Library: Multi-threaded Debug (/MTd)
If that's not enough, there's more at following page: https://social.msdn.microsoft.com/Forums/en-US/841e5723-bce4-4340-b7b3-027dcdf90f00/

Trying to use SDL 2 with Visual Studio c++

I am trying to do one that requires I use SDL2 and I was excited to finally start attempting to write a program. I downloaded SDL2 and didn't have any problems.
Next I opened a new empty project followed the instructions to add the include folder, lib(x86) folder, and I added the sdl2.lib and sdl2main.lib to the linker.
When I tried to build the project I received the following error.
1>MSVCRTD.lib(cinitexe.obj) : warning LNK4098: defaultlib 'msvcrt.lib'
conflicts with use of other libs; use /NODEFAULTLIB:library
1>sdl2main.lib(SDL_windows_main.obj) : error LNK2019: unresolved external
symbol _SDL_main referenced in function _main
1>c:\users\nas\documents\visual studio 2013\Projects\Basic SDL\Debug\Basic
SDL.exe : fatal error LNK1120: 1 unresolved externals
You need to link to the library files.
Right click the project and then properties
Click VC++ Directories.
Click include directories, then the down arrow, then <edit>.
Then add the directory of the include files (where all the .h files are, for example E:\Visual Studio .NET\SDL2-2.0.3\Include).
Then do the same for the library files by clicking library directories',down arrow,edit. However, you will want to make sure you are targeting x86 (for 32 bit program for exampleE:\Visual Studio .NET\SDL2-2.0.3\lib\x86`) or x64 (64bit program, not so common)
Then expand linker and click input on the left hand side.
Click additional dependencies, and then edit and add SDL2.lib and SDL2main.lib.
Click system under the linker heading.
Change SubSystem to /SUBSYSTEM:CONSOLE.
Finally make sure the SDL.dll file is in the folder of your project debug folder.

Unable to build MySQL++ library

I'm trying to build MySQL++ libraries via Visual Studio 2013 (MSVC-12.0). I've downloaded "mysql++-3.2.1.tar.gz" and unpack it. Then I added "mysql-connector-c-6.1.3-win32\include\" path to the include paths and "mysql-connector-c-6.1.3-win32\lib\" path to the libraries paths for the mysqlpp project in the mysql++ solution and tried to build it:
error LNK2001: unresolved external symbol mysql_thread_init
error LNK2001: unresolved external symbol mysql_num_rows
error LNK2001: unresolved external symbol mysql_num_fields
etc
What else should I link to this project? How can I solve it?
Those symbols are from the mysql client library, which is not included in mysql++.
Configuration Properties -> Linker -> Input -> Additional Dependencies needs libmysql.lib
I guess you used x64,but lib is win32

Implementing CURL with Visual Studio 2010

I am trying to compile a program that uses Curl in Visual Studio 2010 on Windows Vista x64. I downloaded the latest version of Curl 7.23.1 from the official website and unzipped it to C:Program Files. From there, I opened the VCProject file in the lib directory, converted it, and built it in Visual C++ Express Version. This resulted in the creation of a debug folder in the lib folder with object files, sbr files, and a libcurl.lib file. After that I opened a W32 Console Application in Visual Studio, added the include folder to include directories, added the debug folder to library directories and additional library directories under Linker, and added libcurl.lib to additional dependencies. When trying to compile my code, I received the following errors:
Error 1 error LNK2001: unresolved external symbol __imp__curl_easy_setopt C:\Users\********\Documents\Visual Studio 2010\Projects\MainProject\Run\Run\Run.obj
Error 2 error LNK2001: unresolved external symbol __imp__curl_easy_perform C:\Users\********\Documents\Visual Studio 2010\Projects\MainProject\Run\Run\Run.obj
Error 4 error LNK2001: unresolved external symbol __imp__curl_easy_init C:\Users\********\Documents\Visual Studio 2010\Projects\MainProject\Run\Run\Run.obj
Error 3 error LNK2001: unresolved external symbol __imp__curl_easy_cleanup C:\Users\********\Documents\Visual Studio 2010\Projects\MainProject\Run\Run\Run.obj
Error 5 error LNK1120: 4 unresolved externals C:\Users\********\Documents\Visual Studio 2010\Projects\MainProject\Run\Release\Run.exe Run
I have tried following some tutorials online but they are all outdated. The procedure I followed is supposed to work on Visual Studio 2008. I thought that maybe I may be missing some header files or have not built/compiled parts of Curl. Thanks for any help.
I have faced almost the same issue while trying to statically link the libcurl.lib using vs2010 professional edition.
try performing a pragma link like this one in the source file. It worked for me.
#pragma comment(lib, "libcurl.lib")
or
if the path is missing in search..
#pragma comment(lib, "<full_path>/libcurl.lib")

Setting up visual studio c++ 2008 with mysql c api

I'm wondering if anyone can help me on getting my visual studio c++ project setup correctly to work with MySql?
I downloaded and installed MySql Server, and installed the developer content with the include files, but beyond that I'm a bit lost.
I tried adding the 'include' directory in my MySql install path to my additional includes directory, which allowed me to access the includes I needed, but left me with unresolved external symbol errors.
1>Main.obj : error LNK2019: unresolved external symbol _mysql_error#4 referenced in function _main
1>Main.obj : error LNK2019: unresolved external symbol _mysql_real_connect#32 referenced in function _main
Any help would be greatly appreciated.
Sounds like the library isn't being included. The first thing I would look at is Additional Dependencies. You can either set it programatically or in Visual Studio (Solution->Properities->Configuration Properties-> Linker
You may need to include the library under "additional library directories" in that same area.