Build FLTK Multi-threaded (MT) project with Visual studio - c++

I use fltk lib in my project.
My goal is to compile my project with all libraries dependencies in it (now problem is only with FLTK), so I don't need to install vcredist libraries on each machine, where I want to use it.
So I read that for this I need to compile my project with parameters c/c++ --> code generation --> Runtime library --> Multi-threaded.
Now I'm using Multi-threaded DLL and everything works fine, but when I change it to MT I get error list (they got all similar code LNK2001):
Code LNK2001 Description unresolved external symbol __imp___wgetcwd file ConsoleApplication2\fltk.lib(fl_utf8.obj)
What I should do to compile my project with MT setup?

Solved.
My solution was recompiling FLTK static library with MT setup.

Related

Use XrSceneLib_uwp in a native HoloLens 2 OpenXR application

I'm trying to create a native HoloLens 2 C++ application with OpenXR. In the Microsoft OpenXR-MixedReality example I discovered the XrSceneLib_uwp project which has the configuration type set as static library (.lib) in the Visual Studio properties. Accordingly to that I tried to add it as a library in my solution which also has a Core Application (C++/WinRT) in it where I want to use the functions from XrSceneLib_uwp. In my thinking it makes sens because I can use the library for example to create a holographic title scene without much effort. The problem here is that when I build my solution I'm getting linker errors and I don't know how to fix them. I'm also relatively new to Visual Studio (22 in my case) and most likely I'm just doing someting wrong in the linking process.
Linker error when I try to build:
Error LNK2019 unresolved external symbol xrGetInstanceProcAddr referenced in function "public: __cdecl `anonymous namespace'::ImplementXrApp::ImplementXrApp(struct engine::XrAppConfiguration)" (??0ImplementXrApp#?A0x934f03db##QEAA#UXrAppConfiguration#engine###Z) CoreApp3 \repos\CoreApp3\CoreApp3\XrSceneLib_uwp.lib(XrApp.obj) 1
My solution explorer
Here is what I do:
I copy and paste the shared and openxr_preview folders from the OpenXR-MixedReality .zip file in my project folder.
Add XrSceneLib_uwp.vcxproj in /shared/XrSceneLib as an existing project to my solution.
Add the path to the copied shared and openxr_preview folders in Properties->Configuration Properties->C/C++->General->Additional Include Directories.
Add also the path to XrSceneLib_uwp.vcxproj in Additional Include Directories in my main project (CoreApp).
Add reference in CoreApp to XrSceneLib_uwp (Add->Reference->Projects).
After that everything works fine and I can even build the solution. But when I try to use the library I'm getting these linker errors. I don't understand why it works in the OpenXR-MixedReality examples but not when I try to implement it on an different project. What am I missing? I assume that XrSceneLib may not have been designed to be used externally in other projects but at the same time I think it should be possible somehow.
I also tried to add Additional Library Directories and the missing object files but either I have done something wrong or it just simply does not work.
I really appreciate any help.
I think the linker is failing to find the OpenXR Loader. The sample projects in the microsoft/OpenXR-MixedReality github repo link to the OpenXR Loader using the NuGet package manager. I get the same linker error if I purposely remove the NuGet package references from the sample projects.
You can either link to the OpenXR Loader using NuGet or you can build the OpenXR Loader youself. Take a look at the "Using OpenXR in an existing project" section on the microsoft site:
https://learn.microsoft.com/en-us/windows/mixed-reality/develop/native/openxr-getting-started#using-openxr-in-an-existing-project

Including an external library to my own library project c++ visual studio

Currently i have 3 visual studio projects:
ConsoleApplication
Logic
Test
These projects are all in the same solution. In the Logic project i use an external library named curl. My logic project is a static library made with the "new project" wizard in visual studio. This project includes a pch.h file. I added following things to my Logic project properties:
Set C/C++ > General > Additional Include Directories to the folder with the header files of curl
Set Libarian > General > Additional Library Directories to the folder with curl.lib in it.
Set Libarian > General > Additional Dependencies to curl.lib.
Now when i build the Logic project the output is a Logic.lib file. i checked with DUMPBIN /SYMBOLS /EXPORTS Logic.lib if the Curl functions are actually in the lib file, and they are.
To include the Logic project into the Console application i did the same 3 steps and added the Logic.lib to the Console application project. Everything works fine untill the moment i start using classes that use the external curl library. When i use these classes i get a link error: Unresolved external symbol (LNK 2019). I have tried much to fix this, but it seems that i am not capable of solving it. Am i doing something wrong that causes this not to work?
Also i would like to be able to use my logic project the same way as i do in my ConsoleApplication in my test project. For more context why i splitted up those projects can be found in my previous question Use c++ classes from console application class in other project visual studio
So after hours of research i found this post and i think this also applies to my case: Linking static libraries to other static libraries
TL;DR static libraries do not link with other static libraries
So i think the best solution in my case is to convert the static logic library to a dynamic lib (DLL)

C++ detours linking issue

I have problems building my code that is using static lib detours. I am trying to do an old basic CTF. For that I want to get into detours.
Whenever I try to build my .dll file I get an issue
LNK2019 unresolved external symbol _DetourTransactionBegin#0 referenced in function _DllMain#12
Now, I have built the detours library using 3 different version of the visual studio dev console.
I have tried firing 'vcvars32.bat' and then using nmake to build the library which was able to build it, but I get the above error during linking my .dll. I have also tried building it with 'vcvarsamd64_x86.bat' and then using nmake to build it which also was able to build the library, but I still get the same error as above during linking.
I have tried the usual stuff: the include folder for detours.h is added to C++/General/Additional Include Directories.
Under Linker/Additional Library Directories I added them as follows: "C:\temp\det_retry\lib.X64";"C:\temp\det_retry\lib.X86";%(AdditionalLibraryDirectories).
And also under Linker/Input/Additional Dependencies I have the following: detours.lib;%(AdditionalDependencies)
What am I missing here? This is a blocker for me for a couple of days and I am reiterating the same steps trying to figure out what's missing but I cannot see. I'd really appreciate the input.
I am sure I am using the newest version because I have downloaded (cloned) detours from the ms github page.
It appears your "Additional Library Directories" are setup incorrectly or contain invalid entries rather. They look like actual library file entries (i.e. pointing to some specific files) versus being only directories (e.g. "my/lib/path/for/my_project/"). Visual Studio's naming conventions are somewhat cryptic but they should be directory entries only. There should be an entry to whatever directory contains the detours.lib file (e.g. "MyProject/Libs/MSDetour" ... where MSDetour is a folder with the "detours.lib" in it) and then Visual Studio should find the library and link everything correctly.
As a side note, if you are using the Visual Studio developer console for building your project/solution you might want to look into CMake ... it is, in my opinion, significantly easier to work with (less "settings" digging) and maintain in the long-run.

Building and using OpenCV as a static library with Ffmpeg

I'm trying write an OpenCV application. I've statically built OpenCV from source as I don't want dll files and my project compiles as long as I don't use cv::VideoCapture, in which case I get a link error LNK2019 unresolved external symbol.
I think this is because the cv::VideoCapture uses ffmpeg to work with video, which, because of it's license, cannot be statically linked in my project. I would be ok with linking the ffmpeg dynamically but I'm having trouble doing this. There is a opencv_ffmpeg310_64.dll file in the %OpenCV_DIR%\bin folder, but I'm clueless about how to dynamically link it to my project. Usually I have .lib files that come with the .dll but I can't find them anywhere.
Is it possible to statically link OpenCV and dynamically link ffmpeg, and how should I go about doing this?
Additional info:
Windows 10
Visual Studio 2015
OpenCV 3.1.0 x64 build
I finally got it working. I was wrong thinking I needed ffmpeg to get it working. The problem I had was solved by adding vfw32.lib to the library dependencies in Visual Studio.

how to deploy simple boost program written in visual studio on other computers

I have written a simple program in C++ that uses the boost filesystem library to organize some files. I am using the Visual Studio 2013 Express for Windows Desktop IDE. I would like my program to run on other computers without an installer or anything else. The user should be able to just download the program and click on it.
I built my program in Release mode and it works on my computer. When I tried to deploy on another computer, the error I got was MSVCP120.dll is missing. To fix this I right-clicked on my project, clicked properties, then Configuration Properties > C/C++ > Code Generation, and I changed the Runtime Library from Multi-threaded DLL (/MD) to Multi-threaded (/MT). Now my program won't compile properly because of this build error:
Error 1 error LNK1104: cannot open file
'libboost_filesystem-vc120-mt-s-1_55.lib' C:\Users\inspection\Desktop\sortFile\Project1\Project1\LINK Project1
I looked in the following folder:
C:\Program Files\boost\boost_1_55_0\libs\filesystem\build\msvc-12.0\release\link-static\threading-multi
and I could not find libboost_filesystem-vc120-mt-s-1_55.lib, though I could find libboost_filesystem-vc120-mt-1_55.lib. The file names are close, they only differ by an '-s' term located after the '-mt' term.
How can I statically link the boost filesystem library so that my whole program runs as a standalone executable, without another user having to install anything?
Boost needs to be recompiled to match your new runtime library setting. The filename of the Boost library indicates the settings it was linked with, and the Boost auto-link code automatically updated the needed filename to match your new settings. In this case, it quite accurately indicates that you need a Boost lib which was compiled with a static stdlib link.