Questions about third-party library(oat++) configuration in visual studio - c++

As a beginner, I want to use oat++ as a third-party library in visual studio, but I encountered some configuration problems.
First I downloaded the source file of the oat++ project and opened it in visual studio and cmake and install.
Then I created a new project in visual studio and started running the first example of the official website.
First of all, it need to configure the preprocessing, I will configure the Include directory first.
What I did is:(my project name is web4)
Project -> Web4 properties -> configuration properties -> VC++ Directories
set the Include Directories include C:\Users\13925\Documents\cpp\oatpp\out\install\x64-Debug\include\oatpp-1.2.5\oatpp
That is great. The compiler can find the #include "file"
After that I'm having trouble,An error occurred when I tried to compile.
Error LNK2019 unresolved external symbol __imp_WSAStartup referenced in function....
By searching for information, it is found that the cause of this problem is that the related library is not included.
But I tried the online method and it didn’t solve the problem,so ask for help here.
The online approach is like this:
Project -> Web4 properties -> configuration properties -> VC++ Directories
set the Library Directories include C:\Users\13925\Documents\cpp\oatpp\out\install\x64-Debug\lib\oatpp-1.2.5
In C:\Users\13925\Documents\cpp\oatpp\out\install\x64-Debug\lib\oatpp-1.2.5 has three files:oatpp.lib、oatpp-test.liband a .hfiles.
Project -> Web4 properties -> configuration properties -> Linker -> Input
set Additional Dependencies include oatpp.lib and oatpp-test.lib
Compile after completing the above four steps and find that the problem is still not solved.
And the problen still unresolved external symbol.
I would be very grateful if you are willing to help.

As far as I'm concerned, the problem is you are not linking against the Ws2_32.lib library. To fix this you could try to add that to your additional dependencies tab of linker/Input settings for your project. And you could also try to add: #pragma comment(lib, "Ws2_32.lib")
Best Regards,
Jeanine

Related

How do I use cURLpp with Visual Studio?

I'm using VS 2019, have downloaded all the cURLpp headers, put them and the cURL headers in an include folder and added this include directory under Project Properties -> Additional Include Directories. When I try to build example00.cpp from the cURLpp site, I get errors saying I have an unresolved external symbol. I've never used a third party library with C++ before, so please explain like I'm an idiot. Should I have a dll or lib file?
I use vcpkg to install curlpp, and I find that my project configuration in visual studio is x64, if I use x86 curlpp it will get build error, I need to use x64 curlpp then build sucess.
This is the include step:
Run cmd command: vcpkg install curlpp:x64-windows
goto Project > Configuration Properties -> Linker -> General -> Additional Library Directories, add yourVcpkgFolderPath\vcpkg\installed\x64-windows\lib\
goto Project > Configuration Properties -> Linker -> Input -> Additional Dependencies, add curlpp.lib
Then build the project, it should build success.

Visual Studio 2015 (C++) sqlite3.dll unresolved external symbol

I cannot figure out how to get sqlite3.dll (or any dll for that matter) to work with my C++ project in Visual Studio.
The error message I get is LNK2001 unresolved external symbol sqlite3_open
Here's what I did so far:
I put the .dll in myProjectFoler/Resources/sqlite3.dll
I generated sqlite3.lib using Visual Studio Developer Command Prompt using a command lib /def:sqlite3.def
I referenced the directory with the lib in Project -> Preferences -> Linker -> General -> Additional Library directories, and then referenced the .lib in Project -> Preferences -> Linker -> Input-> Additional dependencies
I placed sqlite3.h in my project and #included it
(pretty much followed the instructions seen here)
Thank you for help
The issue is that by default the header file assumes that sqlite is linked statically, as opposed to dynamic linking to a dll.
This part of sqlite3.h is responsible for that:
#ifndef SQLITE_API
# define SQLITE_API
#endif
If you set a per-project define in project properties:
SQLITE_API=__declspec(dllimport)
this should resolve your link error.
Alternatively, you can put
#define SQLITE_API __declspec(dllimport)
right before where you #include sqlite3.h.
It's difficult to tell exactly why the problem occurred. There are lots of reasons which could cause LNK2001 error. MSDN contains good check list.
You could try to use /VERBOSE option to determine which files the linker references. Put this option in Project -> Preferences -> Linker -> Command Line -> Additional Options. Output should contains similar strings:
Searching e:\SQLite\sqlite-dll-win32-x86-3150100\sqlite3.lib:
Found _sqlite3_open
Referenced in ConsoleApplication2.obj
Loaded sqlite3.lib(sqlite3.dll)
Pay attention to the VS runtime libraries, there should be no mixup between Debug and Release libraries.

Linker Issues VS2015. LNK2019 and LNK2001 unresolved external symbol

I am trying to extend my knowledge of constrain programming and I want to build a simple example using google's or-tools in VS2015.
However I am constantly nagged by those linker errors. LNK2019 and LNK2001. Why is linking in VS so darn hard.
Google's or-tools comes in a perfect folder, with an include subfolder and lib subfolder with one single .lib file.
I have added Additional Library Dependencies.
Configuration Properties -> Linker -> General Additional Library Dependencies : C:\PATH\or-tools.VisualStudio2013-64b\lib
Set the Input under the Linker properties section.
Configuration Properties -> Linker -> Input Additional Dependencies : ortools.lib
Infomed VC++ where the include directory is.
Configuration Properties -> VC++ Directories : C:\PATH\or-tools.VisualStudio2013-64b
However it is still throwing link errors when building the solution. What am I missing here.
Thanks in advance.
edit:
spelling
Since the VS2013 and VS2015 compiler versions are incompatible, you have to build the lib from source. Though beware that this might entail a bit more work when linking with VS2015. Specifically I've had to manually resolve the following issues:
Change protobuf-3.0.0-beta-1 to protobuf-3.0.0-beta-2(bonus. not really necessary)
gflags 2.1.2 failed to compile due to a conflict of names around snprintf. To resolve this download the latest gflags version from GitHub and overwrite the one in %OR_TOOLS%\dependencies
Look up all VS solution files (.sln) in dependencies\sources\cbc-2.9.7 and convert to VS2015 format by simply double clicking them and following the instructions.
Add the following code to makefiles\Makefile.port
ifeq ("$(VisualStudioVersion)", "14.0")
VISUAL_STUDIO=2015
VS_RELEASE=v140
VS_COMTOOLS=140
else
...
endif
Replace Visual Studio 12 2013 with Visual Studio 14 2015
Rerun make third_party after each step.
Or you can just download the end result, linked on Windows 10 x64 VS2015 update 1. I've included the whole folder after running make third_party && make cc.

Microsoft Visual Studio 2013 Link Error 1104

A while ago I attempted to make make a game using c++ and SDL. I am now taking a class that requires me to program in C++ and I would like to use VS as the IDE. I uninstalled VS 2012 and upgraded to 2013. I am able to compile c# code but when I make a c++ project I get the error
error LNK1104: cannot open file 'SDL.lib'
I went to the project properties -> Configuration Properties -> Linker -> input and made sure that SDL was not referenced there. My Additional Dependencies now has the value %(AdditionalDependencies). The rest of the options are blank. I also made sure that in VC++ Directories the Include Directories did not include anything related to SDL. Having done all of this I still get the same error. Is is somehow inheriting the SDL linker. The project only contains a hello world program which does not include any other libraries. Any help is appreciated.
You can try this:
Right click the project and choose Properties.
Open Configuration Properties --> Linker -->Input.
In the Ignore Specific Default Libraries entry, add SDL.lib.
BTW, whatever you add in your Include Directories cannot cause a linkage error (and neither can any include that you have in your project).

Visual Studio 2012 - error LNK1104: cannot open file 'glew32.lib'

I am having issues compiling a basic openGL program on VS 2012. I get a build error upon compiltation giving me:
1>LINK : fatal error LNK1104: cannot open file 'glew32.lib'
I followed the instructions given to me by the documentation for GLEW.
In your OpenGL project open Project -> Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies -> add glew32.lib.
Also you must include #include in your sources; For that add path to your glew folder: Project -> Properties -> Configuration Properies -> General -> VC++ Directories -> Include Directories and Library Directories;
C/C++ Tab -> General -> Additional Include Directories - Add lib folder there
I have also added the glew32.dll onto my Debug folder within my project folder along with the executable. So far I keep getting this error.
If you need any more further clarification of the steps I have done please don't hesitate to ask
In all honesty, there is no real benefit to using the DLL version of glew (short of reduced executable size, but this hardly matters on modern Windows PCs).
It is not like you can simply drop a new version of the DLL into your application and use extensions that you never used before. Likewise, bug fixes are so infrequent/unnecessary with a library that basically just parses the extension spec. files that using the DLL as a means of fixing extension loading bugs in shipped software is also not practical. Statically linking to glew (this means glew32s.lib) makes much more sense in the long run.
The static linking library is also more portable on Windows, it will work with MSVC and MinGW (whereas the DLL library only works with MSVC). Link against glew32s and put that in whatever directory you decided to use for additional library dependencies.
Here is a sample solution configuration for a project I wrote that uses glew. I have established a convention for this particular software where compile-time dependencies are stored under platform/<Subsystem>. Thus, I have glew32s.lib (32-bit) and glew64s.lib (64-bit) in ./Epsilon/platform/OpenGL/glew{32|64}s.lib
Steps to Use Classes form another project (Add header and solver linker errors)
To be able to add the header from another project, first go to "Properties > c++ > General > Additional Include Directories" and add the directory that contains the header. Now you will be able to add the header of the class from the other project, but running the project will still cause Linker Errors.
Add __declspec(dllexport) before the class you are using for the other project. This can be added in the header file of that class. This should be added right before the function or variable or class name. Now you will get a lib file. (if placed in wrong place, you can get this warning: https://msdn.microsoft.com/en-us/library/eehkcz60.aspx)
"Properties > Linker > Additional Library Directories". Specify the location of the lib file that is generated.
"Properties > Linker > Input > Additional Dependencies”: Add the name of the lib file.
This sounds like the library has been specified as a dependency, but the linker/additional search path(s) has not been set to include the directory where the library is located.
This may help.
It happened to me under this situation, I clean the solution and build it again, then many errors like LNK1104 occur.
After trying to restart IIS, I build solution successfully without LNK1104 errors. I do not know why, but restarting IIS takes much more time than normal, so I guess something is used by other IIS worker process.
Just give a shot to see if this magic happens on you.
This question is old and marked solved, but I had a similar problem symptoms with a completely different solution. So just in case anyone else stumbles in here:
It appeared that because I had 2 projects under one solution (a dll and an exe), the building order was mixed (from the output window):
1> Rebuilding project1..
2> Rebuilding project1..
1> file1.cpp
2> file1.cpp
and so on. By the message you copied, it appears you too have more than one project under one solution. One project was looking for the *.lib file that the other build hadn't created yet.
Solution:
Right click on "main" project -> Build Dependencies -> Project Dependencies.. -> Mark which project the main one depends on.